反应本机ios构建成功,但应用程序捆绑的路径错误

时间:2019-11-28 06:28:03

标签: ios reactjs react-native

当我运行react-native run-ios构建成功并在ios下创建了build文件夹。但是在构建之后,当安装开始时,出现以下错误。通过xcode运行该项目时,该项目成功运行。我观察到的是以“ DerivedData”开头的路径是错误的。相反,它应该是“构建”。当我将我的“ build”文件夹重命名为“ DerivedData”并重新运行“ react-native run-ios”时,整个过程成功完成,但当然要使用先前的构建。

如何将“ DerivedData”更改为“ build”?

我从0.59.9升级到0.60.0后立即发生了此错误。

错误: 信息安装“ DerivedData / Build /产品/Debug-iphonesimulator/mobileappname.app” 处理命令时遇到错误(domain = NSPOSIXErrorDomain,代码= 2): 无法安装请求的应用程序 在提供的路径中找不到应用程序包。 提供指向所需应用程序捆绑包的有效路径。 打印:条目“:CFBundleIdentifier”不存在 错误命令失败:/ usr / libexec / PlistBuddy -c Print:CFBundleIdentifier DerivedData / Build / Products / Debug-iphonesimulator / mobileappname.app / Info.plist 打印:条目“:CFBundleIdentifier”不存在 。使用--verbose标志运行CLI以获取更多详细信息。 错误:命令失败:/ usr / libexec / PlistBuddy -c Print:CFBundleIdentifier DerivedData / Build / Products / Debug-iphonesimulator / mobileappname.app / Info.plist 打印:条目“:CFBundleIdentifier”不存在

在checkExecSyncError(child_process.js:616:11) 在Object.execFileSync(child_process.js:634:13) 在runOnSimulator(/Users/armaneker/WebstormProjects/mobileappname/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:189:45) 在process._tickCallback(internal / process / next_tick.js:68:7)

反应原生版本: 系统: 作业系统:macOS 10.15 二进制文件: 节点:10.15.3-/ usr / local / bin / node npm:6.13.1-/ usr / local / bin / npm 守望者:4.9.0-/ usr / local / bin / watchman SDK: iOS SDK: 平台:iOS 13.0,DriverKit 19.0,macOS 10.15,tvOS 13.0,watchOS 6.0 Xcode:11.0 / 11A420a-/ usr / bin / xcodebuild npmPackages: 反应:16.8.6 => 16.8.6 反应本机:0.60.0 => 0.60.0 npmGlobalPackages: create-react-native-app:1.0.0 react-native-cli:2.0.1 react-native-git-upgrade:0.2.7

复制步骤

  • 使用rn-diff-purge从0.59.9升级到0.60.0
  • android正常工作
  • reli-native run-ios构建成功,但安装 应用失败

2 个答案:

答案 0 :(得分:4)

解决方案并不明显,react-native-cli试图猜测您的计算机上当前正在设置的xcode构建配置,这就是功能getBuildPath()上发生的事情

function getBuildPath(configuration, appName, isDevice, scheme) {
  let device;

  if (isDevice) {
    device = 'iphoneos';
  } else if (appName.toLowerCase().includes('tvos')) {
    device = 'appletvsimulator';
  } else {
    device = 'iphonesimulator';
  }

  let buildPath = `build/${scheme}/Build/Products/${configuration}-${device}/${appName}.app`; // Check wether app file exist, sometimes `-derivedDataPath` option of `xcodebuild` not works as expected.

  if (!_fs().default.existsSync(_path().default.join(buildPath))) {
    return `DerivedData/Build/Products/${configuration}-${device}/${appName}.app`;
  }

  return buildPath;
}

诀窍不是修补此文件,而是首先正确设置xcode配置Xcode > Preferences > Locations(参见图片)

enter image description here

Xcode > Preferences > Locations > Advanced

enter image description here

完成此操作后,您必须清理自己的构建文件夹,否则,react-native-cli仍将假设xcode的行为不符合预期,这将继续产生相同的错误。

cd ios && rm -rf build

您现在可以执行npx react-native run-ios,一切都应该再好了。

我花了很多时间弄清楚这一点,我认为react-native-cli应该输出更多细节,以防止人们受到阻碍。

答案 1 :(得分:0)

问题解决了。我必须在@ react-native-community中编辑一个文件。

如果其他人有相同的问题解决方案,则在下面。

File location:
-> file: 
    -> node_modules
        -> @react-native-community
          -> cli-platform-ios
                -> build
                    -> commands
                        -> runIOS
                            -> index.js line 314

更改:DerivedData/Build/Products/${configuration}-${device}/${appName}.app

收件人:build/Build/Products/${configuration}-${device}/${appName}.app


Cheers.