react-native ios build xcode 12/13 (react-native run-ios) failed with PhaseScriptExecution and CompileSwiftSources error

Viewed 804

i am trying to build react-native on ios, but it is throwing error

versions:

react-native info
info Fetching system and libraries information...
System:
    OS: macOS 11.4
    CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
    Memory: 12.08 GB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
    Watchman: 2021.11.01.00 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7678000
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  npmPackages:
    react: 17.0.1 => 17.0.1 
    react-native: ^0.64.2 => 0.64.2 
  npmGlobalPackages:
    create-react-native-app: 3.5.3
    react-native-asset: 2.0.1
    react-native: 0.60.6

In Xcode build it fails here in below location:

enter image description here

Details:

if you run

react-native run-ios

it says two commands have failed just like above, they are :

The following build commands failed:
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'FBSDKCoreKit' from project 'Pods')

    PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/user204444/Library/Developer/Xcode/DerivedData/xUI-awhgnkdgdnqqhybhizmenofqnvvg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-50E87D65053FE4ADFF2772B365B2C6E0.sh 

  (in target 'FBReactNativeSpec' from project 'Pods')
(2 failures)

Any help would be greatly appreciated

2 Answers

1. To fix the first error try:

`rm -rf ./node_modules`
`yarn install` // or npm install
`cd ios && rm -rf ./Pods && rm -rf Pofile.lock && pod install && cd ..`
`npx react-native run-ios`

2. To fix the second error:

  • try to remove/comment flipper in Podfile
  • Make sure you have excluded the arm64 architecture for simulators

Note: I had a PhaseScriptExecution error showing up after upgrading Xcode to 13.1:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.67.dylib.

I fixed it with: brew update and brew install.

enter image description here

If still not working please attach to your question:

  1. full content of Podfile
  2. result of pod install command
  3. full log for react-native run-ios command

Your errors are too generic to debug without the full the full error log.

I always run into this problem. Follow these steps to remove the error.

  • From the root of the project, do cd ios
  • pod deintegrate
  • pod install

If this doesn't help then remove node_modules and then try above after npm install or yarn install, as follows.

On the root of the project, do the following

  • rm -rf node_modules
  • npm install / yarn install
  • cd ios
  • pod deintegrate
  • pod install
  • cd ..
  • react-native run-ios
Related