문제

I am getting an error :

ld: library not found for -lOCMock
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Detailed error :

Ld /Users/akashpatel/Library/Developer/Xcode/DerivedData/RideShareBuddy-cqfdiphwubeiexdigypzpjjfqaiy/Build/Products/Debug-iphonesimulator/RideShareBuddyTests.app/RideShareBuddyTests normal i386
cd "/Users/akashpatel/Documents/iOS development/RideShare/RideShare"
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
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 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/akashpatel/Library/Developer/Xcode/DerivedData/RideShareBuddy-cqfdiphwubeiexdigypzpjjfqaiy/Build/Products/Debug-iphonesimulator "-L/Users/akashpatel/Documents/iOS development/RideShare/RideShare/RideShare" -F/Users/akashpatel/Library/Developer/Xcode/DerivedData/RideShareBuddy-cqfdiphwubeiexdigypzpjjfqaiy/Build/Products/Debug-iphonesimulator "-F/Users/akashpatel/Documents/iOS development/RideShare/RideShare" -filelist /Users/akashpatel/Library/Developer/Xcode/DerivedData/RideShareBuddy-cqfdiphwubeiexdigypzpjjfqaiy/Build/Intermediates/RideShareBuddy.build/Debug-iphonesimulator/RideShareBuddyTests.build/Objects-normal/i386/RideShareBuddyTests.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -all_load -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework QuartzCore -framework GHUnitIOS -framework UIKit -framework Foundation -framework CoreGraphics -lOCMock -o /Users/akashpatel/Library/Developer/Xcode/DerivedData/RideShareBuddy-cqfdiphwubeiexdigypzpjjfqaiy/Build/Products/Debug-iphonesimulator/RideShareBuddyTests.app/RideShareBuddyTests

I don't have duplicate files in Compile Sources.

Ask if more details is required.

EDIT :

#import <GHUnitIOS/GHUnit.h>
#import "OCMock.h"
#import "RS_LoginRSViewController.h"

@interface RS_LoginRSViewControllerTest : GHTestCase
{
    RS_LoginRSViewController * loginObject;
}
@end

@implementation RS_LoginRSViewControllerTest

// Run before each test method
- (void)setUp { }

// Run after each test method
- (void)tearDown { }

// Run before the tests are run for this class
- (void)setUpClass
{
    loginObject = [[RS_LoginRSViewController alloc] init];
    GHAssertNotNil(loginObject, @"Could not create test object.");
}

// Run before the tests are run for this class
- (void)tearDownClass { }

- (void)testViewDidLoad
{
    GHTestLog(@"Log with a test with the GHTestLog(...) for test specific logging.");
}

@end

Added a path in Library search path and Header search path. It raised one more error.

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_RS_LoginRSViewController", referenced from:
      objc-class-ref in RS_LoginRSViewControllerTest.o
     (maybe you meant: _OBJC_CLASS_$_RS_LoginRSViewControllerTest)
도움이 되었습니까?

해결책 2

First I needed to set Library search path and Header search path as shown in Adding OCMock->step 3 in this link.

After that to solve my Undefined symbol error, I had to add all classes to test target. To see how to add files to a specific target, look at SO question.

다른 팁

I don't want to drag the comments section as its already reached the limit..I suspect the way you're importing the third party framework such as OCMock is wrong...

As you have already downloaded the sample from raywenderlich,just compare its builsettings section with your actual project...

Check these link1 and link2..Moreover its a possible duplicate of what you're looking for...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top