Unable to load standard library for target arm64 error in XCode on Macbook Air M1 - swift

On new Mac with M1 chip get the error after the build of React Native app in XCode 12.4:
unable to load standard library for target 'arm64-apple-ios8.0'
failed to build module 'SciChart' from its module interface; the compiler that produced it, 'Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)', may have used features that aren't supported by this compiler, 'Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)'
What I already tried:
Reinstall XCode;
Changed Swift Language Version;
Deleted VALID_ARCHS reference according Xcode 12 Beta 2 - unable to load standard library for target 'arm64-apple-ios14.0-simulator'
On Macbook with intel chip there are no errors with the same app. And both of my Macbook have the same swift version:
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin20.3.0
Can you help me please!

Guys if you have old React Native projects just build it on Xcode with rosetta and you will save your nerves and time. I was looking the decision all week, but in the total it was so easy, just run Xcode with rosetta on M1: please try to open Xcode through Rosetta - Right click on Xcode in applications folder -> Get Info -> set Open with Rosetta to true

Related

Cant build ios project, no such module or this SDK is not supported by compiler

So I got an demo ios project from different company but I can't launch it
Basically i get two errors:
Sometimes I also go an unsupported swift architecure error
I work on M2 processor and use XCode 14.2
Project does not have pods, all packages are managed via spm (that's what I was told)
For now i tried:
opening xcode via rosetta (nothing changed)
changing version of xcode to 14.0 (nothing changed)
using other swift version via toolchain (Swift 5.7), screen below ( get different erorrs but i dont think its a good way)
UPDATE
I downloaded version 14.0 of xcode and toolchain 5.7.2
When i use that version of xcode i get an error about missing classes from that sdk in scope and also some weird error from SentrySamplingProvider ( screens below)

Swift Version Conflict: this SDK is not supported by the compiler - using BUILD_LIBRARY_FOR_DISTRIBUTION setting. What could be the issue?

I'm building a Swift static library with:
Xcode 13.2 (Swift compiler 5.5.2)
iOS Deployment target 12.0
Build library for distribution YES
Skip install NO
Swift language version 5 and tried with 4.2
Dependency managed with CocoaPods:
Japx 3.0.0
Alamofire 5.2.2
RxSwift
When I try to add it to an iOS project with this setup:
Xcode 13.3 (Swift compiler 5.6)
iOS Deployment target 12.0
Swift language version 5 and tried with 4.2
and build I get this error:
Failed to build module 'LibraryX'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)', while this compiler is 'Apple Swift version 5.6 effective-4.2 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)'). Please select a toolchain which matches the SDK.
These are the headers in the .swiftinterface
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 4.2 -enforce-exclusivity=checked -Onone -module-name LibraryX
Obviously if I build the project with the same compiler version or building the library with the iOS project everything works fine. But the purpose here is to release a precompiled library and not its source code.
Every time that I lookup this error online I've found "You have to set Build library for distribution to Yes"
I tried to add the source code of the static library to a new Framework project, but I get the same result.
I also had this error, in my case it was unable to import a sub-dependency of my XCFramework during reading .swiftinterface file, however was showing this absolutely misleading error.
After repeatedly cleaning up DerivedData and trying different Xcode versions (13.0, 13.4.1) I've seen 2 errors: "this SDK is not supported by the compiler", and "No module named 'AnotherLib'" which was an incorrectly specified dependency inside of my Swift Package.
So, maybe only first part of the message is correct "Failed to build module 'LibraryX'", but the reason is something else, NOT the difference in compiler versions.

Swift Version Conflict: this SDK is not supported by the compiler, Please select a toolchain which matches the SDK

