XCode 6 GM 中的 Swift 编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25792284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:32:02  来源:igfitidea点击:

Swift compile error in XCode 6 GM

iosxcodeswiftxcode6gm

提问by Slavik Voloshyn

I'm using a new Swift language for develop IOS application. Suddenly i got an error from my XCode.

我正在使用一种新的 Swift 语言来开发 IOS 应用程序。突然,我的 XCode 出现错误。

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 


CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
cd /Users/bobo/Desktop/MyProject/ios
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -target armv7-apple-ios7.0 -module-name MyProject -Onone -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk -g -module-cache-path /Users/bobo/Library/Developer/Xcode/DerivedData/ModuleCache -I /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Products/Debug-iphoneos -F /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Products/Debug-iphoneos -F MyProject -c -j4 /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerWiFiSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerEthernet.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellWiFi.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerWidgets.swift /Users/bobo/Desktop/MyProject/ios/MyProject/DAOMyProjectsGroup.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerWifiSecurity.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerWithMenu.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsHeader.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsSlider.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerAllSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellTimeZone.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerVerifyMyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsWiFi.swift /Users/bobo/Desktop/MyProject/ios/MyProject/NSTimerExtension.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectApiHelper.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerSlidingMenu.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectBluetooth.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerAppSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerSettingsList.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectAudio.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerConnectToWiFiError.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/LiveNibViewCell.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerMyProjectsHolder.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectAvailableWiFi.swift /Users/bobo/Desktop/MyProject/ios/MyProject/NSTimeZoneExtension.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectAppWrapper.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerMyProjectName.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerWiFiNetworkSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/Constants.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsInputField.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectModeDrawer.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerAccessPoint.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectWiFi.swift /Users/bobo/Desktop/MyProject/ios/MyProject/LiveNibView.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsInfo.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerSetupSuccess.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerMyProjectsList.swift /Users/bobo/Desktop/MyProject/ios/MyProjectEthernet.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewPager.swift /Users/bobo/Desktop/MyProject/ios/MyProject/UpnpUtils.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectApp.swift /Users/bobo/Desktop/MyProject/ios/MyProject/UiUtils.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsInfoWithArrow.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellMenuHeader.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsSwitch.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsInfoTime.swift /Users/bobo/Desktop/MyProject/ios/MyProject/KeyboardHandler.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerTimeZonesList.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellMenuMyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerHowToConnect.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerBaseSetup.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellMyProjectOnline.swift /Users/bobo/Desktop/MyProject/ios/MyProject/NavigationControllerSlidingMenu.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerAppArrayItemProperties.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerListWiFiNetworks.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellMyProjectOffline.swift /Users/bobo/Desktop/MyProject/ios/MyProject/IMyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/DevUtils.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectModeItem.swift /Users/bobo/Desktop/MyProject/ios/MyProject/AppDelegate.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerVerificationCodeError.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerEnterWiFiPassword.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectInfo.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerAppArrayProperties.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerDateAndTimeSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectDatabaseManager.swift /Users/bobo/Desktop/MyProject/ios/MyProject/AppPreferencesHelper.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerChangeAppProperty.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerStore.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerMyProjectHolder.swift /Users/bobo/Desktop/MyProject/ios/MyProject/SettingsSlider.swift /Users/bobo/Desktop/MyProject/ios/MyProject/BottomDrawer.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerScanningForMyProjects.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellAppPropertyHeader.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectAppDescriptor.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerConnectedWiFiSettings.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ButtonWithColorBackground.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsCheck.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellWidget.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectSetupController.swift /Users/bobo/Desktop/MyProject/ios/MyProject/CellSettingsInfoWithIcon.swift /Users/bobo/Desktop/MyProject/ios/MyProject/DAOMyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/ViewControllerSetUpMyProject.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectClock.swift /Users/bobo/Desktop/MyProject/ios/MyProject/MyProjectDisplay.swift -output-file-map /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/MyProject-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/MyProject.swiftmodule -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-generated-files.hmap -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-own-target-headers.hmap -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-all-target-headers.hmap -Xcc -iquote -Xcc /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-project-headers.hmap -Xcc -iquoteMyProject/upnpx/api -Xcc -iquoteMyProject/upnpx/api/port/ios -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Products/Debug-iphoneos/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/DerivedSources/armv7 -Xcc -I/Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/DerivedSources -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/bobo/Library/Developer/Xcode/DerivedData/MyProject-diekcgczcwnrhtfxrpqbqsfywosi/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/MyProject-Swift.h -import-objc-header /Users/bobo/Desktop/MyProject/ios/MyProject/MyProject-Bridging-Header.h 

XCode version - 6 GM (It's a latest stable version). Somebody know how fix this issue?

XCode 版本 - 6 GM(这是最新的稳定版本)。有人知道如何解决这个问题吗?

采纳答案by Slavik Voloshyn

I found solution, but it's not a best way. After reinstall XCode this issue was fixed.

我找到了解决方案,但这不是最好的方法。重新安装 XCode 后,此问题已修复。

回答by Pintouch

Did you try removing your project folder in the DerivedData folder before reinstalling xCode?

在重新安装 xCode 之前,您是否尝试删除 DerivedData 文件夹中的项目文件夹?

I had the same problem updating from beta 6 to beta 7, and that solved the problem.

我从 beta 6 更新到 beta 7 时遇到了同样的问题,这解决了问题。

回答by tuoxie007

I had the same problem, then I use git checkout old versions to find which commit cause the problem, and try to find the key problem code. My key problem code is something like this

我也遇到了同样的问题,然后我使用git checkout old versions查找导致问题的提交,并尝试找到关键问题代码。我的关键问题代码是这样的

func afunc() {
    class AClass() {
    }
    let ac = AClass()
    //....
}

Other code could make the same problem, occur in Swift Optimization, and swift compiler doesn't tell you the exact location. This must be a bug by Apple.

其他代码可能会出现同样的问题,发生在 Swift 优化中,并且 Swift 编译器不会告诉您确切的位置。这应该是苹果的bug。