[英]How to change the "Bundle Identifier" within React Native?
[英]React Native: Bundle Identifier does not exist
我在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
存在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創建的文件名。
我的解決方案是類似的:
從以下位置更改構建路徑:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.