'Build error of react native run iOS on M1 Macbook

I initialized new react-native project with "react-native init ReactNStudy" for first time on my M1 Silicon Apple computer.

Metro builder worked without any problems.

When building step I get very log error. Starting part of the error like that:

info Found Xcode workspace "ReactNCalisma.xcworkspace" info Launching iPhone 12 (iOS 14.4) info Building (using "xcodebuild -workspace ReactNCalisma.xcworkspace -configuration Debug -scheme ReactNCalisma
-destination id=E914C899-172A-45AE-AFB6-BEBA505887E1") (node:25639) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency (Use `node --trace-warnings ...` to show where the warning was created) error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening ReactNCalisma.xcworkspace. Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace ReactNCalisma.xcworkspace -configuration Debug -scheme ReactNCalisma -destination id=E914C899-172A-45AE-AFB6-BEBA505887E1

And ending part of the error like that:

objc[25723]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1fc2be7a0) and ?? (0x1189b42b8). One of the two will be used. Which one is undefined.
objc[25723]: Class AMSupportURLSession is implemented in both ?? (0x1fc2be7f0) and ?? (0x1189b4308). One of the two will be used. Which one is undefined.
** BUILD FAILED **


The following build commands failed:
    Ld /Users/USERNAME/Library/Developer/Xcode/DerivedData/ReactNCalisma-anxlznepgpgzoyfpokskqpwmffzt/Build/Products/Debug-iphonesimulator/ReactNCalisma.app/ReactNCalisma normal
(1 failure)

info Run CLI with --verbose flag for more details.

After that I tried to run with "xcodebuild":

cd ios && xcodebuild

But in this part I get error as:

fatal error: module map file
      '/Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/Release-iphoneos/YogaKit/YogaKit.modulemap'
      not found

** BUILD FAILED **
The following build commands failed:
    CompileC /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/Objects-normal/arm64/ReactNCalisma_vers.o /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/DerivedSources/ReactNCalisma_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/Objects-normal/armv7/ReactNCalisma_vers.o /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/DerivedSources/ReactNCalisma_vers.c normal armv7 c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

I tried to solve with Pod delete and reinstall, I checked my Xcode terminal settings but I cannot solve this problem .

Is this problem about M1? How can I solve this?



Solution 1:[1]

I followed those steps on macbook M1 (problem with cocoapoda and build):

1- Using Terminal with Rosetta (Make sure all terminals are closed): Go Finder --> Applications --> Utilities --> Terminal (Then right click on Get Info - check Open using Rosetta) Now you can open Terminal & install Cocoapoda from terminal

2- Use Xcode with Rosetta (Make sure that Xcode is closed): Go Finder --> Application --> Xcode (Then right click on Get Info - check Open using Rosetta) Now Xcode/simulator will work as Rosetta

3- Comment this part in Podfile (in ios folder)

# use_flipper!
# post_install do |installer|
#   flipper_post_install(installer)
# end

Then reinstall pod:

cd ios/
$ rm -rf build/
$ pod install

Check this video:

https://youtu.be/UrxM1SyAXAE

Solution 2:[2]

I also experienced same issue before. But, Now i can compile and build react native run-ios sucessfully. I already resume and create guide article on how to run react native iOS Macbook with M1 Chip.

enter image description here

Quick step:

- set terminal to use Rosetta
- set XCode to use Rosetta
- small adjust on podFile if you have problem with react native flipper.

full guide follow from this : https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

Solution 3:[3]

I had same problem. I fixed as below

  • I added into the Podfile
  post_install do |installer|
      react_native_post_install(installer)
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
  end
  • pod install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Handi
Solution 3 S. Ka?an Cin