Why did my pod imports suddenly stop working? - swift

I use several pods including AlamoFire, Realm and SwiftyJSON. The pods and their code worked fine up until recently. Now None of my imports work, but gives me the error No such Module.
I have tried to use the command pod disintegrate in the terminal, then installed them again. I have linked them to the project in the general tab as well as the project phase tab.
I have tried following the steps here:
"No such module 'Alamofire'" Xcode won't recognize Alamofire framework
But step two doesn't seem to exist in the build settings and if I comment out all the imports I instead get another error:
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
I use swift 4.1 which is verified in the build settings. I use Xcode 9.4.1 if that helps.
Very confused about this problem since everything worked fine until it suddenly stopped.

Please check your podfile if you have mentioned explicitly version for one of the dependency
For e.g
Alamofire, ~>’3.3’
Check for the compatible version for swift 4.1 if you have mentioned explicitly version for one of the pod.
Otherwise Simply remove podfile.lock and try pod update once.
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
Select the target which uses swift
Go to Build Settings
Type Swift L in search field and scroll to Swift Language Version
Select the language version

Related

Change Swift Version Project is Built With

I'm using Vapor, and I've run into a problem where the change to Xcode 13.3 from 13.1 now means the project (without changes) will no longer build.
How can I change the version of Swift that a Vapor project will build to? Since this isn't an app, the usual convenient configuration UI isn't available, so I presume this has to be done in a configuration file, or via the terminal. Just don't know how, is all...
I think what you mean is the version of swift-tools that gets invoked rather than swift. Change the first line of Package.swift in your project's folder to use the current version needed by the latest vapor version 4:
// swift-tools-version:5.5
Then use Xcode to try to build. If this doesn't work, try Using the Clean Build Folder menu option off the Product menu and try again.
Failing this, use terminal to remove the .build folder in your project's folder and do a swift package update followed by a swift build. I know of at least one swift compiler bug that means a compile that fails with swift build will succeed with swift build -c release so it could be worth trying both.
If all this fails, include more detail in your question to show the exact cause of 'will no longer build'.

Can't build macOS project after updating to Xcode 10.2/Swift 5

My project built fine before updating Xcode.
Now however, I can no longer build the project. When using Swift 5, building the project just never finishes. It stops on "Building 70 of 100 tasks" and just never finishes. Those numbers aren't always the same, either, but it never finishes building.
If I try to use Xcode to convert my project from Swift 4.2 to Swift 5, it similarly never finishes converting.
If I try changing the toolchain to use the Swift 4.2.1 release toolchain, the code compiles successfully but I get this crash immediately at runtime:
dyld: Symbol not found: _$SBOWV
Referenced from: /Users/compc/Library/Developer/Xcode/DerivedData/Swift_Coder-hczsehpbafcwkfgwyameucznmhsp/Build/Products/Debug/Swift Coder.app/Contents/MacOS/../Frameworks/SavannaKit.framework/Versions/A/SavannaKit
Expected in: /usr/lib/swift/libswiftCore.dylib
in /Users/compc/Library/Developer/Xcode/DerivedData/Swift_Coder-hczsehpbafcwkfgwyameucznmhsp/Build/Products/Debug/Swift Coder.app/Contents/MacOS/../Frameworks/SavannaKit.framework/Versions/A/SavannaKit
I've tried cleaning the project and deleting derived data but neither seems to work.
The project continues to build and run perfectly fine if I use Xcode 10.1.
I had problems with some of my code involving extending the ClosedRange type to Encodable and Decodable in a custom way. In Swift 5, ClosedRange already conforms to Encodable and Decodable when its Bound is Encodable and Decodable, but the compiler wasn't giving me an error about the redundant conformance, instead just hanging on compilation.
After I modified my code to use the new Swift 5 protocol conformance, it compiled fine. It took a long time to narrow down the problem to this, however. It seems to me to be a bug in the Swift Compiler because the compiler hangs in a Playground or from the command line as well, even on a different Mac.
Do your project contains any third libraries? If so, try to figure out which one is outdated. Try to build project without this libraries, i'm perfectly sure some of them are just outdated. You may also want to set up swift language version to old one. Select the target, goto Build Settings > Swift Language Version
Please delete Derived Data,
You can go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment. Then click over the little grey arrow under Derived data section and select your project folder to delete it.
if you have Pods Than deintegrate and reinstalling all pod files again.
Hope this works for you!
Disable iCloud.
The problem was caused by discrepancies between desktop and icloud!
Spent 24h trying to find why workspace would freeze at launch.

