I need to upgrade a project to run on swift 5 yet, the last time someone upgraded the project it was built on swift 4. So I completed the Xcode project update yet when I try and compile, some of my cocoa pods are saying they are using swift 5 but the pod themselves are not built for 5 yet. Which is causing compile errors.
So what I think I need to do is go through each pod build menu and manually set the swift version to be the last swift version that pod was built on. Is this the correct way to fix this issue? Am I going to have any repercussions from doing this?
P.S.
I found out it is ok to do this. Yet one of my pods is supposed to be built in swift 3 because it says one that one of the lines of code has been deprecated in swift 4. Ill update this when i figure out what to do in that situation but if one of you gurus wanna take the lead on this one that be great.
So yes the correct way to fix this issue is to go to each pod that can only run on a lower version of swift and manually change the swift version in the build menu. The issue i was having was when i ran the auto update code to swift 5 was that Xcode also changed all the pods to become swift 5. Since those pods could not run on Swift 5 just as of yet it caused build errors.
Also regarding my P.S. note the reason why that happened was because one of the pods commands needed to be changed to the one they updated in the installation options.
Hope this helps anyone else who would come across this issue.
EDIT:
To be even more precise with what is going on is the fact that every time I run pod install there are a few pods that get reset back to swift 5 when it should be run in swift 4. This is because the authors of the pods have not set the swift_version parameter to be the swift version the pod should be using. This causes the app to not be able to compile with build-time errors.
to fix this add this code to your Podfile and it will manually set the swift version everytime. Just remember to remove it for each pod once they are updated cause you will overwrite the creators pod swift version (if they ever think of adding it)
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'KMPlaceholderTextView' || target.name == 'TagWriteView' || target.name == 'UILoadControl'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
I am using SDWebImage for Swift in my project and I am trying to add a Blur effect to an image following the advance usage example found here.
More specifically I am trying to declare a SDImageBlurTransformer but when I start typing the option doesn't come up.
Is an image blur effect possible using SDWebImage package?
Make sure your Podfile refers to version 5.0 of the project and run a pod update. I have the code completion coming up properly on a new project using version 5.0 of SDWebImage.
Here's my Podfile for reference:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'BlurImage' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'SDWebImage', '~> 5.0'
end
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.
I updated to Xcode 8 and converted to latest Swift 3.0 syntax. I have a number Cocoapods in my project, and some are on Swift 2.3 (e.g. some older pods require Alamofire set to v3.5, which runs Swift 2.3).
I have set these Pods to Use Legacy Swift -> Yes, but when building I get the error:
Module complied with Swift 2.3 cannot be imported in Swift 3.0: /Users/....XSDK/XSDK.framework/swiftmodule/x86_64.swiftmodule
I don't use Carthage (referenced in other questions). Only Cocoapods.
Do I need to convert my project to use Swift 2.3? Or can I use Swift 3.0 in my project and still use legacy Cocoapods?
Unfortunately as Swift is not ABI Stable, you cannot combine pods like this. The reason for this is that theres the huge swift standard library that all swift pods (and frameworks, dylibs, .a, .o, etc) need to reference once compiled. the standard library is language level dependent, and you cannot include multiple copies of the swift standard libraries in a single app.
It has been a good couple months since swift 3 was released. At this point, you're probably going to want to make the jump to 3. If you find a pod that hasn't been updated to swift 3, perhaps fork it and update it and submit a pr. The author will love you! :)
There are two steps to follow to get legacy cocoapods working in your project.
1) Research the cocoapod and make sure you are installing the correct version of the cocoapod, which may not be the latest, or may be on a separate branch, for example.
$pod 'Your Cocoapod', :git => 'https://github.com/.....', :branch => 'branch_name'
2) Within the podfile, set the Swift version. You can also do this manually in the build settings of each pod, but this code sets it automatically.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3' # or '3.0'
#config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
end
end
end
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)