简体   繁体   中英

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

I have a VoiceSampler.framework that was built with Xcode 10.3

I am trying to use that framework in Xcode11 in a new project. I have successfully added that framework, but when I write import VoiceSample in AppDelegate, I get the following error:

Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler: /Users/apple/Projects/CaptureAppSwift/VoiceSampler.framework/Modules/VoiceSampler.swiftmodule/arm64.swiftmodule

Is there a Build Setting I can tweak in Xcode 11 to make it work? Any other work around?

This problem is caused by the fact that you attempt to embed a pre-compiled framework that was created with a different compiler version.

Currently, pre-compiled frameworks can only be embedded if the compiler versions match! The swift compiler version that is used to compile the project must be the same version that was used to compile the framework.

Hopefully, this restriction will be removed in future Swift / compiler versions... For more information refer to the chapter on "Module Stability" here: https://swift.org/blog/abi-stability-and-more

As already mentioned in one of the comments, the solution to this problem is to up- or downgrade to the appropriate Xcode version. (Or, if possible, recompile the framework with the desired compiler version and then use the same compiler version for your project.)

I was getting a similar problem for Sqlite.swift. Doing the following command worked for me:

carthage update --platform iOS --no-use-binaries

This was suggested here .

Just need to set the Build Libraries for Distribution option to Yes in your framework's build settings.

As I have already described here , the provider of VoiceSample should rebuild the framework with BUILD_LIBRARY_FOR_DISTRIBUTION = YES; . In such case, you will be able to use VoiceSample with all Swift versions.

The following commands resolved the compiler error

  1. carthage bootstrap --platform ios
  2. brew bundle
  3. pod repo update

在此处输入图像描述 If you using React Native to build your App, go to Xcode and click on File -> Workspace Settings... -> if you notice there is a small arrow that is the path to the DerivedData folder, click on that and the actual folder will appear with other iOS related folders, DELETE the DerivedData folder and rebuild your App. everything will work smoothly now... thank me later

In my case problem will be in carthage. So, I, in Finder , deleted these files from your project's root folder:

Cartfile.resolved, Carthage/

Then started carthage bootstrap --platform iOS (because I didn't need update carthage).

But if you need update carthage so you don't need to remove files. Only write command carthage update --platform iOS fix this problem.

In my case, with deleting the file Cartfile.resolved , and making a rebuild of my project enough to make it work again. Just as Taras Chernysh suggested, I'm sorry I can't add it where it belongs but I still don't have enough reputation.

You need to set the Build Libraries for Distribution option to Yes in your framework's build settings, otherwise the swift compiler doesn't generate the necessary .swiftinterface files which are the key to future compilers being able to load your old library.

This ends up in your project.pbxproj file as:

BUILD_LIBRARY_FOR_DISTRIBUTION = YES;

After setting this flag, a framework I compiled using Xcode 11.0 (swift 5.1) was able to be compiled with Xcode 11.2 (swift 5.1.2) and everything appears to be working correctly.

Here is a solution for this issue:

  1. Update the Xcode to version 11.2.1
  2. Then copy the PayTM SDK 5.2.1 for iOS in you project from below link

    https://drive.google.com/file/d/1zllbQU4hIyEp7BbRooMA2oQwt3G_VfEe/view

  3. Build the project

Note: check in the build phase in LINK BINARY WITH LIBRARIES section PaymentSDK.framework is there or not. If not then add manually, otherwise it will give you error that module not found.

For more help.. after solving this issue you can follow below link

http://blog.openwebsolutions.in/paytm-payment-integration-ios-swift-language/

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM