In my main target, I have a MyClass
class. Then I try to access this class in my simple test case.
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "MyClass.h"
@interface TryXcodeBotTests : XCTestCase
@end
@implementation TryXcodeBotTests
- (void)testExample {
MyClass *object = [[MyClass alloc] init];
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
}
@end
In my test target, I already set the Host Application
to my app, and check the Allow testing Host Application APIs
. I go to Product > Test
in my Xcode. The simulator shows up. The test went well. Great!
BUT!!! The problem is, when I try it with xcodebuild
command line, it doesn't work.
This is the command.
/usr/bin/xcodebuild test -scheme TryXcodeBot \
-workspace TryXcodeBot.xcworkspace \
-configuration Release \
-destination 'platform=iOS Simulator,name=iPhone 5s'
This is the output, with errors at the end.
ld: warning: directory not found for option '-F/Applications/http://ift.tt/1QIfMIM'
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyObject", referenced from:
objc-class-ref in TryXcodeBotTests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Testing failed:
"_OBJC_CLASS_$_MyObject", referenced from:
Linker command failed with exit code 1 (use -v to see invocation)
** TEST FAILED **
The following build commands failed:
Ld /Users/thongchai/Library/Developer/Xcode/DerivedData/TryXcodeBot-ciwyldvaiganvlcceegjybtnqlto/Build/Intermediates/TryXcodeBot.build/Release-iphonesimulator/TryXcodeBotTests.build/Objects-normal/i386/TryXcodeBotTests normal i386
(1 failure)
I can't find a way to set the test Host Application when using xcodebuild to test. Or do anything to make the test recognize the class in my app file. I know I can manually add MyClass.h
to my test target (which it works). But that's not what I want. I want MyClass to only exist in my main app target. Is there any way to do this?
Aucun commentaire:
Enregistrer un commentaire