duplicate symbol _OBJC_CLASS_$_TWTableViewController in

weixin_34320159發表於2016-08-22

今天把老專案中的幾個類提取出來發現一直編譯不通過

duplicate symbol _OBJC_CLASS_$_TWTableViewController in:
    /Users/taowai/Library/Developer/Xcode/DerivedData/cehua-ggvtgfqynwpwsycwvhupbglyurap/Build/Intermediates/cehua.build/Debug-iphonesimulator/cehua.build/Objects-normal/x86_64/TWMainViewController.o
    /Users/taowai/Library/Developer/Xcode/DerivedData/cehua-ggvtgfqynwpwsycwvhupbglyurap/Build/Intermediates/cehua.build/Debug-iphonesimulator/cehua.build/Objects-normal/x86_64/TWTableViewController.o
duplicate symbol _OBJC_METACLASS_$_TWTableViewController in:
    /Users/taowai/Library/Developer/Xcode/DerivedData/cehua-ggvtgfqynwpwsycwvhupbglyurap/Build/Intermediates/cehua.build/Debug-iphonesimulator/cehua.build/Objects-normal/x86_64/TWMainViewController.o
    /Users/taowai/Library/Developer/Xcode/DerivedData/cehua-ggvtgfqynwpwsycwvhupbglyurap/Build/Intermediates/cehua.build/Debug-iphonesimulator/cehua.build/Objects-normal/x86_64/TWTableViewController.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

然後上網檢查了半天,發現是在import時把.h檔案寫成.m檔案了。

#import "TWMainViewController.h"
#import "TWTableViewController.m"

這個因為有自動提示功能,所以寫程式碼的時候一定要細心。

相關文章