[Fixed] React Native M1 Mac build failure with target "React-Codegen" – Ruby

by
Ali Hasan
apple-m1 cocoapods concurrent-ruby react-native xcode

Quick Fix: Update react-native to v0.71.6 or later. If you are using an older version of react-native, apply the appropriate suggested patch linked in the above answer.

The Problem:

When running npx react-native run-ios on an M1 Mac with React Native 0.71.5, Cocoapods 1.11.3, Node 18.15.0, Xcode 14.3, and macOS 13.3, the build fails with the error CompileC /Users/username/Library/Developer/Xcode/DerivedData/AwesomeProject-ctnixtnnzajiwuhfvbyaxljew/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-Codegen.build/Objects-normal/arm64/FBReactNativeSpec-generated.o /Users/username/Documents/testing/AwesomeProject/ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-Codegen' from project 'Pods') (1 failure).

The Solutions:

Solution 2: Update iOS Deployment Target

To resolve the build failure, navigate to the Pods folder in Xcode and select React-Codegen under Build Settings. Update the iOS Deployment Target to iOS 12.4 or a supported version. This should address the compatibility issue and allow the build to complete successfully.

Solution 3:

Changing the minimum ios version of ReactCodegen inside Xcode targets to 12.0 or greater can solve this issue.

Q&A

Why is the build of React Native failing after upgrading to Xcode 14.3 on an M1 Mac?

Known issue with incompatibility between Xcode 14.3 and React Native prior to v0.71.6

How to quickly patch React Native v0.71.5 to resolve this issue?

Update iOS Deployment Target to iOS 12.4 for React-Codegen under Build Settings in Xcode

How to resolve this using a stable release of React Native?

Upgrade to React Native v0.71.6 or later

Video Explanation:

The following video, titled "React native fix pod install for iOS simulator on MacBook M1 in 3 ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

In this video I am sharing with you the solution of using react native on a MacBook M1 - this solution updated May 2021 Note* Make sure that ...