I'm working in a specific Xcode project and deliberatly making errors in my code (like using undeclared variables), but Xcode doesnt seem to show any compile errors in my code.
It shows errors only when its build or clean.
Tried clean and build, cleaning derived data and restarted both Xcode and system, none of it works.
Using Xcode 8.2.1 (8C1002) and Swift 3
Besides the DerivedData folder, also try cleaning Xcode caches completely:
rm -rf $HOME/Library/Caches/com.apple.dt.Xcode/
I would recommend also killing the SourceKit process — always a source of issues these days! — but since you are already did a full reboot, so looks like you are good there.
If everything fails, you might consider upgrading to the latest Xcode, version 8.3. Just be aware that:
Xcode 8.3 no longer supports Swift 2.3. Please migrate your projects containing Swift 2.3 code to Swift 3 syntax by opening the project and choosing Edit > Convert > To Current Swift Syntax.
Project Settings, "Show all issues" fixed it for me.
For me, I had to first ensure all of my Xcode Targets had valid Signing & Capabilities like a development Team selected... then I was able to update all of my Targets to Swift 5 using the warning that was presented to me. Immediately after all of the targets were all updated to Swift 5 and the Provisioning was fixed, the red errors were flagged again!
I had the same problem using Xcode 13.3 with Swift version 5.5
Upgrading to Xcode version 14.1 (14B47b) which also upgrades Swift tools to version 5.7.1 fixed the problem.
Related
I have recently updated to Xcode 13.2 from the Mac App Store. While trying to fix an issue with a Swift package, I uninstalled it and now I cannot reinstall the package.
When I try to add a package from GitHub the process hangs immediately on "Preparing to validate".
I already attempted to restart Xcode, restart my mac, clean derived data, reset Swift package caches and update package versions to no avail.
Is there any way around this issue?
Check https://developer.apple.com/forums/thread/696504 and re-download Xcode 13.2 directly from the releases section of the Apple Developer website: https://developer.apple.com/download/release/
Make sure to update Xcode to 13.2.1
They have just released the update that should fix it. See in the link that #mikeyh posted in the other answer: https://developer.apple.com/forums/thread/696504.
I'm on Xcode 13.4.1 and ran into this same problem when trying to convert my project from CocoaPods to SPM packages because I was using the Legacy Build Location setting. When trying to install any package it would immediately hang on "Preparing to validate..." just like in the screenshot of the question.
I did get an error stating something like the package could not be added because of using the Legacy Build Location setting, however I did not notice this in the Issue Navigator for a while because once I removed all of my CocoaPods and before I could add the SPM packages I was getting hundreds of build errors.
To fix (if your project can use the default Build Location setting) is to set it by going to
File->Project Settings...->Advanced...->Xcode Default
After updating iPhone to iOS 12.2 I encountered this error in Xcode 10.1:
“This iPhone is running iOS 12.2, which may not be supported by this
version of Xcode.”
So I have to update Xcode to latest version and after updating Xcode to 10.2, when I open the project, Xcode show another error that say:
Unsupported Swift Version
“MyProject” contains source code developed with Swift 3.x. This version of Xcode does not support building or migrating Swift 3.x
targets.
Use Xcode 10.1 to migrate the code to Swift 4.
Now I couldn't run the project correctly in neither Xcode 10.1 nor 10.2!
I think I have to update my code to Swift 5 to Xcode 10.2 be able to compile the code. Am I right?
But updating the whole project is overwhelming.
Is there any other way to resolve the problem?
The situation is neither dire nor daunting. All you really have to do is open the project with Xcode 10.1, mark the code as Swift 4, and close the project again. It would be good to migrate the code to Swift 4, though you don't have to; if you do, you certainly don't have to run it on a device — all you need to do is compile it as valid Swift 4. And the migrator will help you do that.
You will then be able to open the project in Xcode 10.2 and proceed however you like. Optimally you would then migrate again, to Swift 5, but you can postpone that step if you like.
But updating the whole project is overwhelming.
That is a matter of opinion, really. And after all, you got yourself into this situation by not migrating out of Swift 3 earlier (you have had literally years to do that, but you didn't), and by updating the system on your device.
Is there any other way to resolve the problem?
Not given your specifications. If you wish to run on this device that you have updated, you must update to Xcode 10.2, and you can do that only if you migrate out of Swift 3, which you can do with Xcode 10.1.
Open Xcode and change the project's Swift version to the latest (it'll say "unspecified").
Also update your project's Build Settings Library Search Paths to include this at the top:
$(SDKROOT)/usr/lib/swift
I have same issue while migrating code from Swift 3.x to Swift 4+.x :
Try to check two main things :
Target and project setting swift version should be 4.2 or swift 5 ( in case of XCode 10.2)
change build system.
None of the referenced answers works. Something new has happened with Xcode 10.2
This happens whether or not I use Swift 4.2 or 5.
It happens immediately with a brand new, unedited command-line tool.
All you need to do, is create a MacOS command-line tool, and hit "run."
You immediately get this error.
Nothing I have done so far has fixed it.
From the Swift 5 Release Notes for Xcode 10.2:
Swift 5 Runtime Support for Command Line Tools Package
Starting with Xcode 10.2, Swift command line tools require the Swift libraries in macOS. They’re included by default starting with macOS Mojave 10.14.4. In macOS Mojave 10.14.3 and earlier, there’s an optional package to provide these runtime support libraries for Swift command line tools that you can download from More Downloads for Apple Developers. If you installed the beta version of this package, replace it with the release version. This package is only needed for Swift command line tools, not for apps with graphical user interfaces.
Note that:
This is only necessary if you are still on macOS 10.14.3. As soon as macOS is upgraded to 10.14.4, the Swift runtime libraries are provided by the operating system, and command line tools created with Xcode 5 run without the need to install the “Swift 5 Runtime package.”
On macOS 10.14.3 with Xcode 10.2 you must download and install the latest “Swift 5 Runtime package.” An earlier package which you might have installed with an Xcode 10.2 beta release does not work.
Early versions of the Xcode 10.2 beta release notes recommended to add a user-defined setting SWIFT_FORCE_STATIC_LINK_STDLIB=YES as a workaround, that is no longer necessary.
This issue happened because I update XCode to 10.2 without updating the MacOS to the latest and the sdk that I used also not updated. Apparently these steps had solved my issues :
Update your MacOS the latest
for my case even updating all the required updates not solving the crash issue. In that case don't forget to check if your affected SDK/framework already rebuild from the latest XCode (10.2), since The problem went away after I rebuild the SDK with the latest XCode (10.2).
For my case, we used jenkins to release the app, if the cloud still using old xcode and os, the .ipa will still crash. Need macos and xcode on jenkins cloud to be also updated.
Because updating the cloud will affect everything (near the release date) so either I roll back the os and xcode, or I use the old sdk/framework (before rebuild state). But using the second option will make it crash on simulator but atleast no crash issue if release the app.
I updated my macOS as was suggested, but it did not help without the following change in the Package.swift:
- // swift-tools-version:4.2
+ // swift-tools-version:5.0
I've a project that uses Swift 4.1, Cocoapods and has some unit tests. These tests were visible on Xcode 9.3, after I updated it to Xcode 9.4 the test navigator gets stuck and even deleting the derived folder, cleaning the project, reinstalling the software and restarting the Mac does not solve this issue. Must be a misconfiguration on the project (but I didn't change anything).
Any idea what I can do?
(Image has been resized)
Managed to solve the issue:
Simply uninstall all entries of Xcode following this answer this answer and install Xcode 9.4 again.
I came across this issue with Xcode 10.2.1 and solved it by making sure all my code was checked in and pushed, then creating a new sandbox (I'm using git).
That was easier than trying to figure out what Xcode files were causing the issue.
Check if you have disabled xcode indexing. if you have delete it using the terminal command
defaults delete com.apple.dt.Xcode IDEIndexDisable
Then restart your xcode. It worked for me.
When I build my project (any project, really - I tried creating a new empty project with the same results), it builds fine with GCC 4.2 under either Xcode4 or Xcode 3.2.4.
If I build using LLVM 2.0 under Xcode4 or with LLVM 1.5 under Xcode3, I get compile-time build failures, but only when building for the Simulator.
The build errors that I get under LLVM are all in headers over which I have no control, such as UIView.h, UIDevice.h, UIApplication.h, UITextView.h and UIWebView.h in UIKit and CGPDFContext.h in CoreGraphics.
Here's an example error, in WebView.h:
#property(nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0); //<--- Unknown type 'UIDataDetectorTypes'
when UIDataDetectorTypes is indeed declared in UIDataDetectors.h which is included in that file.
sniff
Might be a bug in Xcode 3.2.4 or the SDK configuration.
Try placing a line like one of these in your Build Settings Preprocessor Macros:
-D__IPHONE_OS_VERSION_MIN_REQUIRED=040100
or
-D__IPHONE_OS_VERSION_MIN_REQUIRED=030103
It sounds to me like your installation is borked.
When you installed Xcode4 did you make sure to install it to a completely separate directory to your existing Xcode install?
It could also have something to do with your include paths or something in that vein. I'm not too sure how to go about fixing that.
I would suggest backing up any custom templates etc. and running the uninstall script for both Xcode 3.x and 4, and then reinstalling to see if that fixes the issues.
Does this issue persist with XCode 3.2.5?
Just curious since I haven't downloaded it yet.