Aws-sdk-ios: Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler

Created on 16 Mar 2020  路  6Comments  路  Source: aws-amplify/aws-sdk-ios

Which AWS Services is the feature request for?
AWSMobileClient and probably the rest of Xcode Projects

Is your feature request related to a problem? Please describe.
Sometimes we have to use Xcode Beta to deploy on devices with iOS Betas. With Xcode 11.4 (Beta 3) I get following error at the import of AWSMobileClient in my swift file:

Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler: /$projectdir/Carthage/Build/iOS/AWSMobileClient.framework/Modules/AWSMobileClient.swiftmodule/arm64-apple-ios.swiftmodule

Describe the solution you'd like
https://stackoverflow.com/questions/58654714/module-compiled-with-swift-5-1-cannot-be-imported-by-the-swift-5-1-2-compiler
A solution might be to set BUILD_LIBRARY_FOR_DISTRIBUTION to yes.

Describe alternatives you've considered
The alternative is to recompile AWS-SDK-IOS with the beta compiler. It takes ages and when you switch back to the current compiler you have to recompile again.

build work in progress

Most helpful comment

VENT: Why is it that every SDK provider who made the unfortunate decision to write their SDK in Swift gets punished each time Swift decides to ignore backwards compatibility even inside major version numbers. It's been frustrating me for a couple of years now requiring my client to hire contractors to recompile their SDK, test and notify all third parties that the 2 month old SDK will now break their next release... because modules compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler... very grrrrrr.. thanks.

All 6 comments

Hi this issues got a lot of importance with the official Xcode 11.4 release this week.
A quickfix for us would be a new AWS-SKD-iOS release built by Xcode 11.4

We will be updating the CI/CD config to build with Xcode 11.4.

We're also investigating the BUILD_LIBRARY_FOR_DISTRIBUTION flag, but it doesn't seem to be as simple as merely adding that flag.

The root of the issue with setting BUILD_LIBRARY_FOR_DISTRIBUTION appears to be a known issue with Xcode:

  • If a module is built with BUILD_LIBRARIES_FOR_DISTRIBUTION and contains a public type with the same name as the module itself, clients will fail to import the module. (19481048) (FB5863238)
  • Workaround: Rename either the type or the module to remove the conflict.

This does not yet appear to be resolved in Xcode 11.4, and so we cannot provide forward compatible binary distributions since renaming either the class or the module would be a significantly breaking change.

For now, we'll update the build system to use 11.4, and continue to monitor the Xcode releases and the associated Swift.org issue.

We updated the build image to use Xcode 11.4 in release 2.13.2. Closing.

VENT: Why is it that every SDK provider who made the unfortunate decision to write their SDK in Swift gets punished each time Swift decides to ignore backwards compatibility even inside major version numbers. It's been frustrating me for a couple of years now requiring my client to hire contractors to recompile their SDK, test and notify all third parties that the 2 month old SDK will now break their next release... because modules compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler... very grrrrrr.. thanks.

Using BUILD_LIBRARY_FOR_DISTRIBUTION on Xcode 12 Beta seems to work as expected 馃コ

Project > Build Settings > Build Options > Build Libraries for Distribution = YES

Was this page helpful?
0 / 5 - 0 ratings