1

I have a project with large amount of obj-c and swift code inside it.

I have an obj-c class which imports ProjectName-Swift.h to let that class access swift code.

Now I need to expose that obj-c class to the swift so I can access it from swift code.

The problem is that after import in bridging header name of obj-c class project stops building with error that it cannot find ProjectName-Swift.h which import is stated in obj-c class.

I cannot remove import of ProjectName-Swift.h from obj-c class because after that class breaks.

What can I do ?

3
  • Import ProjectName-Swift.h in .m file Commented Nov 29, 2016 at 18:51
  • I have such import Commented Nov 29, 2016 at 19:00
  • Full tutorial to use Swift code in Objective-C project here: stackoverflow.com/a/40887287/4488252 Commented Dec 1, 2016 at 17:41

1 Answer 1

1

OK, had one answer and then re-read the question. Make absolutely certain that your import of the swift header is the Module Name of the project (not necessarily the project name):

Apple Documentation: Swift and Objective-C in the Same Project

More specifically, go to the section marked "Importing Swift into Objective-C" and read it. And even more specifically:

  1. Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to “Yes”.

  2. Import the Swift code from that framework target into any Objective-C .m file within that framework target using this syntax and substituting the appropriate names:

    #import <ProductName/ProductModuleName-Swift.h>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.