Objective C to Swift header file with multiple targets

前端 未结 6 1684
無奈伤痛
無奈伤痛 2020-12-01 03:32

I\'m successfully calling my Swift classes from Objective C (for target \'MyApp\') via the import statement:

#import \"MyApp-Swift.h\"

I\'v

6条回答
  •  一向
    一向 (楼主)
    2020-12-01 03:52

    The best way I've found to address this issue is in your Xcode shared project settings. You can search for the following setting:

    Objective-C Generated Interface Header Name*

    If you set that value to a common header name, such as "MyProject-Swift.h", it will be applied to each of your targets and you can safely use the import declaration in any of your Objective-C files. This allows you to continue using unique product module names for each target, if needed.

    I've tested this in Xcode Version 6.4 (6E35b).

    *Note: This will appear under your Swift compiler settings, which are only visible if you have Swift source files added to your project. Additionally, if a target doesn't have any Swift source associated with it, the Swift compiler options will not be visible for that target's build settings.

    Good luck!

提交回复
热议问题