Programing

Xcode 9 : Swift 3.1로 컴파일 된 모듈은 Swift 4.0에서 가져올 수 없습니다.

lottogame 2020. 10. 12. 07:02
반응형

Xcode 9 : Swift 3.1로 컴파일 된 모듈은 Swift 4.0에서 가져올 수 없습니다.


Xcode 9로 업데이트 한 후 내 프로젝트 중 하나를 빌드하려고했습니다.

FacebookLogin 포드를 사용합니다 . FacebookLogin / LoginButton.swift에 컴파일러 오류가 있습니다.

@testable import FacebookCore
❌ Module compiled with Swift 3.1 cannot be imported in Swift 4.0

내 대상의 빌드 설정에서 Swift 언어 버전은 Swift 3.2 로 설정됩니다 .

스크린 샷 추가

Facebook이 포드를 업데이트 할 때까지 기다려야 할 것 같은데요? 아니면 다른 제안?

감사 !


최신 정보:

솔루션은 Swift 5 및 Xcode 11에서도 테스트되고 작동합니다.

실물:

Carthage사용하여 Swift 3.2에서 모듈을 컴파일하는 경우 터미널로 이동하여 다음을 실행해야한다고 추가하고 싶습니다 .

sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer

Xcode 9 명령 줄 도구를 사용하려면 다음을 실행할 수 있습니다.

carthage update NameOfTheLibrary --platform iOS --no-use-binaries

이렇게하면 현재 명령 줄 도구로 라이브러리가 컴파일됩니다. 약간 느릴 수 있지만 이제 프로젝트가 빌드되어야합니다.

노트

안정적인 Xcode 명령 줄 도구를 되돌리고 사용하려면 다음을 실행하십시오.

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Xcode 9는 Swift 3.2와 swift 4를 모두 이해하는 Swift 4 컴파일러와 함께 제공되며, 심지어 두 버전을 믹스 앤 매치 할 수 있습니다. 불행히도 다른 버전은 지원되지 않습니다.

언어를 Swift 3.2로 설정하더라도 Swift 4 컴파일러를 사용합니다.

cocoapods를 사용하는 경우 pod 파일 끝에 이것을 추가하여 pod가 Swift 3.2 또는 4.0을 사용하도록 할 수 있습니다.

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.2'
        end
    end
end

또는 FacebookLogin이 Swift 3.2 또는 4로 업데이트 될 때까지 팟 (Pod)의 파일을 프로젝트에 임시로 넣을 수 있습니다.

참고 : Matt의 피드백에 따라 편집 됨


빌드하기 전에 타겟을 청소할 수 있습니다. 그것은 나를 위해 잘 작동합니다.


'Alamofire'를 가리키고 몇 가지 다른 솔루션을 시도한 Xcode 9 Beta 3에서 동일한 문제가 발생하여 가장 쉬운 방법은 다음과 같습니다.

1. CMD+SHIFT+K to clean the build
2. Restart Xcode 9 <-- make sure you do this step, that's critical. `

"클린 빌드 폴더"를 수행하고 Xcode 9를 다시 시작하면 오류가 해결되었습니다. 또한 오류로 인해 앱이 내 장치 또는 시뮬레이터에서 실행되는 것을 중지하지 않았습니다.


xcode DerivedData 디렉토리로 이동 한 다음 그 안의 모든 파일을 제거하고 프로젝트를 다시 컴파일합니다. 그것은 나를 위해 작동합니다.

기본 DerivedData 디렉토리는 : ~ / Library / Developer / Xcode / DerivedData입니다.


Carthage를 사용하는 경우 터미널을 열고 ;

carthage update --platform iOS --no-use-binaries

Pod를 사용하는 경우 터미널을 열고 ;

pod update

(또한 pod에서 작동하지 않는 경우 podfile에서 SWIFT_VERSION을 변경할 수 있습니다. 예 :

config.build_settings['SWIFT_VERSION'] = '3.2'

)

후;

Xcode를 열고 사용하십시오.

Command+Option+Shift+K

여기에 이미지 설명 입력


그것은 나를 위해 작동합니다.

1. Xcode 8에서 프로젝트 정리

2.Build or run your project in Xcode 9


I cleaned the project in Xcode 9, and then run the app, it works.


I had the same problem with Xcode 9 GM and this solved my problem: Remove it from the project and drag it again into "Embedded Binaries".


Clean Build Folder

Cmd + option + shift + K

I have

pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'

in my project and import FBSDKLoginKit, after cleaning the target i didn't have any issue

Since the pod you are using is in swift and is a beta pod, it is likely that you would have some issues with the swift 4 compiler, you should use the objective-c version of the pod for the time being


If you use from Pod:

  1. In Podfile comment FacebookLogin pod
  2. pod install

  3. In Podfile uncomment FacebookLogin pod
  4. pod install

  5. Run again your project

필자의 경우 실제 포드는 신속한 3.1을 대상으로하는 사전 빌드 된 바이너리가있는 정적 zip을 참조했습니다. 따라서 유일한 해결책은 xcode 9의 소스로 프레임 워크를 다시 빌드하는 것입니다.

https://github.com/AudioKit/AudioKit/issues/980

참고 URL : https://stackoverflow.com/questions/44399109/xcode-9-module-compiled-with-swift-3-1-cannot-be-imported-in-swift-4-0

반응형