将 xcode 更新到 9.4 后,react native ios build 失败。错误是“NSInteger”类型的值

Posted

技术标签:

【中文标题】将 xcode 更新到 9.4 后,react native ios build 失败。错误是“NSInteger”类型的值【英文标题】:react native ios build is failed after update xcode to 9.4. error is Values of type 'NSInteger' 【发布时间】:2018-06-22 00:26:33 【问题描述】:

错误代码信息是

“NSInteger”类型的值不应用作格式参数;改为向“long”添加显式强制转换 将 '%zd events before JS - try to make your JS faster.", self.text, ' 替换为 '%ld events before JS - try to make your JS faster.", self.text, (long)'

我的 package.json 文件如下。


"name": "*****",
"version": "****",
"private": true,
"scripts": 
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
,
"dependencies": 
    "firebase": "^5.0.4",
    "moment": "^2.20.1",
    "prop-types": "^15.6.0",
    "react": "^16.0.0-alpha.12",
    "react-addons-update": "^15.6.2",
    "react-moment": "^0.6.9",
    "react-native": "^0.48.4",
    "react-native-camera": "^1.1.4",
    "react-native-check-box": "^2.0.2",
    "react-native-communications": "^2.2.1",
    "react-native-device-info": "^0.13.0",
    "react-native-elements": "^0.18.5",
    "react-native-facebook-login": "^1.6.0",
    "react-native-fcm": "^10.0.3",
    "react-native-gifted-chat": "^0.4.3",
    "react-native-image-crop-picker": "^0.18.2",
    "react-native-image-picker": "^0.26.7",
    "react-native-image-zoom-viewer": "^2.0.20",
    "react-native-keyboard-aware-scroll-view": "^0.4.3",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-maps": "^0.17.1",
    "react-native-modal": "^4.1.1",
    "react-native-modal-selector": "0.0.24",
    "react-native-permissions": "^1.0.6",
    "react-native-progress": "^3.4.0",
    "react-native-simple-radio-button": "^2.7.2",
    "react-native-snap-carousel": "^3.5.0",
    "react-native-splash-screen": "^3.0.6",
    "react-native-swiper": "^1.5.13",
    "react-native-vector-icons": "^4.5.0",
    "react-navigation": "^1.0.0-beta.27",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-persist": "^5.5.0",
    "redux-thunk": "^2.2.0"
,
"devDependencies": 
    "babel-jest": "21.2.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "21.2.1",
    "react-test-renderer": "16.0.0"
,
"jest": 
    "preset": "react-native"
,
"build:ios": "react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/luxlabUser/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"

我能够在 xcode 9.2 版中正常构建。但是,由于 9.2 版本不支持 iOS 11.4 的构建,我升级了 xcode 版本。从那以后,我的构建失败了。

谢谢。

【问题讨论】:

【参考方案1】:

这是一件简单的事情..

只需点击 xcode 修复按钮

【讨论】:

我很高兴你发布了这个。我恢复到 xCode 9.2,因为我找不到这个简单的解决方案。 能否分享一张我在哪里可以找到此修复按钮的屏幕截图? @JordanDaniels 我找到了修复按钮,请参阅下面的解决方案。【参考方案2】:

只有在您使用低于 RN 0.56 但已将 XCode 更新到 9+ 时,这才应该是一个问题。这个问题在 RN 0.56 中得到解决,因为他们在发行版中将 XCode 9 称为最低版本 - https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#xcode-9-is-now-the-minimum-required-version

我找到了修复按钮(回复:react native ios build is failed after update xcode to 9.4. error is Values of type 'NSInteger'),但我每次都必须运行构建,当我遇到这些错误时,我必须找到并按下修复按钮。我认为只有 2 个地方需要发生这种情况,但如果可以找到所有这些地方而不是构建然后修复一个错误然后重复构建直到不再有,那就更好了。

这显然与%zd 需要%ldlong 的大小写有关。

这里是修复按钮:

    点击红点:

    出现修复按钮:

    它使用以下修复重新格式化:

【讨论】:

以上是关于将 xcode 更新到 9.4 后,react native ios build 失败。错误是“NSInteger”类型的值的主要内容,如果未能解决你的问题,请参考以下文章

更新到 Xcode 11.0 后反应本机崩溃

Xcode 9.4致命错误:lipo:无法打开输入文件(没有这样的文件或目录)

构建错误:升级到 Xcode 10 后找不到 FBSDKShareKit.h 文件

Swift Xcode 9.4 框架

更新 xcode 13 后 react-native run-ios 命令未成功运行

将 XCode 更新为 XCode 12.2 / React Native 0.63.2 构建失败