Issues rebuilding alamofire with iOS 10 - ios

I have an iOS app that worked great in iOS 9 but when I upgraded to iOS 10, I am getting an error with alamofire. When I build the app it says
"Module file was created using an older version of the compiler, rebuild 'Alamofire' and try again"
I have attempted to rebuild it by typing carthage update and it does rebuild the framework files but when I re-add them as embedded or linked binaries, I get the same error. How can I go about diagnosing and fixing this issue? I suspect that this isn't an iOS 10 issue in particular but more just a rebuilding that I am failing to grasp.

Change Xcode's command line tools to point to the 8 beta app:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/
See the Swift 3.0 issue on the Alamofire repo for more info.

Related

dyld: Library not loaded: /usr/lib/swift/libswiftWebKit.dylib

I'm getting this error when I run my app through iphone 6s ios version 13.1.2 but it is workin with ios version 14 and up. I tried deleting Pods, brew update, brew upgrade, brew cleanup and update my xcode to latest version but I still get this error. How to fix this error? thank you so much!
I had the same error and fixed it by going into my app in Xcode under the Project Navigator, then opening Frameworks, and deleting libSwiftWebKit.tbd. I had recently updated the deployment target to IOS 12 as well as updated the Podfile, which I think had something to do with it. I think there was a bug in an earlier version of Xcode or my Podfile settings, whereby I had to include libSwiftWebKit.tbd manually, but after recent updates, that was fixed such that it doesn't need to be included manually anymore.
I experienced the same issue and was exhausted with that because I tried different other suggestions but all were in vain. In the end, Deleting the Build folder from Xcode brought me luck.
So my suggestion will be, first of all, to try to
Delete the Build folder (Xcode > Products > Clean Build Folder) or (Shift+Command+K)
If it doesn't work then try other options.

Is Mapbox Navigation compatible with Swift 5.0

Can anyone confirm that Mapbox Navigation works with Swift 5.0 or for that matter they are still a going concern? I have now tried building the frameworks in Carthage using Xcode 11.3 and a fresh install of Xcode 11.6 on a brand new Mac running the latest OS and in both cases when trying to import framework:
Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.2.4 compiler:
According to some answers to this SO question, this happens when Developer has not yet released their app for Swift 5, although the Mapbox changelog claims they have
Have tried contacting Mapbox through every conceivable channel and radio silence. Hopefully they are still in business and supporting the software but I'm not sure.
Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.1.3
compiler:
/Users/M/Desktop/War/idaru/MapboxCoreNavigation.framework/Modules/MapboxCoreNavigation.swiftmodule/arm64.swiftmodule
This error appears because you still have a built copy of MapboxCoreNavigation on your system and Xcode is linking against it instead of building from scratch. It’s always necessary to do a clean build when upgrading Xcode.
If you encounter this error message within Xcode when building your application target, please clean your build products using Product ‣ Clean Build Folder and build again. If you're seeing this error on the command line when running carthage update, you can try cleaning your Carthage caches using the following command:
rm -rf ~/Library/Caches/carthage/ ~/Library/Caches/org.carthage.CarthageKit/binaries/

Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1

