简体   繁体   English

如何使用OCMock + OCUnit获取Xcode 4.4.1来识别项目的头文件?

[英]How can I get Xcode 4.4.1 with OCMock + OCUnit to recognize my project's header files?

I followed these steps: http://ocmock.org 我按照以下步骤操作: http : //ocmock.org

and also these: http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ 以及这些: http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

Though I could not successfully get step #4 of the twobitlabs instructions to work. 虽然我无法成功获得twobitlabs指令中的第4步。 meaining "Click the Build Settings tab and set the Bundle Loader setting to$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp"... When I did that, I get: 意味着“单击“构建设置”选项卡,并将捆绑加载程序设置设置为$(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)

Yet, when I copy/paste that path in my terminal, it definitely is there.. as you can see here: 但是,当我在终端中复制/粘贴该路径时,它肯定存在..如您在此处看到的:

>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

So, I don't know if it's a problem with my file having spaces in it or not... 因此,我不知道文件中是否包含空格是否有问题...

If I skip that step, when I run my tests, I get the infamous error: 如果跳过该步骤,则在运行测试时,会收到臭名昭著的错误:

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)

Where the test.m file doesn't seem to understand what the header is for the actual class I am testing, despite my #import "Question.h" in the test.h's header... (also, adding it directly to the .m does nothing). 凡test.m文件似乎不明白标题是什么实际的类我测试,尽管我#进口“Question.h”在test.h的头......(也直接将它添加到.m不执行任何操作)。

It occurred to me when closely looking at the stack trace.. ".../Debug-iphonesimulator/Notes\\ and\\ Clefs.app/Notes\\ and\\ Clefs\\"" 当我仔细查看堆栈跟踪时,它发生在我身上。“ ... / Debug-iphonesimulator / Notes \\和\\ Clefs.app/Notes \\和\\ Clefs \\”“

the \\'s can't be good! \\不可能很好! I changed the Bundle Loader to the path without the backslashes, and now it works! 我将Bundle Loader更改为没有反斜杠的路径,现在可以使用了! Hooray! 万岁!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM