Unable to compile unit tests - "Could not build module XCTest" - "Expected a type"

Hello -


  • Xcode 9.2
  • macOS 10.12.6 (16G1114)
  • Objective-C (no Swift)
  • macOS app with test cases


We have a macOS app we've been working on. Objective-C (with some Obj-C++ mixed in). App compiles and runs fine.


We've got a bunch of test cases that worked fine until I updated to Xcode 9.2 (from 8.x). Now I can't seem to get them to compile and run. Totally stumped on why.


Messages in the log seem to focus around:


Expected a type

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTestCase+AsynchronousTesting.h:180:52: Expected a type

Expected ';' after top level declarator

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTestCase.h:190:40: Expected ';' after top level declarator

When I look at one of the Xcode tests I'm seeing warnings around the XCTest import

#import <XCTest/XCTest.h>

Shows the warning "Could not build module XCTest"


I don't believe I've changed anything (other than upgrading to XCode 9.2).


For giggles I created a whole new project (Objective-C as well), created a test target and a test class - no problem - everything worked fine. The issue seems to be contained to my existing app.


I read the note re: Swift 4 from (https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html) that indicated Swift 4 projects may have issues with test cases, but I'm not using Swift at all (as much as I'd love to). Is it possible the same work-around would be appropriate even though I'm not using Swift?


Any ideas very much appreciated. Not sure what I did to somehow make the build gremlins unhappy with these test cases.


Thank you,
Eric

Replies

Quick update.


My co-worker, using Xcode 8.2, can successfully build and run tests.


I'm currently downloading 8.3.3 and will see what happens.

Everything works fine in Xcode 8.3. No warnings. All tests compile and run.


Not sure why Xcode 9 is unhappy.