问题
I just did the last Xcode update (8.3), and I have the message :
“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.
Knowing that the "Use Legacy Swift Language Version" option has just been removed from the build settings, how can I generate my app in Swift 2.3 without doing any conversion for now ?
回答1:
In the navigator selection bar, click the magnifying glass, then search for "SWIFT_VERSION
" You will find the places in the project where you can adjust the swift version accordingly.
回答2:
You can't. XCode 8.2 was the last version to support Swift 2.3. You have to either update to Swift 3 or use Xcode 8.2.
回答3:
In My case I selected Pod and changed swift version for specific pod. This works for me.
回答4:
To programmatically change swift version of pods, you may add this inside your Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['Alamofire','OtherPod','AnotherPod'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
In Swift 4, if you are using objective-c as well,
you may turn on @objc inference so the swift project will run properly on objective-c.
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['Alamofire','OtherPod','AnotherPod'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_SWIFT3_OBJC_INFERENCE'] = 'On'
end
end
end
end
回答5:
You cannot as XCode 8.2 was the last version to support Swift 2.3. You will have to either update your code to Swift 3 or use Xcode 8.2.
回答6:
Damn you Xcode, now I have to migrate to Swift 3.0. It clearly shows up this alert on opening or building an old project with Swift 2.3 so I suggest lets migrate :( :(
回答7:
Change the Swift Language Version to supported version in Build settings
回答8:
Updated, It works for me:
Step 1: Go to your ios folder and open podfile and do below simple changes;
first change:
target 'Runner' do
use_frameworks! # <--- add this single line
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
second changes:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '3.2' # <--- add this single line
end
end
end
Step 2: Open your current working project from Xcode i.e. Go to ios folder and open yourProjectName.xcworkspace file;
Add an empty Swift file to your Flutter iOS project in Xcode and accept to add bridging header.
Step 3: Open Terminal and again install using below command;
pod install
If project already open then close it and open again i.e yourProjectName.xcworkspace file , clean and build.
来源:https://stackoverflow.com/questions/43226747/swift-language-version-swift-version-is-required-to-be-configured-correctly