Building on M1, error Could not find module ... for target x86_64-apple-ios-simulator - swift

Attempting to build project with Swift module. Xcode 12.5.1. Builds fine on Intel machine.
Builds fine on M1 machine if building for iOS device.
Does not build on M1 machine if building for simulator.
Error: Could not find module xxx for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator
There are several pods also being used. Some report building for x86_64. I don't understand why. In particular flurry.
When it gets to our Swift module xxx its importing, it generates the above error.
I have tried setting Build Active Architecture Only both Yes and No.
I have tried overriding in Podfile as well.
I have tried adding x86 to list of Architectures.
What tells Xcode to attempt to build x86 architecture? This is on an M1 machine. There should be no need for x86.
Thanks

Related

XCode 14 - Minimum deployment target for SPM package

I am actually compiling for macOS 10.12, as stated. I import the Reachability.swift package, that is compatible down to 10.9. No minimum version is indicated within the Package.swift file. However, I get this error while compiling :
Compiling for macOS 10.12, but module 'Reachability' has a minimum
deployment target of macOS 10.13
It happens since I updated to XCode 14, with version 13, there was no problem.
If I specify the minimum version in the Package.swift of Reachability platforms:[.macOS(.v10_10)],, I clean all the caches, I get the same problem.
I could probably upgrade deployment target to 10.13 (same computer compatibility) or simply include the Reachability.swift file in my code, but I would rather that it works...
[EDIT] Note : other packages, like AppCenter, do not have the same problem… which is weird.
[EDIT 2] With the release of XCode 14.1, the problem remains the same.
Do you have any suggestion ?
I can reproduce your problem: Using AppCenter is OK, but the reachability throws an error.
Here is what I found and maybe this is the root cause:
Make Reachability a local SPM, and modify its swift-tool-version settings and platform settings to align with AppCenter.
Then if you click into the .v10_12 MacOSVersion, you will find os versions lower than 10.13 has all been marked as unsupported
If you head to the built files, test it with otool, you will find the built product's minimum supported version matches with the above description:
So even if you specify the minimum support version to 10.12, the build tools will still target 10.13.
If you check LC_MIN_VERSION_MACOSX on AppCenter. It is also targeting 10.13 instead of 10.12 in its package.swift file.
But why Xcode accepts AppCenter and raise an error for Reachability?
Check the build log below. You will find it in the emitting module stage, the build system is using swift-frontend to embed those 3rd party dependencies. So I guess since the AppCenter is written in objective C.
The checking minimum os version behavior of swift-frontend is different between OC Dependency "AppCenter" and Swift Dependency "Reachability."

Framework not found FBLPromises (Swift Package Manager)

I've seen this problem listed elsewhere, but it always seems to be linked to a Cocoapods installation of Firebase. My problem is the opposite - trying to upgrade from pods to SPM has given me this problem when I try to compile:
ld: framework not found FBLPromises
I'm currently running Xcode 13.3 on a Mac Mini with an M1 chip, but the problem was present in earlier versions of Xcode.
Previously I had Disk (https://github.com/saoudrizwan/Disk) installed via SPM and Firebase/Messaging and Twilio (5.5.1) installed via Cocoapods. I ran pod clean and pod deintegrate, deleted all the Pod files etc and have installed Twilio and Firebase Messaging using SPM. This gives me the following Package Dependencies (and you can see that Promises 2.0.0 has been added successfully):
The top result I get when I look into this is FBLPromises Framework not found, and the second answer suggests adding arm64 as an excluded architecture, but doing that gives me further problems (warning and error below), and I'd rather not exclude an architecture blindly and then go down a rabbithole of trying to fix that when it might not be the solution to my original problem.
Warning and error when I try to exclude arm64 architecture:
None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s) which is not in EXCLUDED_ARCHS (arm64).
error: Build input file cannot be found: '/Users/myName/Library/Developer/Xcode/DerivedData/project-exchrqebmyccatebeoxupvxpdsul/Build/Products/Debug-iphoneos/project.app/project' (in target 'project' from project 'project')
I've not checked to make sure I've not introduced other errors further down the line, but I think the problem was caused by Linker Flags being retained in the build settings.
I went to the Target -> Build Settings -> Linking and deleted everything under 'Other Linker Flags' (OTHER_LDFLAGS is how this is reflected in the project.pbxproj file according to my git diff).
File now compiles and runs successfully, if I find some subtle bugs later that might be caused by this I shall edit this answer accordingly!

