次の手順に従いました: 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 は何もしません)。