2014-07-17 59 views
1

我試圖將我的iOS應用程序轉換爲Swift。一切都很順利,直到我嘗試用一​​個.swift替代我的AppDelegate.m/.h。現在,建設的時候,我得到了以下錯誤:`重複的符號_main` Swift AppDelegate

Ld /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Products/Debug-iphonesimulator/Bowdoin\ Dining.app/Bowdoin\ Dining normal i386 
    cd "/Users/ruben/Workspace/Development/Objective-C/Bowdoin Dining" 
    export IPHONEOS_DEPLOYMENT_TARGET=8.0 
    export PATH="/Applications/Xcode6-Beta2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode6-Beta2.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
    /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode6-Beta2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Products/Debug-iphonesimulator -F/Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Products/Debug-iphonesimulator -filelist /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Intermediates/Bowdoin\ Dining.build/Debug-iphonesimulator/Bowdoin\ Dining.build/Objects-normal/i386/Bowdoin\ Dining.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -lxml2 -lswift_stdlib_core -L/Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -force_load -Xlinker /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a -Xlinker -sectalign -Xlinker __SWIFT -Xlinker __ast -Xlinker 4 -Xlinker -sectcreate -Xlinker __SWIFT -Xlinker __ast -Xlinker /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Intermediates/Bowdoin\ Dining.build/Debug-iphonesimulator/Bowdoin\ Dining.build/Objects-normal/i386/BowdoinDining.swiftmodule -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.0 -lz.1.2.5 -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework CoreGraphics -framework Foundation -framework UIKit -Xlinker -dependency_info -Xlinker /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Intermediates/Bowdoin\ Dining.build/Debug-iphonesimulator/Bowdoin\ Dining.build/Objects-normal/i386/Bowdoin\ Dining_dependency_info.dat -o /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Products/Debug-iphonesimulator/Bowdoin\ Dining.app/Bowdoin\ Dining 

和:

duplicate symbol _main in: 
    /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Intermediates/Bowdoin Dining.build/Debug-iphonesimulator/Bowdoin Dining.build/Objects-normal/i386/AppDelegate.o 
    /Users/ruben/Library/Developer/Xcode/DerivedData/Bowdoin_Dining-eevtozmixiiwpkdhanzlqfsrhfxr/Build/Intermediates/Bowdoin Dining.build/Debug-iphonesimulator/Bowdoin Dining.build/Objects-normal/i386/main.o 
ld: 1 duplicate symbol for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

,這個錯誤似乎很通用是不是所有的有用......但是,這一切我真的得。這似乎發生在我將我的import "AppDelegate.h int main.m更改爲import "MyAppName-Swift.h"後。有誰知道爲什麼會發生?謝謝。

+0

如果您刪除這些更改,您能確認它仍然有效嗎?因爲如果不是,它很可能是一個IDE /調試錯誤。 –

回答

7

你可以完全拋棄main.m。只需在應用程序委託的類聲明上方的行上添加@UIApplicationMain即可指定應用程序的入口點。

0

我有同樣的問題,並刪除main.m解決了它。在我的情況下,我正在將一個Objective-C應用程序轉換爲快速並且目前有混合。