Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.1 compiler

When building application in Xcode 11.2 beta (Swift 5.1.1) that uses framework build in Xcode 11.0 (Swift 5.1) I get an error that module compiled with 5.1 compiler cannot be imported by Swift 5.1.1 compiler. Shouldn't Swift 5.1 module stability solved this issue?

Answered by DTS Engineer in 387658022

Shouldn't Swift 5.1 module stability solved this issue?

Yes, assuming you have enabled the Build Libraries for Distribution (

BUILD_LIBRARY_FOR_DISTRIBUTION
) build setting.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

Shouldn't Swift 5.1 module stability solved this issue?

Yes, assuming you have enabled the Build Libraries for Distribution (

BUILD_LIBRARY_FOR_DISTRIBUTION
) build setting.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you fot your answer. It works with this setting enabled. FInaly frameworks build in Swift are simple to distribute.


Best Regards,

Suzana

It works with this setting enabled.

Cool.

I also recommend that you watch WWDC 2019 Session 416 Binary Frameworks in Swift, which cover this build setting along with a bunch of other useful tidbits.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have enabled "Build Libraries for Distribution" and cleaned the build folder but i am still getting the "Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.1 compiler: /Users/oliviervincent/Documents/Spliqs/SpliqsAR/HelloWorld/AudioKit-iOS/AudioKit.framework/Modules/AudioKit.swiftmodule/arm64-apple-ios.swiftmodule" error.

What am I missing please?


(using Xcode 11.2 beta 2)

Hmmm, this is working for me. Here’s what I did:

  1. I ran Xcode 11.1 (on 10.14.6, but I don’t think that’s relevant) and created a new framework from the macOS > Framework template.

  2. I added a new

    TFHello.swift
    file with the contents:
    import Foundation
    
    
    public enum TFHello {
        public static func sayHello() {
            NSLog("Hello Cruel World!")
        }
    }

    .

  3. I set Build Libraries for Distribution (

    BUILD_LIBRARY_FOR_DISTRIBUTION
    ) build setting.
  4. I built the framework.

  5. I control-clicked on the framework in the Project navigator and choose Show in Finder.

  6. Using the Finder, I copied that framework to my desktop.

  7. Back in Xcode 11.1, I closed the project and quit Xcode itself.

  8. I opened Xcode 11.2b2 and created a new app from the macOS > App target.

  9. I moved the framework from step 6 into that directory.

  10. I added that framework to the target.

  11. I changed the

    ViewController.viewDidLoad
    method to call it:
    override func viewDidLoad() {
        super.viewDidLoad()
        TFHello.sayHello()
    }

    .

  12. I added a Copy Files build phase to copy it into the app’s Frameworks directory.

  13. I did a build and run. The app built and, on launch, it logged:

    2019-10-21 09:44:50.671009+0100 TestClient[42046:7455817] Hello Cruel World!

    .

I’m not sure why this isn’t working for you. My advice is that you try to replicate my steps to check that things are working in general. Then you can compare my process to the process you used in your real project to see what’s different.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I am not successful yet.


So what I am hearing is that for now, there is no direct way to use AudioKit with Xcode 11.2 b2?


Will this be fixed by a new Xcode version or is Audiokit working on it you think?

Thanks,

o

Will this be fixed by a new Xcode version or is Audiokit working on it you think?

I’ve no direct experience with AudioKit. My recommendation is that you escalate this via the support channel for that framework.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I am creating my custom framework & distributing it as Pods .After Chaging the BUILD_LIBRARY_FOR_DISTRIBUTION to yes in my framework.I haved installed the my custom framwork I am getting the following error


Failed to load the files/ modules of my framworks.

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.1 compiler
 
 
Q