Failed to build IONIC Geofence on Xcode - swift

I am using Geofence plugin on IONIC. When I build on Xcode 10.2 it's say:
"Unsupported Swift Version. The target 'MyApp' contains source code developed with Swift 3.x. This version of Xcode does not support building or migrating Swift 3.x targets. Use Xcode 10.1 to migrate the code to Swift 4"
But if I downgrade to Xcode 10.1, it will not work on iOS 12.2.
What should I do now?

Related

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.

Build own carthage with swift version 5.0

I am newly creating carthage and new to this.
I followed the tutorial from
https://medium.com/better-programming/how-to-create-a-framework-with-carthage-support-c30b596d3a7a
I created my own custom project for which I will create my carthage.
I followed the same steps and when I use the command
carthage build --no-skip-current
I get the error, as
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'GSKit')
When I build the carthage with lower swift version by changing the setting in Build Setting to 4.0, this works well,
but I want to implement my own carthage framework with Swift 5.0
I am using Xcode version 11.3
Swift version 5.0
and carthage version on my machine is 0.34.0
Can any one help me so that I can build my carthage in swift 5.0
what changes I am missing to make it compatible to work for swift 5.0
Thanks,

How to import and use CreateML or CreateMLUI in Xcode

I would like to use the new CreateML and CreateMLUI Swift frameworks.
But when I write:
import CreateML
Xcode gives me an error:
No such module 'CreateML'
How can I use those in Xcode?
To import CoreML or CoreMLUI you need to get latest software:
Go to https://developer.apple.com/download/
Install macOS Mojave 10.14 beta version.
Install Xcode 10 beta.
Create a macOS platform template.
HOW TO CREATE YOUR OWN MLMODEL: https://developer.apple.com/documentation/create_ml/creating_an_image_classifier_model
Use free MLModels provided by apple: https://developer.apple.com/machine-learning/run-a-model/
You need to
Have Mojave installed
Install Xcode 10 beta
Create a macOS template playground (not iOS)
Install Mojave* and Xcode 10.
Create a new playground and make sure you select macOS as the target (e.g. macOS Single View).
Type in import CreateMLUI- it should compile without problems.
(*)macOS Mojave is officially available since yesterday.
For Xcode 10 - beta 6
You don't have to upgrade to Mojave. The newest Xcode - beta already supports 10.13.x. (From Apple Developer Forums).
I followed this step to try CreateML framework.
Upgraded to latest MacOS (Not Mojave)
Upgraded latest Xcode - beta.
Create playground in macOS template (Default is iOS template)
Then, I can use createMLUI.

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1

Swift 4.0 modules were fine in Swift 3.2 apps with Xcode 9.0.
But now, with Xcode 9.1, I get:
Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1
Or:
Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1
Swift 4.0 is compatible with Swift 3.2 only.
Swift 4.0.1 is compatible with Swift 3.2.1 only.
So:
you can't mix 4.0 and 3.2.1
you can't mix 4.0.1 and 3.2
you can't mix 4.0 and 4.0.1
you can't mix 3.2.1 and 3.2
To formulate it differently:
you can mix Xcode 9.0 supported Swift versions together
you can mix Xcode 9.1 supported Swift versions together
you can't mix Xcode 9.0 and Xcode 9.1 Swift versions
If the module was built by you, simply rebuild it with the same Xcode.
If the module was built by a third party, request an Xcode 9.1 compatible build.
It's possible to build using Swift 3.2 in Xcode 9.1 beta 2 by installing the Xcode 9.0 toolchain and using that to build your project.
Then choose the Swift 4.0 release under the Xcode -> Toolchains menu.
You should now be able to build with either Swift 3.2 or 4.0 in Xcode 9.1 b2.
Using the last Xcode version solved this issue