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

前端 未结 10 963
北恋
北恋 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:21

    Thanks to @gagarwal for figuring this out. In our case the product name has a space, which is collapsed in $PROJECT_NAME, so I had to hard code it. Additionally, by using $CONFIGURATION_TEMP_DIR instead of $TARGET_TEMP_DIR, you can remove the parent directory (../) from the path. So the solution is to add the following to the Header Search Paths in your test target:

    "$(CONFIGURATION_TEMP_DIR)/Product Name With Spaces.build/DerivedSources"
    

    Or, if your product does not contain spaces:

    "$(CONFIGURATION_TEMP_DIR)/$(PROJECT_NAME).build/DerivedSources"
    

提交回复
热议问题