Xcode 13.2 command PhaseScriptExecution failed with a nonzero exit code

While building my project, I get this error:
line 2: /usr/local/bin/carthage: No such file or directory. Command PhaseScriptExecution failed with a nonzero exit code
Tried so many methods to resolve this issue, including switching Xcode versions.
It's worth to mention that it only occurs on an M1 Mac device which I'm currently using, same project without changing any part of the configurations works on an Intel Mac.
The project is using Carthage, which is likely installed using Homebrew. On M1 Macs, Homebrew links its binaries into /opt/homebrew/bin while on Intel Macs, they are linked into /usr/local/bin.
This means that on an M1 Mac, Carthage is probably found at /opt/homebrew/bin/cartage.
Your build script should use something like $(which carthage) or simply carthage instead of relying on an absolute installation path.
I had a similar error. My issue was that I didn't have a ~/.bash_profile. Creating an empty file fixed the error

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 arm64clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please can you help me, how to solve it?
Looks like a missing Arm64 simulator slice in the OpenSSL-Universal CocoaPods distribution.
Make sure that you're using the latest version with pod update and contact the OpenSSL-Universal if there's still an issue.

Swift for TensorFlow - dyld: Symbol not found: _$sSly7ElementQz5IndexQzcigTq

I'm trying to work through the model training workflow tutorial (https://www.tensorflow.org/swift/tutorials/model_training_walkthrough) but when running the code (it's a MacOS app) in Xcode 10.2 (on MacOS 10.14.4 ) I get the following error:
dyld: Symbol not found: _$sSly7ElementQz5IndexQzcigTq
Referenced from: /Users/Luke/Library/Developer/Xcode/DerivedData/ANN-ffxhvyujcitzkqfhbrwqjnpftijw/Build/Products/Debug/ANN.app/Contents/MacOS/../Frameworks/libswiftPython.dylib
Expected in: /usr/lib/swift/libswiftCore.dylib
in /Users/Luke/Library/Developer/Xcode/DerivedData/ANN-ffxhvyujcitzkqfhbrwqjnpftijw/Build/Products/Debug/ANN.app/Contents/MacOS/../Frameworks/libswiftPython.dylib
I've followed the official installation instructions (https://github.com/tensorflow/swift/blob/master/Installation.md):
Downloaded the latest release "swift-tensorflow-RELEASE-0.2"
Run the installer
Set the toolchain to "Swift for TensorFlow Release 0.2" created 02/03/2019
Set the Build System for shared and per-user to Legacy Build System
Set Swift Compiler - Code Generation -> Optimization Level to Optimise for Speed [-0]
added libtensorflow_framework.so and libtensorflow.so to Linked Frameworks
Added "/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.2.xctoolchain/usr/lib/swift/macosx to Runpath Search Paths. $(inherited) and #executable_path/../Frameworks were already present in the list
added -lpython to Other Linker Flags
I found this to be quite helpful: https://github.com/tensorflow/swift/blob/master/Usage.md#mac-only-xcode
On macOS Catalina, Verify Code Signature for Swift for TensorFlow toolchains produces a code signature error. This prevents Xcode projects built using Swift for TensorFlow toolchains from running. To work around this issue, go to Project Target Settings > Signing & Capabilities > + Capability > Hardened Runtime and check Disable Library Validation.