Cocoa pod installation error: " The target overrides the SWIFT_VERSION build setting "

I'm trying to install Cocoalumberjack as a pod and am getting this error:
The ProjectName [Release] target overrides the SWIFT_VERSION build
setting defined in `Pods/Target Support
Files/Pods-ProjectName/Pods-ProjectName.release.xcconfig'. This can
lead to problems with the CocoaPods installation
The pod xcconfig file contains this:
SWIFT_VERSION = 3.0
But my project is already using swift 3. so I don't understand why there's this mismatch.
xcrun swift -version
Apple Swift version 3.0 (swiftlang-800.0.46.2
clang-800.0.38)
However I cannot see a SWIFT_VERSION in particular anywhere in Xcode's build settings, nor if I type in swift as the search term in the Xcode's build settings can I see anything anywhere that even looks like a swift version number
Additionally the pod installation goes on to say:"Use the $(inherited) flag" to solve the problem.
However my Xcode build settings other linker flags already has this $(inherited) flag, so why is that not solving the problem?
(Xcode 8)
It is a bit non-intuitive but what you have to do is:
1) Search for "SWIFT_VERSION" in your project settings
2) you will see an entry saying "Use Legacy Swift Language Version"
If you had already selected any value it will be shown in BOLD
3) Select the entry (not the value) and press "DELETE", the boldness should disappear.
4) Repeat the same steps but now for your target (the one with the app icon)
5) Close XCode
6) Run "pod install" again
7) Open your project, and CLEAN IT (Shift + Command + K)
Now it should be working correctly.
NOTE:
Specifically for "Cocoalumberjack" make sure your pod is installing the 3.0+ version, if its not run a "sudo pod update" as versions previous to this won't work with Swift 3.
EDIT:
I'm pretty sure the cocoapods handling of this is a bit buggy at the moment, as I've experienced sometimes it works and others it doesnt. However, keep in mind you can set the "SWIFT_VERSION" flag directly on a per framework basis:
1) Select the Pods project (within your project).
2) Select the target that you want to set and look for the "SWIFT_VERSION" flag specifically for that target.
3) Clean and rebuild.
You need to remove any overridden "Use Legacy Swift Language Version" build setting from your targets.
That is not exactly helpful as there is no way to remove it.
You either inherit the value, or you assign a value, and there is no way to get back to $(inherited) value after an assignment due to the way the UI is built on xcode (on some options you have a "custom" value where you can add this, but not on all kinds of values).
So it's kind of a dead end with no real solutions.

Xcode 8 Beta 3 Use Legacy Swift issue

I have an Objective-C project in Xcode 8 Beta 3. Since updating, whenever I try to build I receive the following error:
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
Has anyone encountered this? Since it's an Objective-C project there's no build setting to configure Swift. I have also made sure none of the project dependencies or CocoaPods are using Swift. The only solution I have is to use Beta 2. Any ideas how I might fix this issue?
I should also mention I'm running OSX 10.12 Beta 2.
If you are using CocoaPods and want it to be fixed automatically every time you are doing a pod install, then you can add these lines to the end of your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
EDIT: This problem is now fixed if you use CocoaPods v1.1.1 or later.
Don't forget to remove the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES setting from your main project targets.
I just found a way to fix it.
Go to the Build settings of the project or library and set the Swift Compiler Version attribute "Use Legacy Swift Language Version" from Unspecified to Yes or NO.
I have been ignoring this problem for a while now and just working on other stuff in the meantime - I finally found the solution to my problem.
Since my project is Objective-C I figured maybe one of the Pods I am using was using Swift, I checked each Pod and none of them were.
The final solution was that my Core Data model was set to generate code in Swift even though I have been manually generating them in the File > New > NSManagedObjectSubclass menu. All I had to do was switch it to Objective-C.
This issue is also visible in Xcode-8.1 . When we add new Target like Extension or Widget and Third party library is integrated in new target with the help of cocopods. After Pod install . We can face same error as above .
Change the Use Legacy Swift Language Version in every Library Build Setting to
No.
If you are using Xcode 8 or later
Go to Build Settings
Find use legacy swift language version
Yes - Swift 2.3
No - Swift 3.0
Add below code in end of the podfile.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
I'm working on a project which has mixed objective-c and swift code
I previously used swift version 2.3 and after upgrading to swift 3 I was unable to build the project. Xcode complained with the mentioned error message.
Apparently, there was still some outdated Swift version specified in my project.pbxproj file. There was swift 3.0.1 specified:
SWIFT_VERSION = 3.0.1;
Whereas, I already had 3.0.2 installed:
$ xcrun swift -version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Sooo, I fixed it by changing the Swift version in the project-pbxproj file to:
SWIFT_VERSION = 3.0;
Seems the patch level version specifier was too specific.
In my case I have Just do the Following things
Choose project Target=>Go to Build setting=>Search for “Swift Language Version” =>give Value the current Swift version
Thats all It has fixed my Issue
I got the same error. I tried for searching "Use Legacy Swift Language Version", but not found. I am using Xcode 8.3.3
After surfing too much and working around i found this solution, and this worked for me.
Here are the steps.
1=> select your target from Xcode
2=> go to build setting
3=> search for "Swift Language Version"
4=> change it to swift 3. (or accordingly.)
set "Use Legacy Swift Language Version" to "YES" if you using a old version of swift in your project or any swift 3rd party. "No" if your project uptodate to current swift version.
if you don't configure your swift version , after every update and Install, Pod framework need to specify this.
I actually had to do a search for "Legacy Swift" to be able to change it from unspecified to "Yes" When I simply scrolled down to the section described above, I was not able to change it. I hope this will help someone.
My project is written in Swift. I got that same error with fastlane. What happened was my Xcode auto-updated so I had to update my project to Swift 3.0. Got a ton of errors. Fixing and debugging was taking too much time and it was not worth it at that moment so I decided to install an older version of Xcode. Reverted my code to 2.3. Then fastlane beta wasn't working anymore. Turns out, I needed to set the Command Line Tool to 7.3.
I was having this same issue and solved it by doing the following:
In Project > Build Settings:
Always Embed Swift Standard Libraries = $(inherited)
Use Legacy Swift Language Version = YES
Then in my Podfile:
config.build_settings['SWIFT_VERSION'] = '3.0'
Using these three settings removed all warnings and allowed me to compile properly.
The most obscure and what actually got progress for compiling was changing the SWIFT_VERSION in the Podfile from 3 to 3.0 as suggested here.
From XCode 8 onwards, you can use swift 2.3 even though XCode 8 uses swift 3.x as default swift version. To use swift 2.3, just turn on flag Use Legacy Swift Language Version to YES from Build Setting, then XCode will use Swift 2.3 for that project target.
Before trying complicated solutions, here is a basic check you need to do if you are new to Cocoapods and you are having this issue.
You might need to:
Open your Podfile again
Check that the line for platform is not commented out with a '#'. It should finally look like something like :
platform :ios, '10.1' # Put the right version and no #platform here
use_frameworks! # For swift
pod "MyPod" # Your mean pod :)
Save your Podfile, Close Xcode, and Run pod install again
Open your project.xcworkspace
Maybe it's just that.
If not, you can go above ;-)
I had this same problem after updating to xcode 8.3.2 but the option "Use Legacy Swift Language" was gone. This seems to be the option to change now:
Used this fix with Alamofire and other libs and all works ok.
Go to Project Build Setting for project and Target do below two.
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
And
Swift Compiler - Version = Swift 3
Change to latest Swift 3.
Error resolved.
If it's resolved your error fix, please like it.
In Xcode 9 beta. Go to Project Settings, Build Settings, search for Swift Language Version. In Xcode 9 you must specify if you are using Swift 3.2 or Swift 4.
If you change ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO still not work, it is because the xcode issue, not your problem. Doing the follow steps:
1.Change ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES property to be YES on the warning target
2.then it will show an warning on left bar which recommend you change to swift 3.0
3.then change back to NO. Rebuild the project, the xcode finally detect your change to NO!
Problem solved in this case!
Just need to check the following settings
File -> Workspace setting ->
1 - Check "Don't show a diagnostic issue about build system deprecation"
2 - set Build System to Legacy Build System (Shared Workspace)
3 - set Build System to Legacy Build System (Pre-User Workspace)

Getting dyld_fatal_error after updating to Xcode 6 beta 4 using swift

I just recently downloaded Xcode 6 beta 4, and my swift project compiles with no errors but before it gets to my code I get a dyld_fatal_error just above start in the call stack.
and a breakpoint in some assembly code with a nop instruction
The console error I get is
dyld: lazy symbol binding failed: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
dyld: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
Just so you know the project still compiles, and runs fine with Xcode 6 beta 3.
Most extremely weird problems like this can be solved with a Clean & Build (or perhaps relaunch Xcode). You might also consider deleting the relevant folders from ~/Library/Developer/Xcode/DerivedData.
For sure this error is very unhelpful:
dyld`dyld_fatal_error:
-> 0x1200ad088 <+0>: brk #0x3
This of course occurs only on device, not the simulator. Another good reason to always test on a device.
Anyway, having had the same issue, a clean didn't work for me. Deleting DerivedData didn't help either. Also tried synchronising the Deployment Target versions. That didn't seem make any difference but I did it anyway.
Solution was to add any dynamic frameworks to Embedded Binaries setting under Target -> General:
Now I know that has been mentioned in other answers. However, if I can supplement by saying that any dependent dynamic frameworks must also be included.
So for example if you have a dynamic framework A that depends upon dynamic framework B, then it's necessary to have A and B added to Embedded Binaries.
Note that if the dynamic framework A depends upon any static library or framework, you will almost certainly be forced to create A as an umbrella framework that includes the dependant binaries.
Other considerations that may or may not be important. However did personally for me result in success were;
paths of each dynamic library in the Inspector were set to "Relative
to Group". In the screen grab above the path of the embedded binary
appears correct terminating with "build/Debug-iphoneos".
dynamic frameworks are in embedded binaries section. Static libs and
static libs wrapped up as frameworks are in Linked Frameworks
and Libraries. Nothing appears in both sections.
In setting this up XCode behaved strangely. The following proved successful:
Add the dynamic framework to the embedded binaries.
Find the new framework in XCode groups on the left and update the path to be
"Relative to Group" as described previously.
Delete the dynamic framework from embedded binaries.
Add the dynamic framework to the embedded binaries again. The path should now appear correctly.
Delete all references to the dynamic framework from the Linked Frameworks
and Libraries section.
I have just had this problem trying to link a custom iOS framework to my project, so for anyone out there who has this problem, it's to do with the copy files build phase.
I think that this error results when a file cannot be found. So create a copy files build phase in the appropriate target in your project. Then add the file (in my case the custom framework) to this phase (if it's a framework make sure to select the 'Frameworks' destination).
Cleaning, restarting, deleting etc didn't work for me.
I have a project containing another project. When I ran the project on iOS 7 and the contained project was accessed in code, the app stopped at the line below:
After many days, I saw that the deployment target for the container project was 7.0 (as can be seen below).
The contained project on the other hand, had a deployment target of 8.1 (as can be seen below).
Changing the deployment target of the contained project to 7.0 solved my problem!
The project was working fine on iOS 8 devices.
I had this issue recently and the problem for me was that I had added a library from the same project which wasn't listed in 'Embedded Binaries' from the 'General' section.
NOTE: If you add it in Embedded Binaries it will also add to the Linked Libraries section, possibly adding the same one twice.
Clean and build won't work. You'll need to delete he cache in ~/Library/Caches/com.apple.dt.Xcode* directories. Delete these and rebuild.
Do this every time you upgrade the beta.
I also faced the same issue and tried all the solution given above without any luck.
then what I have done to resolve that I really don’t have much I idea about. So there is Certificated called “apple worldwide developer relations certificate authority” in System group in keychain Access and due to some profile and certificate issue I randomly mark this certificate “Always trusted” from “Use System Defaults”. So this is causing this “dyld_fatal_error” crash to me. when I revert it back to “Use System Defaults” crash got resolved.
So guys if you are tried all the possible option to resolve this crash and didn’t succeed yet, try this also. It helped me, may help you as well.
Found this about this certificate.
This problem still occurs in Xcode 7, and it can happen for a variety of reasons (it seems). In my case, the iOS app with an included framework:
ran on the simulator fine
gave the error you described on the device
The answer was to NOT use linked libraries but rather Embedded Binaries under General.
Also see here: https://stackoverflow.com/a/34052368/8047
Adding the non-system Framework to "Embedded Binaries" inside the general tab of the main project worked for me.
As stated by bitwit, this will also add your framework to "Linked Frameworks and Libraries", so watch out for those duplicates.
Tested with Xcode 7.3.
Xcode 8.
Clean and build didn't work. I deleted the cache, deleted Derived data. After that, my pods configuration was broken, so i needed to install pods again. Pods Target configuration was set to a very old Valid architectures. setting to armv7 and armv7s, was ok to compile and no problems
You'll get this if your scheme has "Guard Edges" enabled in diagnostics when running on an actual device. "Guard Edges" only works in the simulator.
I was using cocoapods and had this problem as well when I updated to deploy target iOS 8 and added use_frameworks! to my Podfile. I was able to fix it by adding the following line to my Podfile:
link_with 'TargetName1', 'TargetName2', etc.
Might work with ProjectName as well