我在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)
最佳答案
问题在于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
与React Native build/Build/Products/Debug-iphonesimulator/RNProject.app
)。我已经为
inferredSchemeName
设置了自定义值,以匹配Xcode创建的文件名。
关于ios - React Native: bundle 标识符不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38571152/