iOS universal framework compiler version changes after pod install

523 views Asked by At

I'm facing an issue with the universal framework in iOS (closed source).

When creating the universal framework it shows * Generated by Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9) * and it works fine if add the framework to project

But after uploading it to git and using pod to install I'm getting an error Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1.2 compiler

When I checked the header file I saw // Generated by Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)

The issue I understood is while uploading my compiler is Swift version 5.1.2, which is correct but after pod install somehow it's getting changed to Swift version 5.0.1

Why is this getting changed? and how can I make sure that it won't change?

podspec

Pod::Spec.new do |s|
s.platform = :ios, '11.0'
s.name = "xyz"
s.version = '1.0.5'
s.summary = 'xyz - Binaries'
s.description = 'Framework for xyz'
s.homepage = 'https://github.com/xyz/xyz'
s.license = { :type => 'MIT' }
s.author = 'https://github.com/Albinzr'
s.requires_arc = true
s.swift_version = '5.1'
s.source = { :http => 'https://github.com/xyz/SDK/blob/master/xyz.framework.zip?raw=true' }
s.ios.deployment_target = '11.0'
s.ios.vendored_frameworks = 'xyz.framework'
end
2

There are 2 answers

2
dosi On

You see this issue is because the framework is being built for distribution with Xcode 11.0 (with Swift 5.0). And you build it locally with Xcode 11.2, which has updated Swift 5.1.2. Swift 5.1.2 is incompatible with 5.0, but it seems like forthcoming releases of Swift will be compatible with 5.0. Because they finally introduced Swift Module stability in 5.1.2.

Make sure that the CI/CD (or another distribution system) runs the latest Xcode.

And make sure to install pods using pod install --repo-update. By default, Cocoapods does not update the repo (because historically that process used to be slow before they introduced CDN)

I hope that helps!

0
Orkhan Alikhanov On

As of CocoaPod 1.7 and later it is changed to spec.swift_versions = ['3.2', '4.0', '4.2']. Check out http://blog.cocoapods.org/CocoaPods-1.7.0-beta/