I'm using xCode 13.1 with macOS 12.0.1 Monterey. I added KingFisher and removed it from my pod. but my project is not built anymore. I got this error for one of my local SDKs:
Failed to build module 'CbSdk';
this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.4
(swiftlang-1205.0.26.9 clang-1205.0.19.55)', while this compiler is 'Apple Swift version 5.5.1
(swiftlang-1300.0.31.4 clang-1300.0.29.6)'). Please select a toolchain which matches the SDK.
What I've done but didn't work:
pod deintegrate and pod install.
restart xCode with clearing cache and DerivedData.
checkout old branch and commit that worked before.
moving code to another macBook that worked before.
download, install and select toolchain 5.4 (odd errors appeared -> )
changing swift compiler language of my target and project to swift 4 (It says you are using swift 5.5.1 again!)
note that I didn't update xcode or swift!
Taken from this Twitter thread.
You need to set the BUILD_LIBRARY_FOR_DISTRIBUTION build setting on the framework target
https://www.swift.org/blog/library-evolution/
https://developer.apple.com/videos/play/wwdc2019/416/
I fetch the same problem when I try to update a library. My Xcode version was 13.2 with the swift version5.5.2. But the library I want to update required a swift version of 5.7.0. Using toolchains in Xcode might be the solution but I decided to update the Xcode version with the latest.
I update my Xcode to the latest version 14.1 and the issue is resolved. Automatically the swift version is found on the latest Xcode.

Swift Package Manager - How to `Always Embed Swift Standard Libraries`?

We have CLI tool written in Swift for common usage (Android and iOS developers) on macOS.
Android developers without Xcode installation get the following error:
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: ~/git/myClITool/macosBin Reason: image not found
Abort trap: 6
We found that enabling Always Embed Swift Standard Libraries in Xcode would most likely help, but this CLI tool is exported with SPM, ignoring all Xcode settings.
How can I achieve this build behaviour using SPM only?
Found the following commandline argument: --static-swift-stdlib
Example usage:
swift build --static-swift-stdlib -c release
This would have produced the output we were looking for. Unfortunately since Swift 5, this argument no longer works for any platforms.
When used, SPM throws the following warning:
warning: Swift compiler no longer supports statically linking the
Swift libraries. They're included in the OS by default starting with
macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier,
there's an optional Swift library package that can be downloaded from
"More Downloads" for Apple Developers at
https://developer.apple.com/download/more/
Related Swift bugticket: https://bugs.swift.org/browse/SR-648

Trouble getting Vapor to work with Xcode 8 beta 3

I was following the instructions here, but was not able to get vapor working on my mac. Here're my xcode and swift versions
Xcode 8.0
Build version 8S174q
Apple Swift version 3.0-dev (LLVM 8fcf602916, Clang cf0a734990, Swift 000d413a62)
Target: x86_64-apple-macosx10.9
When I try to install the toolbox using this command
curl -sL toolbox.qutheory.io | bash
The installation is unsuccessful and yields this message
⚠️ It looks like your Command Line Tools version is incorrect.
Make sure Xcode > Preferences > Locations > Command Line Tools is set correctly.
Correct: Xcode 8.0 (8S162m)
Current: Xcode 8.0
Build version 8S174q
⚠️ It looks like your Swift install location has been modified.
Correct: /usr/bin/swift
Current: /Users/<name>/.swiftenv/shims/swift
❌ Incompatible
Reason: Invalid Swift version
Output must contain 'swiftlang-800.0.33.1'
Current 'swift -version' output:
Apple Swift version 3.0-dev (LLVM 8fcf602916, Clang cf0a734990, Swift 000d413a62) Target: x86_64-apple-macosx10.9
📖 Visit our docs for step-by-step instructions on installing Swift correctly.
http://docs.qutheory.io
👋 or Join our Slack and we'll help you get setup.
http://slack.qutheory.io
From this, I can gather that my swift location is wrong (I don't remember changing it) and that my xcode build number is wrong (because xcode beta 2 is no longer available for download, so I got xcode beta 3.)
Can anybody help me to get this working without changing too much, or is this framework still too finicky to work with a slightly different setup?
Unfortunately it's impossible to create packages that work between different Swift 3 development previews because of how much changes in each preview. Things that compiled today might not compile tomorrow and there is no way to selectively target a given preview in code.
Because of this, the Swift version declared in https://github.com/qutheory/vapor#-current-environment for a given Vapor version must be the one used.
Vapor 0.14 relied on the Swift 3.0 preview 2 version that comes with Xcode 8 beta 2. There is currently no way to download Xcode 8 beta 2 now that Apple has stopped hosting it upon the release of Xcode 8 beta 3. That was an oversight.
Vapor 0.15 will not rely on Xcode 8 beta previews and should be released in a few days.
Open Xcode and make sure the correct SDK is selected:
👀 Xcode > Preferences > Locations > Command Line Tools
Select XCode 8
Then continue with the tutorial you are following.