更新xcode到9.4后,无法响应本机ios构建失败。错误是“ NSInteger”类型的值

时间:2018-06-22 00:26:34

标签: ios xcode react-native

enter image description here

错误代码消息为

'NSInteger'类型的值不应用作格式参数;添加一个明确的强制转换为'long' 用'JS之前的%ld事件-尝试使JS更快。“,self.text,(long)'<'替换JS之前的'%zd事件-尝试使您的JS更快。 / p>

我的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版本。从那时起,我一直在构建失败。

谢谢。

2 个答案:

答案 0 :(得分:1)

这很简单。

只需单击xcode修复按钮

答案 1 :(得分:1)

仅当您使用的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

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

显然,这与%zd有关,需要%ld并用大写字母long来填充。

这是修复按钮:

  1. 单击红点:

  2. 修复按钮出现:

  3. 使用修复程序重新格式化: