最新消息:20210917 已从crifan.com换到crifan.org

【未解决】Xcode换9.2后代码编译报错:Module compiled with Swift 4.0 cannot be imported in Swift 3.2.3

Xcode crifan 2829浏览 0评论

在本身已有:

Version 9.1 beta (9B37)

的情况下,下载了最新的

Xcode 9.2 beta

版后去编译项目,结果出错:

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.3: …/Carthage/Build/iOS/Cartography.framework/Modules/Cartography.swiftmodule/x86_64.swiftmodule

很明显,又是库的版本需要重新编译

那么去参考之前的

【已解决】Xcode9中项目编译出错:Module compiled with Swift 3.1 cannot be imported in Swift 3.2.1

再去试试:

➜  SRT git:(master) ✗ rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData

➜  SRT git:(master) ✗ carthage update –platform iOS –no-use-binaries

Please update to the latest Carthage version: 0.26.2. You currently are on 0.24.0

*** Cloning Cartography

所以先去升级carthage:

【已解决】brew upgrade carthage出错:Error carthage 0.25.0 already installed

然后再去:

carthage update –platform iOS –no-use-binaries

不过突然想到,或许最后也是不行,或许是会由于两个Xcode的版本同存,导致当前的swift的编译器还是3.2.3的?

这个是之前的9.1的Xcode

这个是9.2 beta:

所以还是要等最后看看结果如何。

然后编译等待了1个小时左右,才编译到Realm,还是没有编译完毕,而且CPU始终是100%,电脑卡死。所以干脆中断:

重新开始试试。

最终经历了:大概2个小时,才完整的更新一遍:

➜  SRT git:(master) ✗ carthage update –platform iOS –no-use-binaries

*** Fetching Cartography

*** Fetching MGSwipeTableCell

*** Fetching Alamofire

*** Fetching TextFieldEffects

*** Fetching SwiftyJSON

*** Fetching KMPlaceholderTextView

*** Fetching realm-cocoa

*** Fetching SwiftHEXColors

*** Fetching SwiftHTTPStatusCodes

*** Fetching ActionSheetPicker-3.0

*** Fetching Kingfisher

*** Fetching Charts

*** Fetching SwiftKeychainWrapper

*** Fetching DLRadioButton

*** Fetching XCGLogger

*** Checking out Cartography at “1.1.0”

*** Checking out DLRadioButton at “1.4.11”

*** Checking out Charts at “v3.0.4”

*** Checking out SwiftKeychainWrapper at “2.2.1”

*** Checking out Kingfisher at “3.13.1”

*** Checking out ActionSheetPicker-3.0 at “2.2.0”

*** Checking out SwiftHTTPStatusCodes at “3.1.2”

*** Checking out SwiftHEXColors at “1.1.1”

*** Checking out realm-cocoa at “v3.0.2”

*** Checking out KMPlaceholderTextView at “1.3.0”

*** Checking out SwiftyJSON at “4.0.0”

*** Checking out TextFieldEffects at “1.4.0”

*** Checking out Alamofire at “4.5.1”

*** Checking out MGSwipeTableCell at “1.6.6”

*** Checking out XCGLogger at “Version_4.0.0”

*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.Zg0Tdb.log

*** Building scheme “CoreActionSheetPicker” in ActionSheetPicker-3.0.xcworkspace

*** Building scheme “Alamofire iOS” in Alamofire.xcworkspace

*** Building scheme “Cartography-iOS” in Cartography.xcworkspace

*** Building scheme “Charts” in Charts.xcodeproj

*** Building scheme “DLRadioButton” in DLRadioButton.xcodeproj

*** Building scheme “Kingfisher” in Kingfisher.xcworkspace

*** Building scheme “KMPlaceholderTextView” in KMPlaceholderTextView.xcodeproj

*** Building scheme “MGSwipeTableCell” in MGSwipeTableCell.xcodeproj

*** Building scheme “Realm” in Realm.xcworkspace

*** Building scheme “RealmSwift” in Realm.xcworkspace

*** Building scheme “SwiftHEXColors” in SwiftHEXColors.xcodeproj

*** Building scheme “HTTPStatusCodes” in HTTPStatusCodes.xcodeproj

*** Building scheme “SwiftKeychainWrapper” in SwiftKeychainWrapper.xcodeproj

*** Building scheme “SwiftyJSON iOS” in SwiftyJSON.xcworkspace

*** Building scheme “TextFieldEffects” in TextFieldEffects.xcodeproj

*** Building scheme “XCGLogger (iOS)” in XCGLogger.xcodeproj

➜  SRT git:(master) ✗

然后就再去试试新版的Xcode 9.2中是否可以正常编译

结果还是不行。

TODO:

后续再去想办法看看,Xcode 9.2中如何指定编译器为swift 3.2

目前简单去看了看Xcode 9.2中的配置中,是找不到相关的编译器指定为swift 3.2.3的

并且,项目配置中,本身已经选择了Swift的编译器版本是3.2.3,而不是4.0.1的,

但是不知道为何Xcode 9.2编译时,却内部还是默认用Swift 4去编译?

转载请注明:在路上 » 【未解决】Xcode换9.2后代码编译报错:Module compiled with Swift 4.0 cannot be imported in Swift 3.2.3

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
99 queries in 0.239 seconds, using 23.32MB memory