Xcode error: building for iOS Simulator, but linking in object file built for iOS

Never had a lot of problems until the time to buy Macbook Air M1. Just yesterday my app was build without any error in Xcode 12.4. I did not make any special changes and today build failed:

/Users/userName/Projects/MyApp/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/userName/Projects/MyApp/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please can you help me, how to solve it?



This error indicates that OpenSSL is built containing the simulator slice (x86_64) with the iOS device slice (arm64). Combining device and simulator into a single binary file is not a supported build configuration, and never has been. With the introduction of M1 Macs, where the simulator is also arm64 now, Xcode is looking for a arm64 slice intended for the simulator, but finding one only valid for use on a device, and letting you know of this issue.

The solution is to rebuild OpenSSL. If you intend to use it as a a pre-built binary, rather than compiling from source during your app's build, it needs to be inside of an XCFramework. XCFrameworks are purposefully designed to separate device and simulator builds into separate files and avoid this class of error.
Xcode error: building for iOS Simulator, but linking in object file built for iOS
 
 
Q