1

我在 React Native 中有一个项目,它有两种不同的构建方案并使用 cocoapods。要编译它,我运行:

react-native run-ios --scheme="RNProject-(SCHEME_NAME)"

生成的应用程序例如:

./build/Build/Products/Debug/iphonesimulator/RNProject-customer1.app
./build/Build/Products/Debug/iphonesimulator/RNProject-customer2.app
  • 使用它为其中一个构建方案构建的命令,而不是为另一个构建方案
  • Xcode 总是为两种构建方案构建项目
  • 此外,build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app/Info.plist存在于该路径中并且文件包含有效CFBundleIdentifier(它与General > Identity > Bundle Identifier两个构建方案中的每一个都匹配)
  • 两种方案的项目设置似乎都是正确的(检查后ios/RNProject.xcodeproj/project.pbxproj
  • 特定于模式的设置位于ios/Pods/Target Support Files/Pods-RNProject-customer1ios/Pods/Target Support Files/Pods-RNProject-customer2

我尝试了不同的方法来解决它:

  • 跑步sudo react-native
  • 重启 RN 打包器
  • 手动编辑Info.plist
  • 更改构建位置

安慰:

** BUILD SUCCEEDED **

Installing build/Build/Products/Debug-iphonesimulator/RNProject.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
child_process.js:509
    throw err;
    ^

Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/RNProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

    at checkExecSyncError (child_process.js:486:13)
    at Object.execFileSync (child_process.js:506:13)
    at ChildProcess.xcodeBuildProcess.on.code (node_modules/react-native/local-cli/runIOS/runIOS.js:109:36)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
4

2 回答 2

1

问题在于 React Native 名称如何标记可执行文件。

我的 Xcode 项目根据 Xcode 项目设置创建了两个名称不同的可执行文件。

另一方面,React Native 从.xcworkspace这个脚本 ( ./node_modules/react-native/local-cli/runIOS/runIOS.js:57) 中的文件名形成可执行文件名:

const inferredSchemeName = path.basename(xcodeProject.name, path.extname(xcodeProject.name));

这两种方法是不同的,会导致两个不同的可执行文件名(例如 Xcodebuild/Build/Products/Debug-iphonesimulator/RNProject-customer1.app与 React Native build/Build/Products/Debug-iphonesimulator/RNProject.app)。

我已经设置了自定义值inferredSchemeName来匹配 Xcode 创建的文件名。

于 2016-07-25T15:35:09.593 回答
0

我的解决方案类似:

  1. 打开 ./node_modules/react-native/local-cli/runIOS.js 文件
  2. 从以下位置更改构建路径:

    const getBuildPath = function(configuration = 'Debug', appName, isDevice) {  
      return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
    };
    

    const getBuildPath = function(configuration = 'Debug', appName, isDevice) {  
      return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
    };
  • 删除路径中的“构建”。

我正在使用 Xcode-beta 8.2

于 2016-12-09T04:58:43.093 回答