However I have recompiled the framework using the same Xcode and it still gives me this error.
Base SDK iOS 11.1 for both
Swift Language Version Swift 4.0 for both
Not using Pods/Carthage
I hope someone might know
Update:
For release versions of Xcode:
This error (and similar errors involving Swift 4.1, 4.2, etc.) will occur when opening a project with Xcode 9.1, 9.2, 9.3, 9.4, 10, etc. that uses frameworks that were built with earlier Xcode tools.
To fix the issue, update and rebuild your frameworks using Carthage ( carthage update --platform iOS), Cocoapods (pod update or pod install), or manually, with the new updated Xcode tools. The tools should be updated automatically when you update Xcode, but if not, you can follow the steps outlined below in the original answer.
You may also need to clean your project cmd + shift + k and possibly your build folder cmd + option + shift + k to get Xcode to not use cached framework builds.
In some cases you may also need to delete your derived data folder (Easily found by going to Xcode Preferences -> Locations -> Derived Data Folder
(Thanks Stunner)
For beta versions of Xcode:
See original answer below and then follow steps above.
Original Answer:
You probably still have your xcodebuild tools set to Xcode 9.0 which builds with Swift 4.0 and is incompatible with Xcode 9.1 beta's Swift 4.0.1.
Check in the terminal using the command:
xcodebuild -version
Or just go into Xcode preferences -> Locations and check/change the command line tools to Xcode 9.1. You should be set then.
My issue was due to an external framework not being compiled for Swift 4.0.2. I had added this file via Carthage, so running:
carthage update --platform iOS
And then cleaning the project cmd + shift + k and build folder cmd + option + shift + k and deleting the derived data folder (merely moving it to trash works as well) worked for me.
In my case, I downloaded xCode 11 Beta version to test SwiftUI. When i run my project, i got "Module compiled with Swift 5.1 cannot be imported by the Swift 5.0.1 compiler:..." error.
To do fix this issue. i changed xCode command line tool to new xCode 11 comment line tool. After that, you can create new xcode project with SwiftUI.
Xcode -> Preferences -> Location -> XCode command Line Tool
i hope, this will help someone who want to test with new freamework :)
Install Xcode Toolchain of specific Xcode version which was working for you from here.
An Xcode toolchain includes a copy of the compiler, lldb, and other related tools needed to provide a cohesive development experience for working in a specific version of Swift.
Open Xcode's Preferences, navigate to Components > Toolchains , and select the installed Swift toolchain.
This will let you compile and run the app for now.
I hit this issue with Xcode 10 beta, which adds Swift 4.2. My issue was unrelated to Carthage or any external dependencies.
Go to YourTarget > Build Settings > Swift Language Version for all of your Xcode targets.
Mine were all set to Swift 4.
After adding a Copy Files Build Phase, I started getting the error
:0: error: module compiled with Swift 4.1.2 cannot be imported by the Swift 4.2 compiler: /Users/user/Library/Developer/Xcode/DerivedData/MyApp-faskfrihumfcdibjxisjvbfshppp/Build/Intermediates.noindex/MyApp.build/Debug/MyAppExtension.build/Objects-normal/x86_64/MyClass~partial.swiftmodule
Command MergeSwiftModule failed with a nonzero exit code
I then set each target's Swift Language Version to Swift 4.2, which eliminated the error.
I'm not sure why the error was occuring in the first place, though, as having all targets set to Swift 4 should be equally as valid.
In my case (Xcode 9.2):
I went to Xcode Preferences > Locations > Derived Data
I then deleted the data and did a clean build and was ok.
In my case, I used CocoaPods with plugin cocoapods-binary to prebuild libraries to binaries. After I upgrade Xcode from 10 to 11, Xcode gives me this error:
Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler
I fix it by removing the /Pods directory and running pod install.
In my case, I re-compiled the framework with whatever version it was complaining about.
To recompile, run pod update or update the carthage (which ever one you're using), and build the project.
Then search for the framework in finder. Copy-paste the theFramework.framework to your project and make sure to "Copy items if needed."Build the project again and it should work.

Deleted Xcode 9 beta, Swift Compiler Error

Had been using Xcode 9 beta for a while, and then I updated Xcode 9 since now it has an official update. Then I removed the beta from my Desktop.
Now I have a problem compiling my project with the following error:
Header '/Users/sahn/Desktop/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/CommonCrypto//CommonCrypto.h' not found
I've tried cleaning the project, cleaning build folder... but that Xcode-beta.app location won't go away.
How can I fix this?
Didn't work with XCode for almost a year now, but this usually could be fixed before with
xcode-select --switch /Applications/Xcode.app/Contents/Developer
This command is used to switch the location of the XCode. Might need sudo.
Documentation is here btw : https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
It turns out that the problem was an external framework, internally uses CommonCrypto framework, and the framework was compiled previously with the Xcode Beta.
Simply fixed by recompiling dependencies.

Carthage, Xcode 9. "xcodebuild timed out while trying to read *.xcodeproj" error

Today I downloaded xCode 9 and started converting everything to Swift 3.2/4, so I can build and run my project.
As it was expected carthage complaint about some project that they could not be build, as they were not compatible with Swift 3.2/4. I had to find the versions that were compatible and build them.
I also had to use --no-use-binaries, as some frameworks are precompiled with previous versions of Swift.
I then got the following error:
xcodebuild timeout while trying to read AWSiOSSDKv2.xcodeproj
So far I was probably not getting this error, as i was downloading AWS framework precompiled. Now that carthage had to compile it locally, something was missing and was creating the timeout.
To sort it out I did the following steps:
Open the timed out project in Xcode
Do not do anything
Run "Carthage build --platform iOS"
Everything compiled without any errors. It seams that once the project is opened in Xcode, Xcode is automatically adding something that is missing and the project compiles then.
This process has to be followed after every "carthage update", as the update will download a fresh xcode project.

Resources