ios - React Native: bundle 标识符不存在

标签 ios react-native cocoapods xcode-project xcodeproj

我在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)
    

    最佳答案

    问题在于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/

    相关文章:

    ios - Swift:多个本地通知但只显示最新的

    java - 现有应用程序(java/eclipse/android)到其他平台

    ios - 使用点击手势选择行

    ios - 按钮之间的标签在哪里

    javascript - 组件在更新时消失

    android - react-native gradle config 和 react-native-firebase 最新版本不匹配

    ios - Xcode 11 Swift 5 - 无法安装应用程序(无法加载 info.plist 文件)

    ios - 适用于 iOS 的 MobileVLCKit 无法构建(pod 和框架)

    node.js - 未处理的 promise 拒绝警告 : Error: Cannot find module '/MyProject/node_modules/react-native-scripts/build/scripts/init.js'

    ios - 如何为具有静态库目标的项目创建 PodSpec?