From 1d554cebf6e1b346f9a1dc3e76250af2b1cd3ffa Mon Sep 17 00:00:00 2001 From: aleksipousar Date: Thu, 28 Sep 2017 15:28:36 +0300 Subject: [PATCH] Added automatic React linking to the iOS side --- README.md | 5 ++ command.js | 2 +- templates/general.js | 7 +- templates/ios.js | 153 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 164 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 34a871a..01ca238 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ $ react-native-create-library MyFancyLibrary This will create the folder `MyFancyLibrary` in which the library will be created in. +Now install dependencies by running this command in the newly created library. +``` +$ npm install +``` + ``` Usage: react-native-create-library [options] diff --git a/command.js b/command.js index cbc6c8e..a1b629f 100644 --- a/command.js +++ b/command.js @@ -28,7 +28,7 @@ module.exports = { console.log(` ${emoji.get('books')} Created library ${name} in \`./${name}\`. ${emoji.get('clock9')} It took ${Date.now() - beforeCreation}ms. -${emoji.get('arrow_right')} To get started type \`cd ./${name}\``); +${emoji.get('arrow_right')} To get started type \`cd ./${name}\` and run \`npm install\``); }).catch((err) => { console.error(`Error while creating library ${name}`); diff --git a/templates/general.js b/templates/general.js index 620b086..2185a56 100644 --- a/templates/general.js +++ b/templates/general.js @@ -74,7 +74,9 @@ ${name}; }, { name: () => 'package.json', content: ({ moduleName, platforms }) => { - let dependencies = '"react-native": "^0.41.2"'; + let dependencies = ` + "react": "16.0.0-alpha.6", + "react-native": "^0.44.1"`; if (platforms.indexOf('windows') >= 0) { dependencies += `, "react-native-windows": "0.41.0-rc.1" @@ -96,6 +98,9 @@ ${name}; "license": "", "peerDependencies": { ${dependencies} + }, + "devDependencies": { + ${dependencies} } } `; diff --git a/templates/ios.js b/templates/ios.js index e23b059..1e32262 100644 --- a/templates/ios.js +++ b/templates/ios.js @@ -77,9 +77,69 @@ RCT_EXPORT_MODULE() objects = { /* Begin PBXBuildFile section */ + 289A75F91F7D1C4500E34F27 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 289A75E91F7D1BF800E34F27 /* libReact.a */; }; B3E7B58A1CC2AC0600A0062D /* ${name}.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* ${name}.m */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 289A75E81F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; + 289A75EA1F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28131D9B038B00D4039D; + remoteInfo = "React-tvOS"; + }; + 289A75EC1F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3C059A1DE3340900C268FA; + remoteInfo = yoga; + }; + 289A75EE1F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3C06751DE3340C00C268FA; + remoteInfo = "yoga-tvOS"; + }; + 289A75F01F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; + remoteInfo = cxxreact; + }; + 289A75F21F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; + remoteInfo = "cxxreact-tvOS"; + }; + 289A75F41F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; + remoteInfo = jschelpers; + }; + 289A75F61F7D1BF800E34F27 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; + remoteInfo = "jschelpers-tvOS"; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 58B511D91A9E6C8500147676 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; @@ -94,6 +154,7 @@ RCT_EXPORT_MODULE() /* Begin PBXFileReference section */ 134814201AA4EA6300B7C361 /* lib${name}.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = lib${name}.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; B3E7B5881CC2AC0600A0062D /* ${name}.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ${name}.h; sourceTree = ""; }; B3E7B5891CC2AC0600A0062D /* ${name}.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ${name}.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -103,6 +164,7 @@ RCT_EXPORT_MODULE() isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 289A75F91F7D1C4500E34F27 /* libReact.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -117,12 +179,36 @@ RCT_EXPORT_MODULE() name = Products; sourceTree = ""; }; + 289A75DE1F7D1BF800E34F27 /* Products */ = { + isa = PBXGroup; + children = ( + 289A75E91F7D1BF800E34F27 /* libReact.a */, + 289A75EB1F7D1BF800E34F27 /* libReact.a */, + 289A75ED1F7D1BF800E34F27 /* libyoga.a */, + 289A75EF1F7D1BF800E34F27 /* libyoga.a */, + 289A75F11F7D1BF800E34F27 /* libcxxreact.a */, + 289A75F31F7D1BF800E34F27 /* libcxxreact.a */, + 289A75F51F7D1BF800E34F27 /* libjschelpers.a */, + 289A75F71F7D1BF800E34F27 /* libjschelpers.a */, + ); + name = Products; + sourceTree = ""; + }; + 289A75F81F7D1C4500E34F27 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; 58B511D21A9E6C8500147676 = { isa = PBXGroup; children = ( B3E7B5881CC2AC0600A0062D /* ${name}.h */, B3E7B5891CC2AC0600A0062D /* ${name}.m */, 134814211AA4EA7D00B7C361 /* Products */, + 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */, + 289A75F81F7D1C4500E34F27 /* Frameworks */, ); sourceTree = ""; }; @@ -170,6 +256,12 @@ RCT_EXPORT_MODULE() mainGroup = 58B511D21A9E6C8500147676; productRefGroup = 58B511D21A9E6C8500147676; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 289A75DE1F7D1BF800E34F27 /* Products */; + ProjectRef = 289A75DD1F7D1BF800E34F27 /* React.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 58B511DA1A9E6C8500147676 /* ${name} */, @@ -177,6 +269,65 @@ RCT_EXPORT_MODULE() }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 289A75E91F7D1BF800E34F27 /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 289A75E81F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75EB1F7D1BF800E34F27 /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 289A75EA1F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75ED1F7D1BF800E34F27 /* libyoga.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libyoga.a; + remoteRef = 289A75EC1F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75EF1F7D1BF800E34F27 /* libyoga.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libyoga.a; + remoteRef = 289A75EE1F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75F11F7D1BF800E34F27 /* libcxxreact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcxxreact.a; + remoteRef = 289A75F01F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75F31F7D1BF800E34F27 /* libcxxreact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcxxreact.a; + remoteRef = 289A75F21F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75F51F7D1BF800E34F27 /* libjschelpers.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libjschelpers.a; + remoteRef = 289A75F41F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 289A75F71F7D1BF800E34F27 /* libjschelpers.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libjschelpers.a; + remoteRef = 289A75F61F7D1BF800E34F27 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXSourcesBuildPhase section */ 58B511D71A9E6C8500147676 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -274,7 +425,7 @@ RCT_EXPORT_MODULE() isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ( - "$(inherited)", + "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../../../React/**", "$(SRCROOT)/../../react-native/React/**",