53 javascript xcode ios reactjs react-native
我刚刚使用react-native升级命令从RN 0.68.x升级到0.69.0。它显示了有关FBReactNativeSpec“值”不可用的错误:在ios 12.0反应本机中引入
,当我使用最新版本创建新项目时显示相同的错误版本。
xcode: 12.4
mac版本:10.15.7
Tou*_*der 168
为那些可能很难找到选项的人提供图解答案:
来源:https ://github.com/facebook/react-native/issues/34106#issuecomment-1489549051
小智 33
跟进阿扎兹的回答
您可以为 podfile 中的所有构建配置自动化它
添加
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
end
end
end
Run Code Online (Sandbox Code Playgroud)
Cem*_*Cem 27
来自 React Native 社区的更新(我还没有尝试升级):https ://github.com/facebook/react-native/issues/34106#issuecomment-1495970568
我知道这个问题已经解决了,但如果有人想要一个仅使用世博会的解决方案(我现在是世博会的忠实粉丝)
下面是如何使用 expo 配置插件修改 podfile,就像 Vivek 的答案一样。
我还添加了一个 if 语句来仅更新,React-codegen因为它是更新 xcode 后唯一给我带来问题的语句14.3
// ./expo-plugins/fix-rn-codegen.js
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const { ExpoConfig } = require("@expo/config-types");
const {
mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const { readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");
const withFixedDeploymentTarget = (c) => {
return withDangerousMod(c, [
"ios",
async (config) => {
const file = resolve(config.modRequest.platformProjectRoot, "Podfile");
const contents = readFileSync(file, { encoding: "utf-8" });
writeFileSync(file, fixDeploymentTarget(contents));
return config;
},
]);
};
function fixDeploymentTarget(src) {
return mergeContents({
tag: `rn-fix-deployment-target`,
src,
newSrc: `
installer.pods_project.targets.each do |target|
if target.to_s === 'React-Codegen'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
`,
anchor: /post_install/,
offset: 1,
comment: "#",
}).contents;
}
module.exports = (config) => withPlugins(config, [withFixedDeploymentTarget]);
Run Code Online (Sandbox Code Playgroud)
然后将其链接到app.json中
// ./app.json
{
"expo": {
"plugins": [
["./expo-plugins/fix-rn-codegen.js"]
]
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
下面由Vivek Verma 回答。
只需防止覆盖具有更高目标的 Pod(新的 Expo Pod 的目标为 13)。
ios/Podfile
// ios/Podfile
post_install do |installer|
...
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] < '12.4'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
end
end
end
...
end
Run Code Online (Sandbox Code Playgroud)
Xcode最近几天升级后就开始出现这种情况。
Xcode项目导航器中,选择Pods。Targets,选择React-Codegen窗口并将其设置为Build Settings。Deployment,设置iOS Deployment Target为12.4。关于这个问题, https://github.com/facebook/react-native/issues/34106上有一个大讨论。
这已在最新版本的react-native. 您应该能够通过升级到以下任何版本来解决问题:
我认为这是由您的react-native项目中的一些pod引起的,这些pod不是最新版本,因此其中一些pod的IPHONEOS_DEPLOYMENT_TARGET可能小于12.0
就我而言,我执行了以下步骤
| 归档时间: |
|
| 查看次数: |
40215 次 |
| 最近记录: |