react-native-quick-crypto icon indicating copy to clipboard operation
react-native-quick-crypto copied to clipboard

Errors when building for release on iOS

Open awojciak opened this issue 2 years ago • 19 comments

Hi, I'm getting this error when building for release on iOS: obraz 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

awojciak avatar Nov 03 '22 12:11 awojciak

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

KachanS avatar Nov 14 '22 08:11 KachanS

I've checked if this happens after updating lib to 0.5.0; unfortunately, yes. Please, can somebody answer my question?

awojciak avatar Nov 15 '22 14:11 awojciak

you add manual OpenSSL.framework in General Project, archive Done, but when you debug, you must remove OpenSSL.xcframework

Thinhnguyen185 avatar Nov 17 '22 03:11 Thinhnguyen185

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.

awojciak avatar Nov 17 '22 15:11 awojciak

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

awojciak avatar Nov 18 '22 13:11 awojciak

Any updates ?

adelbeke avatar Dec 02 '22 22:12 adelbeke

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.

superKalo avatar Jan 03 '23 15:01 superKalo

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 avatar Jan 03 '23 15:01 awojciak

@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?

superKalo avatar Jan 04 '23 09:01 superKalo

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 ..

hoanganhx86 avatar Feb 16 '23 13:02 hoanganhx86

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:

Screenshot 2023-04-07 at 9 45 48 PM

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...

otech47 avatar Apr 07 '23 19:04 otech47

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.

BlackCat1397 avatar Apr 15 '23 10:04 BlackCat1397

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.

chocky335 avatar May 08 '23 00:05 chocky335

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"

otech47 avatar May 10 '23 08:05 otech47

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

nriccar avatar Jun 07 '23 19:06 nriccar

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

numandev1 avatar Jun 09 '23 08:06 numandev1

any updates on this?

Ahmedhamed77 avatar Aug 31 '23 11:08 Ahmedhamed77

@Ahmedhamed77 you can try these solutions https://stackoverflow.com/a/76455587/8079868

numandev1 avatar Sep 05 '23 06:09 numandev1

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

hpelitebook745G2 avatar Oct 25 '23 16:10 hpelitebook745G2

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.

boorad avatar Jul 08 '24 18:07 boorad