注意:「使用GHUnit」不是此問題的可接受答案。我知道大多數人認爲GHUnit比Xcode4 OCUnit更好,但這不是我所問的。我會分開評估。Xcode 4單元測試鏈接器錯誤
我有一個從頭開始在Xcode4中創建的Xcode項目,在創建過程中選中「包含單元測試」複選框。我還包括一些我在以前的項目中開發的庫。通過「添加文件到x ...」對話框將它們添加到項目中,並僅添加到應用程序目標(而不是測試目標)。運行應用程序時它們工作正常,所以我認爲它們設置正確。我也爲這個項目編寫了許多不同的類。
我的測試文件是以標準方式設置的,名爲[AppName] Tests.h和.m。
代碼頭:
#import <SenTestingKit/SenTestingKit.h>
@interface [AppName]Tests : SenTestCase {
@private
}
@end
代碼執行:
#import "[AppName]Tests.h"
@implementation [AppName]Tests
- (void)setUp
{
[super setUp];
// Set-up code here.
}
- (void)tearDown
{
// Tear-down code here.
[super tearDown];
}
// Test methods go here
@end
這僅僅是基本骨架。它可以在我的其他項目以及這個項目中正常工作,只要我不導入任何其他文件。當我從這個項目導入另一個文件,並使用它,我看到的Xcode輸出日誌以下錯誤:
The test bundle at /Users/[Me]/Library/Developer/Xcode/DerivedData/[AppName]-dwuuuwcpmdqxqmgxomoniplwhlpb/Build/Products/Debug-iphonesimulator/[AppName]Tests.octest could not be loaded because a link error occurred. It is likely that dyld cannot locate a framework framework or library that the the test bundle was linked against, possibly because the framework or library had an incorrect install path at link time.
我已經證實:
- 我所用有框架被 添加到「鏈接二進制與 庫」爲應用程序和測試 目標。
- 測試目標已經配置 正確地創建和我所有的 測試方法編輯顯示 計劃...->測試 - >測試
- 每一個問題,但這個已經 解決,有沒有編譯器 錯誤。
- 所有設置討論 here 設置是否正確和一致 我認爲正確的測試 其他項目。
有什麼想法可能會導致這種情況?
我有這個EXACT相同的問題。測試運行正常,直到您從主機應用程序分配一個對象。整天被難住:( – Sam 2011-07-28 16:42:21
@Sam我被困了一個半月:P 最終我放棄了,並測試了老式的方式。也許新的Xcode會修復它,誰知道。 – Kongress 2011-07-28 19:59:40
與我之前的許多人一樣,我已經放棄了,現在正在使用GHUnit,花費了大約10分鐘的時間來設置 – Sam 2011-07-29 10:27:53