Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10.2 Module compiled with Swift 4.2 cannot be imported by the Swift 5.0 compiler [duplicate]

Tags:

ios

swift

paytm

I am trying to implement integration of third party app into project as per instruciton https://github.com/Paytm-Payments/Paytm_iOS_App_Kit/tree/master/Swift/BitCodeDisabled/PaytmNativeSDK

I see the following error in build

Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler

I have tried toolchains https://medium.com/xcblog/switching-swift-versions-inside-xcode-using-toolchains-755b28831c43 The error changes to Reason: Incompatible library version: PaytmNativeSDK requires version 1.0.0 or later, but libswiftCore.dylib provides version 0.0.0

How do i setup XCode or the Library to make it work . There is no chance of the vendor updating the library for Swift 5.0 and make it available on POD.

like image 366
appbootup Avatar asked Mar 26 '19 08:03

appbootup


People also ask

How do I update my Apple version of Swift?

You can also update every single Swift Package in your project at once. To do this, open the Files menu, navigate to Packages and then click Update to Latest Package Versions. Afterwards, make sure to test your project to see if everything still works, especially in projects with a lot of package dependencies.

What is Build_library_for_distribution?

Build Libraries for Distribution BUILD_LIBRARY_FOR_DISTRIBUTION. Ensures that your libraries are built for distribution. For Swift, this enables support for library evolution and generation of a module interface file.

How do I compile framework in Xcode?

In Xcode, select File ▸ New ▸ Project…. Then choose iOS ▸ Framework & Library ▸ Framework. Click Next.


3 Answers

For Carthage users: After upgrading to Xcode 10.2, I ran into this same issue with a framework that I had been importing using Carthage.

I resolved it by rebuilding the framework:

carthage update --no-use-binaries --platform iOS
like image 179
Mike Taverne Avatar answered Oct 07 '22 08:10

Mike Taverne


The correct solution is download Xcode 10.1, and wait for Apple patch the bug fix.

Don't waste time on fix third-party bug.


The problem of my project is we are using Alamofire which is failed to update by Carthage.

like image 25
Yi Jiang Avatar answered Oct 07 '22 10:10

Yi Jiang


The provider of this library should rebuild it with BUILD_LIBRARY_FOR_DISTRIBUTION = YES; (available in Xcode 11.3 in Build Settings -> Build Options). Already asked to do it in the corresponding GitHub issue. After that PaytmNativeSDK will be compatible with every next Swift version.

It looks like the issue has been fixed in 804152caae76245d96548eb74ea87a6150239407.

like image 37
Roman Podymov Avatar answered Oct 07 '22 08:10

Roman Podymov