react-native: Can't compile initial project for iOS

Description

When I create a new project via npx react-native init bestproject and trying to compile it on macOS I receive the following errors:

/Users/user/projects/bestproject/ios/Pods/OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:186:39:
 Unknown type name 'BN_ULONG'
Flipper-Folly
/Users/user/projects/bestproject/ios/Pods/OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bio.h:687:1:
 Expected function body after function declarator

React Native version:

System:
    OS: macOS 10.15.7
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 433.12 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.10.1 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.10 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

  1. npx react-native init bestproject
  2. cd bestproject
  3. pod install
  4. Run project in xcode
  5. Receive the errors

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 26 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Building existing iOS projects also start failing with the same error(s) if OpenSSL-Universal gets updated to 1.1.180 via pod update. Rolling back to OpenSSL-Universal 1.0.2.20 (Flipper-Folly 2.3.0 and Flipper-RSocket 1.1.0) seems to get the iOS build working again.

In case anyone else is wondering how to do this, you need to add pod 'OpenSSL-Universal', '~>1.0.2.20' to your Podfile

@lauritaipale’s solution worked for me, adding this to my pod file fixed the problem:

pod ‘OpenSSL-Universal’, ‘~>1.0.2.20’

NOTE: after adding this, just running pod install will fire an error due to versions mismatch, in that case remove Podfile.lock and pod install again

@lauritaipale’s solution worked for me, adding this to my pod file fixed the problem:

pod ‘OpenSSL-Universal’, ‘~>1.0.2.20’

NOTE: after adding this, just running pod install will fire an error due to versions mismatch, in that case remove Podfile.lock and pod install again

Adding that to the Podfile causes pod update to fail with an incompatibility error:

Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
[!] CocoaPods could not find compatible versions for pod "OpenSSL-Universal":
  In Podfile:
    FlipperKit/FBCxxFollyDynamicConvert (~> 0.75.1) was resolved to 0.75.1, which depends on
      Flipper-Folly (~> 2.5) was resolved to 2.5.1, which depends on
        OpenSSL-Universal (= 1.1.180)

    OpenSSL-Universal (~> 1.0.2.20)

System info:

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Xeon(R) CPU           X5570  @ 2.93GHz
    Memory: 3.16 GB / 28.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.21.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.11 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Updating cocoapods to 1.10.1 fixed the issue.

There seems to be an issue with xcframeworks on version 1.9.x (https://github.com/krzyzanowskim/OpenSSL/issues/113#issuecomment-773390391)

Building existing iOS projects also start failing with the same error(s) if OpenSSL-Universal gets updated to 1.1.180 via pod update. Rolling back to OpenSSL-Universal 1.0.2.20 (Flipper-Folly 2.3.0 and Flipper-RSocket 1.1.0) seems to get the iOS build working again.

This saved me pod 'OpenSSL-Universal', '~>1.1.1100'

   use_flipper!({'Flipper-Folly' => '~> 2.6.9','Flipper' => '0.95.0'})
    post_install do |installer|
      flipper_post_install(installer)
    end

I am also using googleplaces and google maps so I had to add this installer.pods_project.targets.each do |target| if target.name == 'react-native-google-places' target.build_configurations.each do |config| config.build_settings['CLANG_ENABLE_MODULES'] = 'No' end end if target.name == "React" target.remove_from_project end end

and pod 'react-native-google-places', :path => '../node_modules/react-native-google-places'

Adding to help someone with similar issue. After switching to Big Sur and Xcode 12.5

Later I had this issue while generating a device build ___cxa_increment_exception_refcount" so I had to make these changes pod 'OpenSSL-Universal', '~>1.1.180'
use_flipper!({'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7'})

Its still a pain to create a new project after 2 years. Whishes to learn react native but wasted 2 hours just to setup new project still no success

Building existing iOS projects also start failing with the same error(s) if OpenSSL-Universal gets updated to 1.1.180 via pod update. Rolling back to OpenSSL-Universal 1.0.2.20 (Flipper-Folly 2.3.0 and Flipper-RSocket 1.1.0) seems to get the iOS build working again.

In case anyone else is wondering how to do this, you need to add pod 'OpenSSL-Universal', '~>1.0.2.20' to your Podfile

It worked for me. Thank you.

Ah my favorite. Random build breaks while updating core libraries. I applied @EricWiener 's code to Podfile and then issued a pod update and was successful. DIdn’t need to blow away Podfile.lock as @Yadro was suggesting. Mostly commenting to get my name on here and get an update when this issue is fixed so I can unpin OpenSSL-Universal.

For me the fix is just to change the Deployment Info target to iOS 11 or greater

I had this issue recently and the problem was with the outdated cocoapods (1.9) version. Updating to a newer version solved the issue.

sudo gem install cocoapods

Updating cocoapods to 1.10.1 fixed the issue.

The OP is a known issue, caused by an outdated cocoapods. Make sure to update it to 1.10.

I run into other issues when I update cocoapods to 1.10.1, the build simply does not show up in the Organizer after archiving (may also be related to a Mapbox SDK issue, not sure) so I have to downgrade cocoapods to 1.9.3 by doing this:

$ sudo gem uninstall cocoapods
$ sudo gem install cocoapods -v 1.9.3

In case anyone else is wondering how to do this, you need to add pod ‘OpenSSL-Universal’, ‘~>1.0.2.20’ to your Podfile

~One more note: you should also remove Podfile.lock before pod install~ Just execute pod update

In case anyone else is wondering how to do this, you need to add pod 'OpenSSL-Universal', '~>1.0.2.20' to your Podfile

You’ve saved my day

Building existing iOS projects also start failing with the same error(s) if OpenSSL-Universal gets updated to 1.1.180 via pod update. Rolling back to OpenSSL-Universal 1.0.2.20 (Flipper-Folly 2.3.0 and Flipper-RSocket 1.1.0) seems to get the iOS build working again.

In case anyone else is wondering how to do this, you need to add pod 'OpenSSL-Universal', '~>1.0.2.20' to your Podfile

This WORKED for me to… its worked for init project with RN 0.62.2 & 0.63.2 Too…

Thank you… React Native give me trouble every single release 😂 They said, ‘stable’ release haha