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
- npx react-native init bestproject
- cd bestproject
- pod install
- Run project in xcode
- 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
- Working ios build by updating Cocoapod deps Add OpenSSL specific version to podfile and run `pod install`. Notes: https://github.com/facebook/react-native/issues/30922#issuecomment-776758668 — committed to tgroshon/example-react-native-BLE by tgroshon 3 years ago
- Add constraint on supported cocoapods version Summary: Specify minimum required cocoapods version for Flipper, fixes https://github.com/facebook/react-native/issues/30922, according to https://guides... — committed to facebook/flipper by mweststrate 3 years ago
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
Adding that to the Podfile causes
pod update
to fail with an incompatibility error:System info:
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'
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
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 apod update
and was successful. DIdn’t need to blow awayPodfile.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 unpinOpenSSL-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.
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 to1.9.3
by doing this:~One more note: you should also remove
Podfile.lock
beforepod install
~ Just executepod update
You’ve saved my day
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