Can't use Swift classes inside Objective-C unit test

假如想象 提交于 2019-12-05 00:48:45
Drux

As per @SushiGrassJacob's comment (see here) the following solves the issue:

  1. Make sure that Swift classes are targeted to both MyProject and MyProjectTest.
  2. In unit test, #import "MyProjectTests-Swift.h".

Step-1

Go to your test target > Build Settings > Header Search Paths, and add $CONFIGURATION_TEMP_DIR/YourProject.build/DerivedSources in it.

Step-2

#import "YourProject-Swift.h"

Go to test target > Build Settings > Header Search Paths, and add $CONFIGURATION_TEMP_DIR/MyProject.build/DerivedSources in it. For me worked only without checking Swift classes targeted for MyProjectTests. Source: https://medium.com/if-let-swift-programming/ios-tests-working-with-objective-c-and-swift-class-together-aaf40f91a27c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!