Running framework compiled in Swift 4.0 in Xcode 9.1 - swift

I recently updated Xcode from 9.0 to 9.1. My project has an external framework created by a business partner which was compiled in Swift 4.0. When I try and run the project, I get the following error thrown by the import of the external framework:
Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2
I understand this problem because Xcode 9.1 uses Swift 4.0.2, however, I am curious if there is anyway to compile this framework now that the Swift versions are incompatible. I tried changing the Swift Language Version variable in the Build Settings to 4.0 however, this made no change. I also don't see an option for 4.0.2 in this list so I am assuming when selecting 4.0 it defaults to 4.0.2?
Is there anyway I can compile this lib, or do I need to wait for them to release an update which was compiled in 4.0.2?

I've done something like:
In cocoapods separate swift 3.0.2 / 4 / 4.0.2 libraries
swift_32 = [<swift 3.0.2 libs>]
swift4 = [<swift 4 libs>]
swift_42 = [<swift 4.0.2 libs>]
post_install do |installer|
installer.pods_project.targets.each do |target|
swift_version = nil
if swift_32.include?(target.name)
swift_version = '3.2'
end
if swift4.include?(target.name)
swift_version = '4.0'
end
if swift_c42.include?(target.name)
swift_version = '4.0'
end
end
end
May be it will help you

Related

building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Getting this error.
Realm/core/librealmcore-ios.a(array_binary.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
Swift iOS 14 xcode 12.0.1
What I have tried :
Updating to the latest realm
Excluding the arm64 architecture
Nothing seems to work
Seems realm are having issues too : https://realm.io/docs/swift/latest/#cocoapods
"Arm64 simulator architecture may not be supported for several combinations of Realm 5.x and Xcode 12. Please attempt the following workarounds if you experience architecture-related build errors with the latest version of Realm."
Use
pod 'RealmSwift', '~> 10.5.0'
They already added support for xcframework.
It's not really a proper fix, but what worked for my project is:
following the suggestions provided by: https://realm.io/docs/swift/latest/#cocoapods
Installing cocoapods 1.10.0.rc1
setting the BuildActiveArchitectureOnly to Yes in the cocoapods project
Now when you build your app for your device or you're archiving make sure to set this back to No, or alternatively, use a different config for this (e.g: I have Debug set to Yes, Release to No).
What I did was
setting the BuildActiveArchitectureOnly to Yes in the build settings.
And
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end
end
And
Updated my Realm to the latest version.

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,

Unsupported swift version (SWIFT 5)

before you mark this question as a duplicate, I checked this question
and it didn't work for me.
how to fix this error:
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'DropDown')
For XCode 10.1, select your Pods File
-> Go to Build Settings -> Choose your Pod -> Search "Swift" -> Navigate to "Swift Language version" -> Set to desired language version.
You have code which was compiled on the new Xcode 10.2 or the beta version which supports Swift 5. Update your Xcode to the latest version.
After upgrading to Xcode 10.2 release make sure you reboot MacOS. I had the exact same problem and reboot helped.
In addition to the correct answer, I added this to my podfile.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
end

Cocoapods ignoring the Target's SWIFT_VERSION and sets 3.0 instead

From what I understand the Swift version used for your pods will be the Swift version specified in your main targets in your project.
My project has SWIFT_VERSION 4.1 set:
but when the debug or release xcconfig is generated, the SWIFT_VERSION version is set to 3.0. I can't find the reason why this happens:
I have a mixed 3.2 and 4.1 swift setup:
cocoapods: v 1.4.0 (tried 1.5.0 with no luck)
xcode: v9.3 (same on 9.2)
Thanks for any insights.
note: good resource here
the value came from one of the pods specs:
"xcconfig": {
"SWIFT_VERSION": "3.0"
},
https://github.com/CocoaPods/Specs/blob/d0ec5a65e80656c8d78e12ff19f251df879e0bc2/Specs/d/1/8/CocoaLumberjack/3.0.0/CocoaLumberjack.podspec.json#L75

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