I have three asynchronous tests. All run fine when tested within Xcode, but the test case cannot be built with xcodebuild. I get 11 build errors all relating to XCTestExpectation.
Example:
error: unknown type name 'XCTestExpectation' @property XCTestExpectation *expectationNoImage;
I am using the latest command line tools (Xcode 6.1.1). xcodebuild -version correctly states that.
I am running the build with the following command
xcodebuild -project myprojasync.xcodeproj -scheme testScheme -configuration Debug -sdk iphonesimulator7.1 clean test | ocunit2junit
Everything runs perfectly with the same command if I comment out the async tests and their counterparts.
Edit: Here's one of the test methods.
@property XCTestExpectation *expectationPass;
-(void)testTaskPass{
//Expectation
self.expectationPass = [self expectationWithDescription:@"Testing Async Works"];
[self.asyncTask getInfo]; //asynchronous call
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
-(void)returnedFrom:(NSURL *)url with:(UIImage *)image{
if([[url absoluteString] isEqualToString: @"http://correcturl.com"]){
[self.expectationPass fulfill];
}
}
It turns out, the issue was actually that while I had the 6.1 tools within XCode. I had older tools still on my computer and for whatever reason even though my xcode-select pointed to the correct ones, it was trying to use the older tools. Uninstalled the older tools and everything works now :)