Module file was created by a newer version of the compiler - ios

I'm taking over development of a project and am unable to contact the previous developer. I'm trying to figure out which versions of the imbedded open source libraries were used. The project appears to be in Swift 2.1. I am attempting to compile it with Xcode 7.3.1. Carthage was the package manager used. I'm stuck on an error with RealmSwift. The error occurs on the line that tries to import RealmSwift.
/{app source path}/PersonnelModel.swift:10:8: Module file was created
by a newer version of the compiler: /{app source
path}/Carthage/Build/iOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule
I have worked my way all the way back to version 0.96.2 of realm-cocoa, which I believe is the first version to support Xcode 7.1 and Swift 2.1. However, I'm still getting the error.
I have looked through other answers on here, but have not found a solution that works. Am I misunderstanding the cause of the error? I just thought it was picking up a newer version of the framework.
Here is what my Cartfile looks like:
github "ReactiveCocoa/ReactiveCocoa"
github "Alamofire/Alamofire" ~> 3.4
github "SwiftyJSON/SwiftyJSON"
github "realm/realm-cocoa" == 0.96.2
github "scalessec/Toast-Swift" ~> 1.4.0

If you're just trying to get a clean compile for now, it might be worth taking Realm out of Carthage, installing it manually as a dynamic framework, and then putting it back into Carthage at the end once you've got everything smoothed out.
Xcode 7.3.1 was Swift 2.2. The very latest version of Realm to support Swift 2.2 is version 2.3.0, so I'd recommend downloading that version and manually importing it into Xcode 7.3.1
As an aside, Realm has dropped support for Swift 2 starting with version 2.4.0, so it's greatly recommended you migrate your codebase to Swift 3 as soon as possible. :)

I had this issue today in Xcode 8.3.2 w Swift 3. I mistakenly tried to run the swift 3 converter on one class file and canceled it mid run. Xcode then threw this error for one of my Pods (Bolts). Fix was to remove the pod, run pod update, then add the pod back, run pod update again so the module was reset.

Related

Swift Snapshot for version 4.1

I'm new to iOS development, so thank you in advance for the help. I'm trying to build an application that was built in XCode 9.3 and Swift 4.1. When I install the packages using Carthage, it throws this error:
"Skipped installing CryptoSwift.framework binary due to the error:
"Incompatible Swift version - framework was built with 4.1 (swiftlang-902.0.48 clang-902.0.37.1) and the local version is 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)."
The reason for the error (very clear...) is because I'm trying to build the project using XCode 10.2 and Swift version 5.0.1. So in order to fix it, you need to go to the swifts snapshots and download the version I need and install it.
However, when I go to the swifts snapshots I see the one for 4.1 but the links seem to be broken(?). It redirects me to the apple Xcode documentation.
Does anyone know where and how can I install the swift version I need?
Thanks,
If I understand your problem right, try giving this a go(if not already):
When using a newly released version of Xcode you'll have to build
libraries from source (by passing --no-use-binaries to carthage
update) until a new version of framework comes out which has pre-built
binaries for that Xcode version.
The above is an extract from: https://github.com/realm/realm-cocoa/issues/6134 and it might help...

Migrating from Cocoapods to Swift Package Manager but import module failed

