Deleted Xcode 9 beta, Swift Compiler Error - ios

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.

Related

Apple Mach-O Linker Warning, in xcode 9.4

I update xcode version 9.4 to 10.2.1, I have created a project on xcode 9.4, run it once on xcode 10.2.1 and then delete this version and switch back to xcode 9.4 due to some reasons ... when I tried to run project on xcode 9.4 it gives lot of warnings and 198 errors
how to solve this issue.
If it's only linker errors, try to clear derived data on Xcode (Which you can access from Xcode > Preferences > Locations) and run application after clean and build. Some times your lesser disk spay might caused to these kind of issues as well.
When you opened the project on XCode 10.2.1 did you allow the project to be updated to the "recommended settings"?
It would have appeared as the yellow yield icon in the issues log.
A possible solution is to go into Time Machine (hopefully you keep backups) and revert your project folder to a copy from before you updated XCode

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.

Xcode 9 Bug: Cannot find cdtool

After installing Xcode 9 beta, Xcode 8 gives me an error when compiling a project:
Cannot find cdtool at '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Agents/cdtool': Cannot find a simulator runtime for platform <DVTPlatform:0x7fd67af0a930:'com.apple.platform.iphonesimulator':<DVTFilePath:0x7fd67af0a7c0:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform'>>.
I suspect Xcode 9 modified some shared state with Xcode 8 (set a path, overwrote a file, etc.). But I've tried deleting and both Xcodes to no avail.
The project uses Core Data and it's clearly failing when trying to compile the xcdatamodel.
I can still compile and run under Xcode 9.
An Apple engineer reached out about this...
Those of you with cdtool errors in Xcode 8, I suspect you installed the iOS 10.3 Simulator runtime from Xcode 9. It was discovered this week that this causes a problem with cdtool in Xcode 8.3.
You can work around that by moving iOS 10.3.simruntime aside and restarting CoreSimulatorService (source):
sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/Backup
sudo mv /Library/Developer/CoreSimulator/Profiles/Runtimes/{,Backup/}iOS\ 10.3.simruntime
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
Then restart Xcode, Simulator, etc. Those of you that deleted CoreSimulator.framework and thus cannot run Xcode.app any more can reinstall CoreSimulator.framework with:
installer -pkg /Applications/Xcode-beta.app/Contents/Resources/Packages/XcodeSystemResources.pkg -target /
Didn't work for me because I also have a Watch app and got the error on the Watch SDK.
I ended up deleting both Xcode 8 and 9 Beta, deleting /Library/Developer and ~/Library/Developer. Then reinstalled Xcode 8 and it worked.
You can also remove the 10.3 folder from
/Library/Developer/CoreSimulator/Profiles/Runtimes
Restart Xcode in order to take effect (may not be needed).
I agree with this answer. In addition I first removed all existing(took backup) Xcode version from machine.Then kept xcode 8.3.3 in Application folder. Made the project to open with default Xcode 8.3.2. Problem got resolved.
The problem came when I updated Xcode 9 beta to 9.2.

Swift does not support the SDK 'iPhoneSimulator9.3.sdk'?

I have just installed the xcode 8.0 and upgrade my project to swift 3. I was using swift 2.2 and xcode 7.3.1.
But getting following error:
Swift does not support the SDK 'iPhoneSimulator9.3.sdk'
Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
failed with exit code 1
This happened to me when I had simultaneously installed both Xcode 7 and 7.3 and after automatic update I was left with 8.0 only.
One indication that something got messed up was output of xcodebuild -sdk -version in terminal:
DVTSDK: Warning: SDK path collision for path '<DVTFilePath:0x7fd810db4c50:'/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk'>': SDK with name 'watchos3.0' being superceded by SDK with 'watchos3.0'.
Solution:
Quit Xcode
go to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
remove the iPhoneOS9.3.sdk folder from that directory. Be sure to make an external copy if you still need it so you can put it back later.
restart Xcode, clean, and build
???
PROFIT
UPDATE:
According to #tsafrir comment, delete also 'iPhoneOS9.3.sdk' for simulator folder:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhon‌​eSimulator.platform/‌​Developer/SDKs
The iPhoneOS9.3.sdk for the simulator is at Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs.
quit xcode
delete
clean
build again.
Not the best solution, but selecting - "Use Legacy Compiler Version": Yes, removed that warning for me.
It happen due to old xcode still in system and you updated new one.
For fixing this use following step.
Quit Xcode
go to
Simulator and iPhoneOS. platform
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
3. remove the iPhoneOS9.x.sdk folder from that directory. Be sure to
make an external copy if you still need it so you can put it back
later.
Copy old xcode sdk (iPhoneOS9.x(Updated SDK))
Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ iPhoneOS9.3(Updated SDK)
5> Paste this SDK in new XCODE 8 in this folder
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
6> Clean and Build.
Fixed
Open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs

Issues rebuilding alamofire with iOS 10

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.

Resources