React-Native: Could not build module 'Darwin' after upgrading react & react-native
Asked Answered
S

3

7

After upgrading react-native package from 0.63.4 to 0.64.4 I got following errors in Xcode (on MacBook Pro M1) while building and running the app on simulator and device:

enter image description here

I tried to it with and without using flipper, but nothing helped. Also added CoreFoundation and Foundation Framework manually to the project and ran Xcode with and without Rosetta enabled.

This is my current PodFile:

source 'https://github.com/CocoaPods/Specs.git'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'

  pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"

   # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    #use_flipper!()

    post_install do |installer|
      react_native_post_install(installer)
    end
end
Sherborne answered 23/9, 2022 at 12:42 Comment(3)
Did you manage to get it to build? I also upgraded to version 0.69.5, I get a similar error.Scolex
@Scolex nope, nothing found related to this error. we just involved another team member of us. if we got a result we will post the answer hereSherborne
@Scolex did you got any solution for this problem?Sherborne
L
12

For me it was Flipper. I wasn't using it in my old project, and it was automatically enabled in my new one. Just comment out the line in your Podfile if your project doesn't require it.

# :flipper_configuration => FlipperConfiguration.enabled,
Luettaluevano answered 28/12, 2022 at 9:41 Comment(0)
S
-1
  1. Delete folder ios
  2. npm i react-native-eject
  3. react-native eject
  4. Modify ios/Podfile enter image description here

to

 :hermes_enabled => false,
  1. Build Project
Sinistrality answered 27/2, 2023 at 0:57 Comment(0)
S
-2

My working solution for this is to create a new, clean project with the version you want to upgrade to. Afterwards do following steps:

  1. Open both .xcworkspace files in Xcode
  2. Head over to your Targets Build Settings
  3. Search for "Header Search Paths"
  4. Copy all Header Search Paths from new Project to your project you want to upgrade
  5. Remove DerivedData, Clean Build and Run again
  6. Run pod install. Maybe you need to upgrade some packages

Additionally a nice npm script for rebuilding .xcworkspace (Replace "[PRJECT_NAME]" with your .xcworkspace name):

"renew-pods-m1": "cd ios; rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf [PROJECT_NAME].xcworkspace; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; arch -x86_64 pod install;"

Note: Have a look at your PodFile. Maybe you need to change the use_react_native implementation and add the post_install script

use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

At the end of the PodFile

# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()

post_install do |installer|
  react_native_post_install(installer)
end
Sherborne answered 19/10, 2022 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.