iOS - 'MyProject-Swift.h' file not found when running Unit Tests for Swift

前端 未结 10 968
北恋
北恋 2020-12-02 07:03

I am trying to setup Unit Testing for my project. It is an existing Objective-C app, that I have recently added one Swift class to. I have setup the \'MyProject-Swift.h\' an

10条回答
  •  春和景丽
    2020-12-02 07:08

    Strangely, I was seeing this same error, but only when targeting a device (not the simulator). Before running the test I would see the red exclamation point next to the import statement for "MyProjectNameTests-Swift.h".

    However, funny thing is, if I just go ahead and run the test anyway (despite this apparent build error), then during the build phase that happens thereafter, XCode actually does generate the "MyProjectNameTests-Swift.h" file, and the test runs just fine!

    So, at least in my case, there was no need for the other solutions here, evidently, although I believe they do work also.

    I should also note that I deleted my DerivedData directory prior to this, so maybe that is a step also worth trying.

提交回复
热议问题