1

I created a sample ReactNative project using npx react-native “projectName” on M1 chip based Mac. Project created without any issue and android project build and ran successfully without any error on both google preview emulator and real device. However iOS build gets fail. I have installed cocoa pods using Rosetta and and installed other required packages and softwares such as home-brew, watchman, Xcode, iOS emulator..etc

But if I create an expo project it works fine without any issue on both iOS and android, However I want to know, ReactNative CLI based projects works fine on M1 chipset, If it does work then, then something might be wrong with the my development setup.

Please be kind enough to help me with this issue

This is the log file data

Blockquote 0 verbose cli [ 0 verbose cli '/usr/local/bin/node', 0 verbose cli '/usr/local/lib/node_modules/npm/bin/npm-cli.js', 0 verbose cli 'exec', 0 verbose cli '--', 0 verbose cli 'react-native', 0 verbose cli 'run-ios' 0 verbose cli ] 1 info using [email protected] 2 info using [email protected] 3 timing config:load:defaults Completed in 1ms 4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 2ms 5 timing config:load:builtin Completed in 2ms 6 timing config:load:cli Completed in 1ms 7 timing config:load:env Completed in 0ms 8 timing config:load:file:/Users/vihagayohan/Desktop/ReactNative/Ikman/.npmrc Completed in 1ms 9 timing config:load:project Completed in 1ms 10 timing config:load:file:/Users/vihagayohan/.npmrc Completed in 0ms 11 timing config:load:user Completed in 0ms 12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms 13 timing config:load:global Completed in 0ms 14 timing config:load:cafile Completed in 0ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:setUserAgent Completed in 0ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 6ms 19 verbose npm-session b605b9422c99c9ad 20 timing npm:load Completed in 15ms 21 timing command:exec Completed in 71201ms 22 verbose stack Error: command failed 22 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27) 22 verbose stack at ChildProcess.emit (node:events:379:20) 22 verbose stack at maybeClose (node:internal/child_process:1065:16) 22 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:296:5) 23 verbose pkgid [email protected] 24 verbose cwd /Users/vihagayohan/Desktop/ReactNative/Ikman 25 verbose Darwin 20.1.0 26 verbose argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "react-native" "run-ios" 27 verbose node v15.6.0 28 verbose npm v7.4.0 29 error code 1 30 error path /Users/vihagayohan/Desktop/ReactNative/Ikman 31 error command failed 32 error command sh -c react-native "run-ios" 33 verbose exit 1 0 verbose cli [ 0 verbose cli '/usr/local/bin/node', 0 verbose cli '/usr/local/lib/node_modules/npm/bin/npm-cli.js', 0 verbose cli 'exec', 0 verbose cli '--', 0 verbose cli 'react-native', 0 verbose cli 'run-ios' 0 verbose cli ] 1 info using [email protected] 2 info using [email protected] 3 timing config:load:defaults Completed in 1ms 4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 2ms 5 timing config:load:builtin Completed in 2ms 6 timing config:load:cli Completed in 1ms 7 timing config:load:env Completed in 0ms 8 timing config:load:file:/Users/vihagayohan/Desktop/ReactNative/Ikman/.npmrc Completed in 1ms 9 timing config:load:project Completed in 1ms 10 timing config:load:file:/Users/vihagayohan/.npmrc Completed in 0ms 11 timing config:load:user Completed in 0ms 12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms 13 timing config:load:global Completed in 0ms 14 timing config:load:cafile Completed in 0ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:setUserAgent Completed in 0ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 6ms 19 verbose npm-session b605b9422c99c9ad 20 timing npm:load Completed in 15ms 21 timing command:exec Completed in 71201ms 22 verbose stack Error: command failed 22 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27) 22 verbose stack at ChildProcess.emit (node:events:379:20) 22 verbose stack at maybeClose (node:internal/child_process:1065:16) 22 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:296:5) 23 verbose pkgid [email protected] 24 verbose cwd /Users/vihagayohan/Desktop/ReactNative/Ikman 25 verbose Darwin 20.1.0 26 verbose argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "react-native" "run-ios" 27 verbose node v15.6.0 28 verbose npm v7.4.0 29 error code 1 30 error path /Users/vihagayohan/Desktop/ReactNative/Ikman 31 error command failed 32 error command sh -c react-native "run-ios" 33 verbose exit 1

Thank You, Yohanenter image description here

4 Answers 4

1

I asked this question few days back and struggling to get a solution. So right now i have found a solution but don't know whether it's a perfect solution but so far it works fine. So basically what I did was i commented (as shown in the picture) flipper dependencies from pod file and pod install againenter image description here

0

Try to exclude arm64 build architecture for both Pods and Project Target.

0

I run react native iOS on my macbook Pro with Chip M1, i got build error. But, after follow this post, i successfully running react native iOS on macbook Pro M1. The tricks is to use Rosetta and applied it to your terminal and also XCode. full guide follow here: solve react native build failed on macbook Pro with chip M1

0

I just add these in Build settings > Search paths > Library search paths.

$(SDKROOT)/usr/lib/swift

Change/Add/Replace this line in your Podfile.

use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })

Define this function in your Podfile Define find-and-replace function

 def find_and_replace(dir, findstr, replacestr)
   Dir[dir].each do |name|
       text = File.read(name)
       replace = text.gsub(findstr,replacestr)
       replaced = text.index(replacestr)
       if replaced == nil && text != replace
           puts "Fix: " + name
           File.open(name, "w") { |file| file.puts replace }
           STDOUT.flush
       end
   end
   Dir[dir + '*/'].each(&method(:find_and_replace))
 end

Then call this function from the post-install so we will need to add the following 2 function calls inside post_install do |installer|

find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
                  "atomic_notify_one(state)", "folly::atomic_notify_one(state)") 
find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
 "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")

Run pod repo update inside the ios folder

And update your project pods using

pod install

DONE !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.