I have an old Swift app that was building fine on XCode 10.3 (OS: 10.15.7), but after upgrading to latest MacOS (12.4) and XCode 13.4 I get "No such module: 'ObjectMapper'" when trying to build.
I am using Carthage for dependency management and Carthage update appears to work, e.g:
carthage update --use-xcframeworks --platform iOS.
Here is the line in Cartfile for ObjectMapper:
github "Hearst-DD/ObjectMapper" ~> 4.2
Here is the "Link Binary With Libaries" section in Build Phases:
In the Run Script section: /usr/local/bin/carthage copy-frameworks
It has been a while since I last did XCode or Swift development, so I am probably missing something obvious.
Help solving this would be much appreciated.
Related
After Xcode auto update to version 13.2.1, I can't build project with Carthage dependencies manager.
With one framework got from here: https://gitlab.com/trustpayments-public/mobile-sdk/ios
I get the error following:
Module compiled with Swift 5.5 cannot be imported by the Swift 5.5.2 compiler
I tried rebuilding framework and set Build libraries for distribution flag in project settings to No but it returned the error that bridging headers are not allowed.
Any ideas ?
P.S. I managed to build the app with CocoaPods, but environmental requirements force me to remain with Carthage in my iOS project.
OK, I managed to compile my project.
Steps to do:
Remove ../Carthage/Build folder
Run xcodebuild -version and check is it the newest one.
Run carthage build --platform ios --use-xcframeworks --no-use-binaries
My project was running perfect with xcode 11.4.1 but when i tried to run project xcode 12.1. I got error "Module compiled with Swift 5.2.2 cannot be imported by the Swift 5.3 compiler with xcode 12.1".
Please see attached image. Thanks!
https://i.stack.imgur.com/39k04.png
I had faced same error in Razorpay integreation in a project. I have down grade my xcode version to the supported swift version and the error gone.
Please suggest any other option, if you found. Some thing which does not require to down grade xcode version and works.
I have fixed this issue via remove Carthage from project and added all those modules which was in Carthage via pod and manual add BuckoNetworking files in the project because BuckoNetworking was not available in pod. Import all module in BuckoNetworking files which needed to that files to run project.
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:
I have an application which was developed in Xcode 7.3 and Swift 2. Now I am trying to convert it to Swift 3.0.2, as the dependency manager I am using is Carthage. Now I am updating my Carthage so that all the frameworks should support swift 3.0.2. For this, first I have used the following command:
"carthage update --platform iOS"
It now fetches all the dependencies and check out all the dependencies but then after checkout it starts to build the dependencies and while building the dependency it just fails with an error.
Here is a attached screenshot of the error. I am totally blank on what I am missing in this case:
When I faced the problem , this is how I resolved it:
I deleted everything that was checked out and got all new fetches and builds
Ran carthage update --no-build && carthage bootstrap
This problem mainly occurs in Xcode 7.3 beta2 (7D129n) toolchain. Carthage version0.12 will build the cartfile successfully if you set xcselect to 7.2.1.
Version v0.11 didn't have this problem. The problem occurs during the build, maybe because all the versions of Carthage dependencies don't match too. I also read a few posts which asked me to supply with sudo carthage update --platform iOS --no-use-binaries.
And you're using a really old version of Xcode. I'll suggest you to upgrade.
I ran carthage bootstrap --platform iOS and got "Skipped installing realm-cocoa.framework binary due to the error: Incompatible Swift version - framework was built with 3.1 and the local version is 4.0", and then at the end of the build I got a full on "Build Failed: Task failed with exit code 65" error.
It points me to the derivedDataPath, and I checked the xcodebuild log for more details where it let me know "PhaseScriptExecution Download\ Core\ and\ Sync /Users/user/Libary/Caches/org.carthage.CarthageKit/DerivedData/9.0_9A###/realm-cocoa/v2.10.2/Build/Intermediates.noindex/Realm.build/Release-iphoneos/Realm.build/Script-X#X#X#X#X.sh (1 failure)".
But I'm still not totally sure what exactly is happening with Realm Cocoa, or how to fix, do you know?
TL;DR: Ensure you're using the latest Swift version, included with Xcode, and then perform carthage bootstrap --no-use-binaries --platform iOS --cache-builds
Long version:
The error you got from Xcode while building your project, Incompatible Swift version - framework was built with 3.1 and the local version is 4.0, is due to a download performed by Carthage to get a pre-built version of Realm Framework (this is a time-saver feature but sometimes there are version incompatibilities like this one).
This downloaded pre-built framework was compiled with a previous version of Swift (in this case the error is pointing v3.1 was used.) The solution for this error will be to perform the dependencies installation process using a different command:
carthage bootstrap --platform iOS --no-use-binaries
This will work for the project dependencies build to succeed. Anyway this might take a long time since it will build from scratch the Realm.framework and RealmSwift.framework from the core every time the command is executed. So it is possible to enable a local cache for the builds on Carthage. The dependencies can be installed with
carthage bootstrap --no-use-binaries --platform iOS --cache-builds
With this options Carthage will:
bootstrap, so the versions in the Cartfile.resolved will be used, no updates.
--no-use-binaries build the dependencies with no downloads of pre-built frameworks (avoiding the version incompatibility.)
--platform iOS will build the dependencies for be used only on iOS, avoiding building frameworks for Apple TV or Mac OS in case the dependency supports it. This will cut a lot of time!
--cache-builds will enable Carthage to store your built dependencies (and use it when re-needed) on a local cache, so even if you perform the command again it will just copy your stored framework, avoiding another time consuming build process.
Check your application folder and Switch your Xcode version to older version with swift 3.
sudo xcode-select --switch /Applications/Xcode.app