0
我寫了一個C函數,當我想在Xcode中使用XCTest測試這個函數時,得到一個錯誤。XCTest測試C函數構建失敗
List.h
有一個函數定義。
#ifndef List_h
#define List_h
#include <stdio.h>
List initList();
#endif /* List_h */
Test.m
代碼 #進口 的#include 「List.h」
@interface ListTest : XCTestCase
@end
@implementation ListTest
- (void)testExample {
initList();
}
@end
當我按下命令+ U,構建失敗!
錯誤消息:
Undefined symbols for architecture i386:
"_initList", referenced from:
-[ListTest testExample] in ListTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
幫助,謝謝。
如果您必須在您的測試目標中包含實施文件,那麼您的設置不正確。我剛剛創建了一個全新的項目,並能夠從我的測試中調用我的C函數,沒問題。 –