I ran into an issue when using pod lib lint and pod spec lint on frameworks across Xcode 10.1 and 10.2. We have a library (Willow) that supports both Swift 4.2 and 5.0 in Willow 5.2.1. We then have a second library that also supports Swift 4.2 and 5.0 called Surf. When linting with Xcode 10.2, everything works as expected. When linting with Xcode 10.1, Willow can never be compiled because CocoaPods is always setting the Swift version to 5.0 even though it isn't supported on Xcode 10.1.
cnoon:~/Programming/Troubleshooting/CocoaPods/LintingPods$ pod lib lint Surf.podspec
-> Surf (1.0.0)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'App')
- NOTE | [iOS] xcodebuild: error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Willow')
- NOTE | [iOS] xcodebuild: error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Surf')
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
[!] Surf did not pass validation, due to 1 error.
You can use the `--no-clean` option to inspect any issue.
By adding --swift-version=4.2, I can get Surf to compile, but Willow will still be set to a SWIFT_VERSION of 5.0.
cnoon:~/Programming/Troubleshooting/CocoaPods/LintingPods$ pod lib lint Surf.podspec --swift-version=4.2
-> Surf (1.0.0)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Willow')
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
[!] Surf did not pass validation, due to 1 error.
You can use the `--no-clean` option to inspect any issue.
It appears that the --swift-version=4.2 argument only affect the Surf pod, and has no effect on dependent pods. Therefore, I have no way to actually lint Surf with Xcode 10.1 because Willow will always be set to Swift 5.0 which won't compile.
After some digging, it looks like this is handled in Podfiles with the new supports_swift_versions API. It seems we need that same type of functionality in linting, or to have --swift-version be pushed down to dependent pods that support higher Swift versions.
I expected Willow to be set to a SWIFT_VERSION of 4.2 when running pod lib lint or pod spec lint when compiling with Xcode 10.1. I expected this even more so when adding the --swift-version=4.2 command line argument to pod lib lint.
Willow is always set to a SWIFT_VERSION of 5.0 when running pod lib lint with Xcode 10.1 which will always fail.
I was running CocoaPods 1.7.0.rc.1 for testing.
Thanks! Will check it out!
@cnoon but what if Willow doesn't support Swift 4.2?
i guess what we can do is if a dependency supports this dependency then use it otherwise warn?
I expected Willow to be set to a SWIFT_VERSION of 4.2 when running pod lib lint or pod spec lint when compiling with Xcode 10.1.
CocoaPods explicitly does not know the version of Xcode being used.
@dnkoutso that's certainly a great point about CocoaPods not knowing which version of Xcode is running. Would it make sense to have the --swift-version=4.2 flag push down to dependencies as well if they support multiple Swift versions? Seems like that would work for this use case, but I'm not sure it that breaks others. If I specified --swift-version=4.2 for linting Surf, and Willow only supported 5.0, then I would expect pods to respect the 5.0 setting on Willow and get the error using Xcode 10.1. If Willow supported both, could we infer that it would make sense to lint with 4.2 for all dependencies as well if they support it?
I see your point and agree. It seems we need supports_swift_version support for lint.
Perhaps we can parse --swift-version as a requirement...all lint does is create an in-memory Podfile.
Perhaps we can parse --swift-version as a requirement...all lint does is create an in-memory Podfile.
more thinking on this we probably don't want to do that as requirements can be >= etc...
I am leaning on pushing the value down to dependencies if supported and error (or let it error out like it does for you) if the dependency does not support it.
Yep, I think that makes the most sense.
I'm running into this also. Currently using Xcode 10.1, have a private Framework that I'm trying to publish to my private spec repo. My private Framework depends on SwiftKeychainWrapper and TrustKit. Currently I'm unable to lint my private pod due to dependent pod:
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'SwiftKeychainWrapper')
Will take care of this in 1.7.1.
Thanks @dnkoutso 馃嵒
Moved this to 1.7.2 still on my list to do but also trying to coordinate Xcode 11 support.
Most helpful comment
more thinking on this we probably don't want to do that as requirements can be
>=etc...I am leaning on pushing the value down to dependencies if supported and error (or let it error out like it does for you) if the dependency does not support it.