Programming

Xcode 8 Beta 3 레거시 스위프트 사용 문제

procodes 2020. 5. 8. 21:40
반응형

Xcode 8 Beta 3 레거시 스위프트 사용 문제


Xcode 8 Beta 3에 Objective-C 프로젝트가 있습니다. 업데이트 후 빌드 할 때마다 다음 오류가 발생합니다.

Swift를 사용하는 대상에 대해 "레거시 스위프트 언어 버전 사용"(SWIFT_VERSION)을 올바르게 구성해야합니다. [편집> 변환> 현재 Swift 구문으로…] 메뉴를 사용하여 Swift 버전을 선택하거나 빌드 설정 편집기를 사용하여 빌드 설정을 직접 구성하십시오.

누구든지 이것을 만난 적이 있습니까? Objective-C 프로젝트이므로 Swift를 구성하기위한 빌드 설정이 없습니다. 또한 프로젝트 종속성이나 CocoaPod가 Swift를 사용하지 않는지 확인했습니다. 내가 가진 유일한 솔루션은 베타 2를 사용하는 것입니다.이 문제를 어떻게 해결할 수 있습니까?

또한 OSX 10.12 베타 2를 실행 중임을 언급해야합니다.


CocoaPods를 사용하고 있고을 수행 할 때마다 자동으로 수정 pod install되도록하려면 다음 행을 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

편집 : CocoaPods v1.1.1 이상을 사용하는 경우이 문제가 해결되었습니다. ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES기본 프로젝트 대상에서 설정 을 제거하는 것을 잊지 마십시오 .


방금 해결 방법을 찾았습니다.

프로젝트 또는 라이브러리의 빌드 설정으로 이동하여 Swift 컴파일러 버전 속성 "레거시 스위프트 언어 버전 사용"을 지정되지 않음에서 예 또는 아니오로 설정하십시오.

여기에 이미지 설명을 입력하십시오


나는이 문제를 잠시 무시하고 그 동안 다른 것들을 연구하고 있었고 마침내 내 문제에 대한 해결책을 찾았습니다.

내 프로젝트는 Objective-C이기 때문에 내가 사용하는 포드 중 하나가 Swift를 사용하고 있다고 생각했는데 각 포드를 확인했지만 그중 하나도 없었습니다.

마지막 해결책은 파일> 새로 만들기> NSManagedObjectSubclass 메뉴에서 수동으로 코드를 생성했지만 핵심 데이터 모델이 Swift에서 코드를 생성하도록 설정되었다는 것입니다. 내가해야 할 일은 Objective-C로 전환하는 것입니다.

스크린 샷


이 문제는 Xcode-8.1에서도 볼 수 있습니다. 확장 또는 위젯과 같은 새로운 대상을 추가하면 cocopods의 도움으로 타사 라이브러리가 새로운 대상에 통합됩니다. 포드 설치. 위와 같은 오류가 발생할 수 있습니다.

모든 라이브러리 빌드 설정에서 레거시 스위프트 언어 버전 사용 설정을 다음으로 변경하십시오.

없음 .

여기에 이미지 설명을 입력하십시오


Xcode 8 이상을 사용하는 경우

  1. 빌드 설정으로 이동
  2. 레거시 스위프트 언어 버전 사용 찾기
  3. 예-스위프트 2.3
  4. 아니오-스위프트 3.0 여기에 이미지 설명을 입력하십시오

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

나는 이전에 swift 버전 2.3을 사용하여 objective-c와 swift 코드가 혼합 된 프로젝트를 진행 중이며 swift 3으로 업그레이드 한 후 프로젝트를 빌드 할 수 없었습니다. Xcode가 언급 된 오류 메시지에 대해 불평했습니다.

분명히 내 project.pbxproj 파일에 오래된 Swift 버전이 아직 지정되어 있습니다. 신속한 3.0.1이 지정되었습니다.

SWIFT_VERSION = 3.0.1;

반면, 이미 3.0.2가 설치되어 있습니다.

$ 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, project-pbxproj 파일의 Swift 버전을 다음과 같이 변경하여 수정했습니다.

SWIFT_VERSION = 3.0;

패치 레벨 버전 지정자가 너무 구체적인 것 같습니다.


내 경우에는 다음을 수행합니다.

프로젝트 선택 == 빌드 설정으로 이동 =>“Swift Language Version”검색 => 현재 Swift 버전 평가

그게 다 내 문제를 해결했습니다

이 이미지를 따르십시오


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!

참고 URL : https://stackoverflow.com/questions/38446097/xcode-8-beta-3-use-legacy-swift-issue

반응형