gpt4 book ai didi

xcode - react 原生上不存在 CFBundleIdentifier

转载 作者:行者123 更新时间:2023-12-04 12:09:43 28 4
gpt4 key购买 nike

在这里可以轻松获得赏金。不一定需要任何 react-native 经验。问题似乎出在开源代码中,可以在那里获得:
更新了 xcode,现在当我尝试通过发出以下命令来运行我的 react-native 应用程序时:react-native run-ios我收到一个错误:

An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):Failed to install the requested applicationAn application bundle was not found at the provided path.Provide a valid path to the desired application bundle.Print: Entry, ":CFBundleIdentifier", Does Not Existerror Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plistPrint: Entry, ":CFBundleIdentifier", Does Not Exist


debug Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plistPrint: Entry, ":CFBundleIdentifier", Does Not Existat checkExecSyncError (child_process.js:616:11)at Object.execFileSync (child_process.js:634:13)at runOnSimulator (project-root-dir/node_modules/@react-native-community/cli/build/commands/runIOS/runIOS.js:181:45)


在出现这些错误之前,该命令会打印出有关成功构建以及即将安装构建的信息:

info ** BUILD SUCCEEDED **


info Installing DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app


所以看起来构建没问题,但是当它尝试安装应用程序时失败了?
认为我已经尝试了从其他问题中找到的“所有内容”,并带有类似的错误消息,但没有任何效果。
一些规范:
react 原生:0.59.10
react :16.8.3
xcode 版本:版本 12.2 (12B45b)
我知道在 stackoverflow 上也有类似的问题。但是由于那里提供的解决方案都没有对我有用,而且我希望解决它,所以我提出了这个单独的问题。
我不知道它试图找到的 Info.plist 文件在哪里:DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plist
在我的 ios 文件夹中,有一个名为 DerivedData 的文件夹,但里面没有名为 Build 的文件夹。所以我认为它可能是从错误的位置看的?
更新:
我已经能够查明 cli 启动出错的地方:
https://github.com/react-native-community/cli/blob/ba298d9c47af522f0377325bebc6c2075d41790a/packages/platform-ios/src/commands/runIOS/index.ts#L378
如果我更改该行 let buildPath = build/${scheme}/Build/Products/${configuration}-${device}/${appName}.app到 -> build/${scheme}/Build/Products/${configuration}-${device}/MyAppRealName.app ;
然后开发启动运行良好,没有问题。所以看起来获取 appName 出错了。 appName 在此处解析: https://github.com/react-native-community/cli/blob/ba298d9c47af522f0377325bebc6c2075d41790a/packages/platform-ios/src/commands/runIOS/index.ts#L387 const productNameMatch = /export FULL_PRODUCT_NAME="?(.+).app"?$/m.exec(buildOutput);我可以做一个安装后 npm 脚本,它只是将应用程序的名称设置为正确的,然后就可以了。但这是非常hacky的方式。我想知道是否有更好的替代方案?我看到 runIOS 文件已经从我拥有的版本更新了很多,但是函数 getProductName 仍然保持不变。所以我不确定只更新 cli 是否可行,或者是否可行,因为它可能需要更新的 react-native 版本,这对我来说现在不是一个选择。

最佳答案

@react-native-community/cli 的较新版本不适用于旧版本的 react-native,因为在较新的版本中它们有变化 getProductNamegetPlatformName .有关更多详细信息,您可以阅读此摘要 PR
解决方案
作为本地解决方法,通过 patch-package 修补软件包node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js和编辑 getProductName (第 362-365 行)阅读:

 function getProductName(buildOutput) {
const productNameMatch = /export FULL_PRODUCT_NAME\\?="?(.+).app"?$/m.exec(buildOutput);
return productNameMatch ? productNameMatch[1].replace(/(?:\\(.))/g, '$1') : null;
}

关于xcode - react 原生上不存在 CFBundleIdentifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65580385/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com