Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So I have an iOS project with tests and everything was working properly.

I felt the need to change the project name. I did as indicated at apple's docs, selected the project and changed its name.

After a while of updating things for this to finally work, the app runs ok, but I'm still having a problem.

I can't run the tests because of this annoying issue. I'm sure it's a basic thing, but still I can't quite figure it out.

Here's my test class (for the sake of the question I'm using a Foo example)

@testable import MyApp // File FooTests is part of module MyApp. Ignoring import.

class FooTests: QuickSpec {

  override func spec() {

     describe("a foo test") {
         it("tests foo") {
             let return = Foo.barMethod()
             XCTAssertEqual(return, "expected", "Expected something, got (return) instead")
         }
    }
 }

The Foo class is not being recognized, and I get the error that the test class is part of MyApp which is not the case.

Where should I look for?

question from:https://stackoverflow.com/questions/34889552/xcode-test-class-file-is-part-of-module-ignoring-import

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
243 views
Welcome To Ask or Share your Answers For Others

1 Answer

I just stumbled on the same problem, and your post was helpful. What I found out is by change the Product Name to AppNameTests, as per your example, then the product module name is reflected correctly and you don't have to add Tests at the end of $(PRODUCT_NAME:c99extidentifier). c99extidentifier seems torefers to Product Name.

Summary:

  • select your test target in Project
  • navigate to Build Settings -> Packaging
  • change the Product Name to your previous test target, likely appending Tests
  • I believe the rename as per Apple's renaming a project doesn't include the updating the module in @testable, so I had to do this manually

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...