我在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
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-customer1
和ios/Pods/Target Support Files/Pods-RNProject-customer2
我尝试了不同的解决方法:
sudo react-native
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)
答案 0 :(得分:0)
问题在于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));
这两种方法不同,导致两个不同的可执行文件名(例如Xcode build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app
vs React Native build/Build/Products/Debug-iphonesimulator/RNProject.app
)。
我为inferredSchemeName
设置了自定义值,以匹配Xcode创建的文件名。
答案 1 :(得分:0)
我的解决方案类似:
从以下位置更改构建路径:
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