升级到Xcode 8并将我的所有代码转换为Swift 3后,我遇到了编译swift资源的麻烦。这需要很长时间,我的电脑变得超级迟滞,大约30分钟后我就得到了这个
CompileSwift normal arm64 /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrank.swift cd / Users / choojayson / Dropbox / BottomsUp /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/choojayson/Dropbox/BottomsUp/Thirst/PendingVC.swift / Users / choojayson / Dropbox / BottomsUp / Thirst /NotificationCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ProfileCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/NotificationsVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserPendingAction.swift / Users / choojayson /Dropbox/BottomsUp/Thirst/ChooseDrinkVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/AppDelegate.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserCell.swift / Users / choojayson / Dropbox / BottomsUp / Thirst / FirebaseReferences .swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ProfileStatsCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrankTime.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/MyProfileVC.swift / Users / choojayson / Dropbox /BottomsUp/Thirst/ProfileStatsFooterCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/WeeklyDrank.swift / Us ers / choojayson / Dropbox / BottomsUp / Thirst / DrinkList.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/DrinkCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/User.swift / Users / choojayson / Dropbox / BottomsUp / Thirst / HeaderCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/EndorseVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/GlobalScore.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Username.swift / Users / choojayson / Dropbox / BottomsUp / HomeVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/LoginVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/LeaderBoardVC.swift / Users / choojayson / Dropbox / BottomsUp / Thirst / CollectionViewHeaderCell。 swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Global.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/CircularTransition.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Drink.swift / Users / choojayson / Dropbox / BottomsUp / Thirst / WeeklyBestVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/DrinkStatus.swift / Users / choojayson / Dropbox / BottomsUp / Thirst / Leade rBoardCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/PendingCell.swift -primary-file /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrank.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use -tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk -I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Products / Debug-iphoneos -F / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Products / Debug-iphoneos -F / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Products / Debug-iphoneos / SDWebImage -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseAnalytics / Frameworks / frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseAuth / Frameworks / frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseDatabase / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseIn stanceID / Frameworks / frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseMessaging / Frameworks / frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / FirebaseStorage / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleIPhoneUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleInterchangeUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleNetworkingUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleParsingUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleSymbolUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp / Pods / GoogleUtilities / Frameworks -F / Users / choojayson / Dropbox / BottomsUp -enable-testing - g -module-cache-path / Users / choojayson / Library / Developer / Xcode / DerivedData / ModuleCache -serialize-debugging-options -Xcc -I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build /中间体/ Thirst.build /调试-的iPhoneOS / Thirst.build / swift-overrides.hm ap -Xcc -iquote -Xcc /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Thirst-generated-files.hmap -Xcc- I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug-iphoneos / Thirst.build / Thirst-own-target-headers.hmap -Xcc -I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug-iphoneos / Thirst.build / Thirst-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /用户/ choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / all-product-headers.yaml -Xcc -iquote -Xcc / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug-iphoneos / Thirst.build / Thirst-project-headers.hmap -Xcc -I / Users / choojayson / Library / Develop er / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Products / Debug-iphoneos / include -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Firebase / Analytics / Sources -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / Firebase -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseAnalytics -Xcc - I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseAuth -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseDatabase -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseInstanceID -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseMessaging -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / FirebaseStorage -Xcc - I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / GoogleIPhoneUtilities -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / GoogleInterchangeUtilities -Xcc -I / Users / choojayson / Dropbox / BottomsU p / Pods / Headers / Public / GoogleNetworkingUtilities -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / GoogleParsingUtilities -Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / GoogleSymbolUtilities - Xcc -I / Users / choojayson / Dropbox / BottomsUp / Pods / Headers / Public / GoogleUtilities -Xcc -I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug- iphoneos / Thirst.build / DerivedSources / arm64 -Xcc -I / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug-iphoneos / Thirst.build / DerivedSources -Xcc - DDEBUG = 1 -Xcc -DCOCOAPODS = 1 -Xcc -working-directory / Users / choojayson / Dropbox / BottomsUp -emit-module-doc-path / Users / choojayson / Library / Developer / Xcode / DerivedData / Thirst-fbgpdykwgpyxllfixfnpenbijinz / Build / Intermediates / Thirst.build / Debug-iphoneos / Thirst.build / Objects-normal / arm64 / UserDrank~partial.swiftdoc -Onone -module-name Thirst -emit-mod ule-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank~partial.swiftmodule-serialize- diagnostics-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.dia-emit- dependencies- path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.d-emit-reference-dependencies- path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.swiftdeps -o / Users / choojayson /图书馆/开发商/ Xcode中/ DerivedData /渴fbgpdykwgpyxllfixfnpenbijinz /编译/中间体/ Thirst.build /调试-的iPhoneOS / Thirst.build/Objects-normal/arm64/UserDrank.o -embed-bitcode-marker
答案 0 :(得分:13)
信不信由你,这是导致问题的一段代码。有了它,编译大约需要30分钟。如果我只是注释掉那段代码,它会在不到30秒的时间内编译。
let params : [String: Any] = [
"person_id" : kPersonId,
"person_promo_id" : promo.personPromoId!,
"promo_page_id" : promo.promoPageId!,
"seq_no" : promo.seqNo!,
"promo_type" : promo.promoType!,
"page_name" : promo.pageName!,
"image_name" : promo.imageName!,
"start_date" : promo.startDate!,
"end_date" : promo.endDate!,
"website" : promo.website!,
"facility_name" : promo.facilityName!,
"address" : promo.street!,
"city" : promo.city!,
"prov_state_cd" : promo.provState!,
"country_cd" : promo.country!,
"contact_name" : promo.contactName!,
"contact_phone" : promo.contactPhone!,
"latitude" : promo.latitude!,
"longitude" : promo.longitude!,
"bgColorRed" : promo.bgColorRed!,
"bgColorGreen" : promo.bgColorGreen!,
"bgColorBlue" : promo.bgColorBlue!,
"promoCategories" : promoCat
]
根据我和其他阅读过的内容,我会寻找一个案例,你在定义中使用Any
或AnyObject
为大型或嵌套字典赋值。我猜这是Any
正在通过疯狂的追逐发送编译器。
如果您检查日志失败的位置,则应该在失败的对象上发生错误。这应该可以为您提供关于要查看的文件的线索。
编辑: @Jay Chow,这就是我用上面的代码解决编译器问题的方法:
var params : [String : Any] = [:]
params["person_id"] = kPersonId
params["person_promo_id"] = promo.personPromoId
params["promo_page_id"] = promo.promoPageId
params["seq_no"] = promo.seqNo
params["promo_type"] = promo.promoType
params["page_name"] = promo.pageName
params["image_name"] = promo.imageName
params["start_date"] = promo.startDate
params["end_date"] = promo.endDate
params["website"] = promo.website
params["facility_name"] = promo.facilityName
params["address"] = promo.street
params["city"] = promo.city
params["prov_state_cd"] = promo.provState
params["country_cd"] = promo.country
params["contact_name"] = promo.contactName
params["contact_phone"] = promo.contactPhone
params["latitude"] = promo.latitude
params["longitude"] = promo.longitude
params["bgColorRed"] = promo.bgColorRed
params["bgColorGreen"] = promo.bgColorGreen
params["bgColorBlue"] = promo.bgColorBlue
params["promoCategories"] = promoCat
答案 1 :(得分:0)
就我而言,当我发现问题的代码是:
return realm2.objects(Alert.self).sorted(by: { (alert1, alert2) -> Bool in
return alert1.hour < alert2.hour &&
alert1.minute < alert2.minute &&
alert1.label < alert2.label
})
答案 2 :(得分:0)
我的情况与将太多以编程方式创建的约束附加到视图控制器的视图有关。我在类级别定义了多个约束数组,如下所示:
Success undefined
我在视图中对所有UI元素使用了这种表示法。当我构建视图时,我有大约10个3-5个NSLayoutConstraints的数组。
然后我将一个连接数组附加到视图的约束数组中,如下所示:
lazy var labelConstraints: [NSLayoutConstraint] = [...]
这一行原来是问题所在。它必须是延迟初始化和内联数组concat的东西。不管是什么原因,我使用flatMap修复了这个问题,如下所示。
self.view.addConstraints(labelConstraints + buttonConstraints + viewConstraints, ...)
答案 3 :(得分:0)
就我而言,我正在编写一个实现Equatable
的类,并且还有通用成员。当泛型类没有实现==
运算符时,我的问题根源于将通用成员与==
进行比较。
例如(使用Variable
中的RxSwift
):
class Foo: Equatable {
var fieldOne: Variable<String> = Variable("fieldOne")
var fieldTwo: Variable<String?> = Variable(nil)
public static func ==(lhs: Foo, rhs: Foo) -> Bool {
//should be marked as a compiler error, since Variable doesn't have ==
return lhs.fieldOne == rhs.fieldOne && lhs.fieldTwo == rhs.fieldTwo
}
}
我应该看到编译器错误,因为==
没有Variable
的定义,但编译器会崩溃(以及静态分析)才能显示它。在崩溃之前我看到内存使用量为60GB +。让人惊讶。
当涉及到泛型时,似乎很快就会有一些挥之不去的错误。
答案 4 :(得分:0)
在我的情况下,Xcode 9,Swift 4,编译器无法添加8个数字:
let aBitPattern: UInt64 = ((UInt64(a) & UInt64(0xff)) << 0) +
((UInt64(b) & UInt64(0xff)) << 8) +
((UInt64(c) & UInt64(0xff)) << 16) +
((UInt64(d) & UInt64(0xff)) << 24) +
((UInt64(e) & UInt64(0xff)) << 32) +
((UInt64(f) & UInt64(0xff)) << 40) +
((UInt64(g) & UInt64(0xff)) << 48) +
((UInt64(h) & UInt64(0xff)) << 56)
转换为此解决了无限编译:
var aBitPattern: UInt64 = ((UInt64(a) & UInt64(0xff)) << 0);
aBitPattern += ((UInt64(b) & UInt64(0xff)) << 8);
aBitPattern += ((UInt64(c) & UInt64(0xff)) << 16);
aBitPattern += ((UInt64(d) & UInt64(0xff)) << 24);
aBitPattern += ((UInt64(e) & UInt64(0xff)) << 32);
aBitPattern += ((UInt64(f) & UInt64(0xff)) << 40);
aBitPattern += ((UInt64(g) & UInt64(0xff)) << 48);
aBitPattern += ((UInt64(h) & UInt64(0xff)) << 56);
是的,有时分号也帮助编译器理解你的代码。
我总是期待新的Swift编译器,它总是让Apple感到非常失望。