sho*_*ode 6 ios reactjs react-native
当我运行 react-native run-ios build 成功并在 ios 下创建了 build 文件夹。但是在构建后,当安装开始时,出现以下错误。当我通过 xcode 运行该项目时,该项目成功运行。我观察到的是,以“DerivedData”开头的路径是错误的。相反,它应该是“构建”。当我将我的“build”文件夹重命名为“DerivedData”并重新运行“react-native run-ios”时,整个过程成功完成,当然还有之前的构建。
如何将“DerivedData”更改为“build”?
我从 0.59.9 升级到 0.60.0 后立即出现此错误。
错误: info 安装“DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app” 处理命令时遇到错误(域=NSPOSIXErrorDomain,代码=2):无法安装请求的应用程序 在提供的路径中找不到应用程序包. 提供所需应用程序包的有效路径。打印:条目,“:CFBundleIdentifier”,不存在错误命令失败:/usr/libexec/PlistBuddy -c 打印: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 Print: Entry, ":
在 checkExecSyncError (child_process.js:616:11) at Object.execFileSync (child_process.js:634:13) at 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)
React Native 版本: 系统:操作系统:macOS 10.15 二进制文件:节点:10.15.3 - /usr/local/bin/node npm:6.13.1 - /usr/local/bin/npm Watchman:4.9.0 - /usr/local /bin/watchman SDKs: 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: react: 16.8.6 => react16.0 -native: 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
重现步骤
解决方案并不明显,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;
}
Run Code Online (Sandbox Code Playgroud)
诀窍不是修补这个文件,而是首先正确设置你的 xcode 配置Xcode > Preferences > Locations(见图)
和 Xcode > Preferences > Locations > Advanced
完成此操作后,您必须清理构建文件夹,否则,react-native-cli仍会假设 xcode 未按预期运行,这将继续产生相同的错误。
cd ios && rm -rf build
你现在可以执行了npx react-native run-ios,一切都应该好了。
我花了很长时间才弄清楚这一点,我认为react-native-cli应该输出更多关于幕后发生的事情的详细信息,以使人们不被阻止。
问题解决了。我必须编辑 @react-native-community 内的文件。
如果其他人也有同样的问题,解决方案如下。
File location:
-> file:
-> node_modules
-> @react-native-community
-> cli-platform-ios
-> build
-> commands
-> runIOS
-> index.js line 314
Run Code Online (Sandbox Code Playgroud)
改变:DerivedData/Build/Products/${configuration}-${device}/${appName}.app
到:build/Build/Products/${configuration}-${device}/${appName}.app
Cheers.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4095 次 |
| 最近记录: |