recently I'm refactoring a project which uses Cocoapods to manage dependencies (a lot of dependencies...), since Xcode 11 integrated Swift Package Manager, I want to migrate progressively some dependencies to SPM staring from the framework Alamofire.
After I removed the Alamofire from the Podfile (delete and run pod install) and added it into SPM,
I got the error No such module 'Alamofire'.
I've already tried to clean build and removed derived data but none of them can fix it.
Did anyone have this problem too?
After few days searching, I found out this https://stackoverflow.com/a/57312755/863020.
Seems that SPM could be only used for Debug and Release configurations, if we want to use it with more configurations then we should write a pre-action. And it is also a known issue on Xcode so I would not use SPM for now :(
UPDATED on dec. 12
So I come back to my question after the new release of Xcode 11.3, it fixed this issue and now I can build the project with custom build configuration :)

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

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.
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
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.
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.
I wanted to use Swift 4.2 (which Xcode 10.2 should still support, I've set it in Swift Language Version), but it still gave me an error about the Swift 5.0 compiler. So after trying to clear everything like build folder, derived data and stuff, I came to the conclusion that it does not work on Xcode 10.2.
I reverted back to Xcode 10.1 which you can download here. This works. So until Apple fixes this bug I am forced to stay on Xcode 10.1.
The developers of the framework need to provide an update, which is built in Xcode 10.2.
Explanation for framework developers:
Even if you created the framework in Xcode 10.2 or with the default version used by CI, your users may still encounter such an error. You should make sure that Xcode 10.2 is your default command line tool. You can check it in terminal with the command xcodebuild -version.
Default version can be adjusted in Xcode -> Preferences -> Locations -> Command Line Tools.
This will happen if you have external libraries in your project thats still built using 4.2 compiler, whereas the new Xcode tries building your project in 5.0 compiler.
In my case, I had few libraries imported using Carthage. Luckily the libraries that I have used have released an updates in the past few days making it compatible with Swift 5.0 compilers. If those external libraries haven't updated it to support Swift 5.0 you may be out of luck for now.
On the way you might still face few issues and here are some best practices to avoid further issues.
Remove the cartfile.resolved and Carthage folder completely
Ensure you remove any copy of the libraries added to your project earlier.
Remove the embedded libraries and Linked frameworks and libraries from your Targets> Yourapp > General .
Product > Clean build folder
Update the Cart file and fetch the new sources using the Carthage update command
Now import the libraries back to your project.
Hopefully it works.
My problem with Carthage was related to the xcode phase that copys binaries in
"carthage copy-frameworks" phase.
I've a slightly different solution to the one commented in https://stackoverflow.com/a/55362536/721929, because that solution also updates dependencies versions in some cases.
So, I just executed "carthage build". I also include a cache clean for Carthage, to fix possible errors in subtasks (in my case, failing in git clone with "exit code 1")
rm -rf ~/Library/Caches/org.carthage.CarthageKit
carthage build --no-use-binaries --platform iOS --verbose
Just remove all the *.framework folders, fetch and generate then just Import the new framework folders to your project.
That's what helped me.
For Instance:

Xcode 9.1 : module compiled with Swift 4.0 cannot be imported in Swift 3.2.2

I updated xCode from 9.0.1 to 9.1. Everything was ok before, but now, I have this error when I try to build my project (with Carthage) :
module compiled with Swift 4.0 cannot be imported in Swift 3.2.2 (or 4.0.2 for SWIFT 4 users)
Don't need to let you know the module because it doesn't depend on it (because when I comment the import line concerned, the mistake his misplaced to the next import, so for another module).
I tried everything I saw :
Clean the project
Clean the Carthage folder
Clean Derived Data folder:
rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData
Update with Carthage: carthage update --platform iOS (with or not --no-use-binaries)
Update Modules
Build again
Close and Reopen Xcode
pray
Carthage (0.26.2) and MacOS (High Sierra) are up to date.
So, my last supposition (as I can read) is that Xcode 9.1 not allow us to use modules not build with Xcode 9.1. So I can come back to Xcode 9.0.1 but I will unable to deliver my project to Xcode 9.1 users. I cannot imagine to wait the update of all the modules. So do you have an idea, please ?
Thanks you !
Yes, you have to upgrade every framework you are using to 9.1.
"As I said, it doesn't depend on the module because if I comment one import, it's the import of another one who have troubles"
That's because the next one has the exact same problem. Just replace all your frameworks in the "Embedded Binaries" with versions that have been compiled with 9.1. To prove it to yourself, do it on the first one it complains about, and Xcode will then tell you the second one is now the problem, etc.

ReactiveCocoa: Xcode asking me the conversion to swift 3

Evening, I'm working with a project using cocoapods, especially with the SimpleAuth pod.
Now I can't understand why, after I installed my pods and updated them, opening the workspace I receive the warning:
While the readme of ReactiveCocoa is saying that is swift 3 ready.
Mine reactiveCocoa version is 4.2.2, the latest.
You may have to change your Xcode 8.1 toolchain to use Swift 3.0.

Resources