【问题标题】:React Native: Bundle Identifier does not existReact Native:捆绑标识符不存在
【发布时间】:2016-07-25 14:58:50
【问题描述】:

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

【问题讨论】:

    标签: ios react-native cocoapods xcode-project xcodeproj


    【解决方案1】:

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

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

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

    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 创建的文件名。

    【讨论】:

      【解决方案2】:

      我的解决方法类似:

      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`;
          };
      
      • 删除路径中的“Build”。

      我正在使用 Xcode-beta 8.2

      【讨论】:

        猜你喜欢
        • 2017-08-14
        • 2020-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-03
        • 1970-01-01
        • 2018-05-21
        • 1970-01-01
        相关资源
        最近更新 更多