react-native-quick-crypto
react-native-quick-crypto copied to clipboard
Errors when building for release on iOS
Hi, I'm getting this error when building for release on iOS:
Undefined symbols for architecture arm64: "_BIO_ctrl", referenced from: margelo::ParsePublicKeyPEM(std::__1::unique_ptr<evp_pkey_st, margelo::FunctionDeleter<evp_pkey_st, &(EVP_PKEY_free)> >*, char const*, int) in libreact-native-quick-crypto.a(MGLKeys.o) margelo::BIOToStringOrBuffer(bio_st*, margelo::PKFormatType) in libreact-native-quick-crypto.a(MGLKeys.o) "_BIO_free_all", referenced from: std::__1::unique_ptr<bio_st, margelo::FunctionDeleter<bio_st, &(BIO_free_all)> >::~unique_ptr() in libreact-native-quick-crypto.a(MGLKeys.o) "_BIO_new", referenced from: margelo::WritePrivateKey(facebook::jsi::Runtime&, evp_pkey_st*, margelo::PrivateKeyEncodingConfig const&) in libreact-native-quick-crypto.a(MGLKeys.o) margelo::WritePublicKey(facebook::jsi::Runtime&, evp_pkey_st*, margelo::AsymmetricKeyEncodingConfig const&) in libreact-native-quick-crypto.a(MGLKeys.o) "_BIO_new_mem_buf", referenced from: margelo::ParsePublicKeyPEM(std::__1::unique_ptr<evp_pkey_st, margelo::FunctionDeleter<evp_pkey_st, &(EVP_PKEY_free)> >*, char const*, int) in libreact-native-quick-crypto.a(MGLKeys.o) margelo::ParsePrivateKey(std::__1::unique_ptr<evp_pkey_st, margelo::FunctionDeleter<evp_pkey_st, &(EVP_PKEY_free)> >*, margelo::PrivateKeyEncodingConfig const&, char const*, unsigned long) in libreact-native-quick-crypto.a(MGLKeys.o) "_BIO_s_mem", referenced from: margelo::WritePrivateKey(facebook::jsi::Runtime&, evp_pkey_st*, margelo::PrivateKeyEncodingConfig const&) in libreact-native-quick-crypto.a(MGLKeys.o) margelo::WritePublicKey(facebook::jsi::Runtime&, evp_pkey_st*, margelo::AsymmetricKeyEncodingConfig const&) in libreact-native-quick-crypto.a(MGLKeys.o) "_BN_bin2bn", referenced from: margelo::ConvertSignatureToDER(margelo::ManagedEVPPKey const&, margelo::ByteSource&&) in libreact-native-quick-crypto.a(MGLSignHostObjects.o)
Debug build works fine, this happens only on release. What might caused this issue and how to solve it?
react-native info output:
System: OS: macOS 12.6 CPU: (8) x64 Apple M1 Memory: 71.05 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/adrian-synthetify/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild Languages: Java: 11.0.16.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.3 => 0.70.3 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found
Have the same issue.
react-native info:
System: OS: macOS 12.6 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 60.88 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.0 - /var/folders/gj/0rjxbjfn7ss6947lshwf5l240000gn/T/yarn--1668414971586-0.6411709107032832/node Yarn: 1.22.19 - /var/folders/gj/0rjxbjfn7ss6947lshwf5l240000gn/T/yarn--1668414971586-0.6411709107032832/yarn npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm Watchman: 2021.12.27.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 29, 30, 31 Build Tools: 29.0.2, 29.0.3, 30.0.2, 31.0.0, 33.0.0 System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-32 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.16.1 - /Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home/bin/javac npmPackages: @react-native-community/cli: ^8.0.3 => 8.0.6 react: 18.0.0 => 18.0.0 react-native: ^0.69.7 => 0.69.7 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found
I've checked if this happens after updating lib to 0.5.0; unfortunately, yes. Please, can somebody answer my question?
you add manual OpenSSL.framework
in General Project, archive Done, but when you debug, you must remove OpenSSL.xcframework
you add manual
OpenSSL.framework
in General Project, archive Done, but when you debug, you must remove OpenSSL.xcframework
Ok, that works for me too, thanks! that's fine as temporary workaround, but I hope better solution will be implemented in this lib soon.
Ok, I've created more convenient solution. Instead of manually adding and removing OpenSSL.xcframework, add "New Run Script Phase" in Build Phases in Xcode and put there this script:
FRAMEWORK="${PODS_ROOT}/OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_armv7/OpenSSL.framework"
DESTINATION="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework"
if [ ${CONFIGURATION} == "Release" ] && [ ! -d $DESTINATION ]; then
cp -r $FRAMEWORK $DESTINATION
codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements $DESTINATION
fi
Any updates ?
Manually adding "OpenSSL.framework" in General -> "Frameworks, Libraries and Embedded Content" solves the issue for me too. But I need to manually remove it when debugging, blah.
@awojciak , I tried with your more convenient solution, but for some reason it didn't click for me. Build fails with the same error. Should I set anything additional when creating a "New Run Script Phase" except copying over the script?
I'm with xCode 14.2, React Native 0.68.2, if that makes any difference.
Manually adding "OpenSSL.framework" in General -> "Frameworks, Libraries and Embedded Content" solves the issue for me too. But I need to manually remove it when debugging, blah.
@awojciak , I tried with your more convenient solution, but for some reason it didn't click for me. Build fails with the same error. Should I set anything additional when creating a "New Run Script Phase" except copying over the script?
I'm with xCode 14.2, React Native 0.68.2, if that makes any difference.
Suddenly it stopped working for me, so I've sticked to manually adding framework.
@awojciak thank you for sharing!
I noticed that the conflicting OpenSSL.framework
version comes from Flipper. With the below line commented out, build succeeds. We ended up wrapping it in env variable (so that the CI release builds don't use Flipper).
if !ENV['CI']
use_flipper!("Flipper" => "0.159.0")
end
However, the solution is not optimal, because the release builds on my local machine fail. I couldn't find env variable where in the Podfile I can check additionally if that's a debug or release build. Do you know if there is one?
In case you don't want to modify the code, a workaround now you can create a shell script and execute it as a step on the CI environment for example, it removes the use_flipper
line from the Podfile.
cd ios
sed -i '' 's/use_flipper.*$//g' Podfile
cd ..
EDIT: So this did successfully build the release ipa but when uploading to testflight i get an Asset Validation Failure error same as here... Then after adding the OpenSSL framework again as described above (which then breaks the debug build) the release build succeeds AND uploads to testflight without the error... so still not really a fix... 🥲
My fix was to just add the path to OpenSSL to the Framework Search Paths > Release
For whatever reason in Project settings > select Target > Build Settings tab > Search Paths section > Framework Search Paths > Debug showed this:
but the Release ones were missing a bunch of those so I added these 2:
"${PODS_ROOT}/OpenSSL-Universal/Frameworks"
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal"
Then both debug and release builds worked for me. 👍🏼
not sure what the proper fix should be... maybe something in the autolinking of this library needs tweaking? why would Debug paths be set but not Release paths? maybe it was intentional because why in the hell would you release an app with the cryptography rolled in Javascript?
i do not have the answers to these questions...
but the Release ones were missing a bunch of those so I added these 2:
"${PODS_ROOT}/OpenSSL-Universal/Frameworks" "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal"
This fix worked for me too 👍 But looks like this problem should be fixed inside the lib.
Added this line to Podfile (after use_react_native
)
pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
This is the only solution that allows me to run both Debug&Release without extra manipulation each time.
Added this line to Podfile (after
use_react_native
)pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
This is the only solution that allows me to run both Debug&Release without extra manipulation each time.
This worked for me thanks! both debug and release builds succeed and no need to manually add OpenSSL in "Frameworks, Libraries and Embedded Content"
Added this line to Podfile (after
use_react_native
)pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
This is the only solution that allows me to run both Debug&Release without extra manipulation each time.
Worked like a charm
https://github.com/numandev1/react-native-keys#setup just read
Note: If you get Undefined symbols _BIO_f_base64 error during Xcode build then follow the below steps
any updates on this?
@Ahmedhamed77 you can try these solutions https://stackoverflow.com/a/76455587/8079868
i'm using;
"react-native-quick-crypto": "^0.6.1",
debug
works fine but i got this same issue from OP when i archive
.
what worked for me is @chocky335 's solution:
Added this line to Podfile (after
use_react_native
)pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
This is the only solution that allows me to run both Debug&Release without extra manipulation each time.
and if you're ever using Flipper at the same time and got new issue during archive
, follow this
Still happening in 0.7.x
versions? I'm going to close in favor of the solution on Stack Overflow and #314. Reopen if you think there's still something to solve here.