0

我按照以下步骤操作:http: //ocmock.org

还有这些: http ://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

虽然我无法成功地让 twobitlabs 指令的第 4 步工作。意思是“单击构建设置选项卡并将捆绑加载程序设置设置为$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp”......当我这样做时,我得到:

Ld /Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/UnitTests.octest/UnitTests normal i386
cd "/Users/patrick/coding/objective_c/vms/Notes and Clefs"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.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/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator "-L/Users/patrick/coding/objective_c/vms/Notes and Clefs/usr/lib" -F/Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist "/Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Intermediates/Notes and Clefs.build/Debug-iphonesimulator/UnitTests.build/Objects-normal/i386/UnitTests.LinkFileList" -mmacosx-version-min=10.6 -bundle_loader "\"/Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/Notes\\ and\\ Clefs.app/Notes\\ and\\ Clefs\"" -Xlinker -objc_abi_version -Xlinker 2 -force_load "/Users/patrick/coding/objective_c/vms/Notes and Clefs/usr/lib/libOCMock.a" -ObjC -fobjc-link-runtime -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -lOCMock -framework SenTestingKit -framework UIKit -framework Foundation -o /Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/UnitTests.octest/UnitTests

ld: file not found: "/Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/Notes\ and\ Clefs.app/Notes\ and\ Clefs"
clang: error: linker command failed with exit code 1 (use -v to see invocation)

然而,当我在我的终端中复制/粘贴该路径时,它肯定存在..正如您在此处看到的:

>ls -l /Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/Notes\ and\ Clefs.app/Notes\ and\ Clefs
-rwxr-xr-x  1 patrick  staff  1862424 Aug 15 22:42 /Users/patrick/Library/Developer/Xcode/DerivedData/Notes_and_Clefs-fpzvpdfkkkjuynefaqeajfdiznbp/Build/Products/Debug-iphonesimulator/Notes and Clefs.app/Notes and Clefs

所以,我不知道我的文件中是否有空格是否有问题......

如果我跳过这一步,当我运行测试时,我会收到臭名昭著的错误:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_Question", referenced from:
      objc-class-ref in UnitTests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

test.m 文件似乎不理解我正在测试的实际类的标头是什么,尽管我在 test.h 的标头中使用了 #import "Question.h" ...(另外,将其直接添加到.m 什么都不做)。

4

1 回答 1

0

仔细查看堆栈跟踪时,我突然想到了..“.../Debug-iphonesimulator/Notes\ and\ Clefs.app/Notes\ and\ Clefs\”

\'s不可能是好的!我将 Bundle Loader 更改为没有反斜杠的路径,现在它可以工作了!万岁!

于 2012-08-16T08:05:00.123 回答