react-native: Can't make an iOS build [0.65.0]

Description

This is what i have in my Podfile

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

platform :ios, '13.2'

target 'Test' 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
  )

  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
  end


  pod 'React-Core', :path => '../node_modules/react-native'

end

React Native version:

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.99 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: Not Found
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
    Watchman: 2021.08.02.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: ^0.65.0 => 0.65.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

pod update/pod install/pod install --repo-update

##Problem that i am facing Screen Shot 2021-08-19 at 11 59 30 AM

Expected Results

App should build without any issues.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 33 (11 by maintainers)

Most upvoted comments

Parts of flipper are still included now no matter what in react-native 0.65 especially if you want hermes on ios.

Here’s my full set of hacks.

  post_install do |installer|
    react_native_post_install(installer)

    # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
        end
      end
      aggregate_target.user_project.save
    end

     # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
    # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end

    # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
    # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
    # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
  end

I tried 0.66 today, now everything works even with default Podfile, you do not need those changes mentioned in this issue and you can enable Flipper too. a big thanks to all developers💗

This is my change as mentionned on previous comment :

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

platform :ios, '11.0'

target 'default' 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
  )

  target 'defaultTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })

  post_install do |installer|
    react_native_post_install(installer)

    installer.pods_project.targets.each do |target|  
      case target.name
      when 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        end
      end
    end
  end
end

With debug mode it’s working, but when trying to build for release I have this error, if someone have an idea how to resolve that, I’m on a clean react-native project with xcode 12.5

Capture d’écran 2021-08-19 à 23 28 06

Same error with fresh 0.65 version and xcode 12.5, RCT-FOLLY problem as mentionned before, impossible to build for release

thanks, but no luck for me too, everything works well in debug mode, but not release mode, I changed the Podfile but got another error as @john-dufrene-dev mentioned above Thread-local storage is not supported for the current target

I have checked the IPHONEOS_DEPLOYMENT_TARGET of “RCT_Folly” in xcode, it’s 9.0.

also I have a warning when I run “pod install” [!] FBReactNativeSpec has added 1 script phase. Please inspect before executing a build. See https://guides.cocoapods.org/syntax/podspec.html#script_phases for more information. I just ignore it, don’t know if it’s the reason I got the error Thread-local storage is not supported for the current target

The warnings are still there, they are not bogus, but neither are they important. The warnings are saying “hey, your iOS minimum for your apps is higher than your libraries” Does that matter? Not at all. Is it noisy? Yes. Ask me how I know: I had this post_install, to quiet the noise, it was nice. But then the build started breaking like this, so I removed the post_install change, the build works, my logs are noisy again.

Build working >> noise 🤷

closing since we have addressed this in the latest release

If you just do npx react-native init TestProject && cd TestProject && yarn ios it works, right?

Don’t worry about the cocoapods warning about adding FBReactNativeSpec, that’s normal. That’s cocoapods warning you that a script was added, in case you have security concerns with the script.

In this case, it’s a necessary part of react-native iOS compiling, so it’s good to be aware (thanks Cocoapods!) but it’s not a problem.

My take on it now is: if it’s possible that some libraries have version dependent behavior, and I was just trying to quiet noise but they actually depend on their build settings not changing, do I really know more than all the library authors? I do not. I should probably leave their build settings alone.

@smartameer have slightly updated Podfile due to your comment and deployment_target I receive but now i have this problem while building

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

require_relative ‘…/node_modules/react-native/scripts/react_native_pods’ require_relative ‘…/node_modules/@react-native-community/cli-platform-ios/native_modules’

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

IOS_VERSION = '11.0'

platform :ios, '11.0'

target 'test' 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
  )

   # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })


  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end

  end

end