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?
The M1 processors used in the latest Macs are based on technology first developed for the company's iPhone and iPad. (In fact, the current iPad Pro uses the same M1 processor.) Because of this, the M1 brings to the Mac the ability to run iPhone and iPad apps.
The key to solving React Native build failure on M1 Macbook is to use Rosetta. What is rosetta? Rosetta is a dynamic binary translator developed by Apple Inc. for macOS, an application compatibility layer between different instruction set architectures.
How to Set up, Build and Run an React Native App on Macbook Pro M1 Chip React Native is a JavaScript framework that allows native rendering of iOS and Android applications. This makes it easier for us to create two applications on different platforms with one source code.
The error output that you will get when you build react native iOS is as below: The following build commands failed: CompileC /Users/ [username]/Library/Developer/Xcode/DerivedData/reactNativeBoilerplate-atkaxzsfrfdlfocjvyvemwywinew/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Object.
However, in addition to the advantages of the MacBook Pro M1, there are shortcomings in terms of application development. Some applications are not yet compatible with this Apple M1 chip. React Native is a JavaScript framework that allows native iOS and Android applications to be rendered.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With