Canvas preview for widget fails to compile

I added a Widget target to my project. If I build and run the Widget scheme everything works and I can see the widget in the simulator. But if I try to see the preview (clicking "resume") in the Canvas the compilation fails with an error about openssl libcrypto.a not having the correct architecture.

ld: in /Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a(cryptlib.o), building for iOS Simulator, but linking in object file (/Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a(cryptlib.o)) built for iOS, file '/Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please note that openssl is not in the header search path or the library search path for the Widget target. They are in the target of the main iOS app and they build and run with no issue both on the device and the Simulator.

Also note that libcrypto.a contains libraries for all architectures.
This is the result of the command file libcrypto.a:

file libcrypto.a
libcrypto.a: Mach-O universal binary with 5 architectures: [i386:current ar archive] [armv7s] [armv7] [x8664] [arm64]
libcrypto.a (for architecture i386): current ar archive
libcrypto.a (for architecture armv7s): current ar archive
libcrypto.a (for architecture armv7): current ar archive
libcrypto.a (for architecture x86
64): current ar archive
libcrypto.a (for architecture arm64): current ar archive

Many warnings are also displayed that in normal compilation aren't there about other targets having bitcode disabled (not true: they all have bitcoin enabled, and when compiling both the app and the widget scheme this warnings are not displayed)

ld: warning: all bitcode will be dropped because '/Users/username/Library/Developer/Xcode/DerivedData/ProjectName-cvlnfysptxebwcaeifxqmaltnndr/Build/Intermediates.noindex/Previews/ProjectName/Products/Debug-iphonesimulator/WhatsNewKit.o' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.

Filed report in Report Assistant as FB8619450

Accepted Reply

It may not help with your issue, but excluding arm64 when building for the simulator solved a similar issue with Firebase for me - see https://developer.apple.com/forums/thread/657913?answerId=628433022#628433022

Replies

It may not help with your issue, but excluding arm64 when building for the simulator solved a similar issue with Firebase for me - see https://developer.apple.com/forums/thread/657913?answerId=628433022#628433022
Thank you, I confirm the same workaround works, it looks like it is the same issue.