2

Well, I want to know how to move some parts of framework from objective-c to swift without big pain

Ok, as far as I know:

1) Any project not a framework.

  • You make Swift-Bridging-Header.h or CatsAndGuns-Bridging-Header.h and put in it many import items.
  • You assure yourself in Build Settings -> (Search Swift) -> Objective-C Bridging Header. And put here your name.
  • Also check Packaging -> Defines Modules -> Yes

2) Framework

Well, you want to develop framework with mix objective-c and swift together.

And here you have pain: you can't use bridging headers in framework targets.

So, you come to google or documentation and start to read. Documentation

Ok, now you feel free and gorgeous about your knowledge, but.. you still don't know how to do it.

  • Create umbrella header and name it: YourProjectName-Swift.h. CatsAndGuns-Swift.h, ok.
  • Make it visible to framework level, so, navigate to right bar and put target membership -> your_framework_target (CatsAndGuns.framework in my case, of course) -> Public
  • And everything should be ok? remember to put every import as: #import <CatsAndGuns/Rocket.h>

Ok, let's check Rocket.h file in our framework. it is a Project-visible file, so, can it be accessed via in umbrella header (oh, module-swift.h) or not?

Now I have:

  • No bridging header in project ( as i understand from answer )
  • Manually created umbrella header with project-visible Rocket.h: #import <CatsAndGuns/Rocket.h>
  • errors in swift class that it can't see objective-c declarations.
  • Product module name without spaces.
Community
  • 1
  • 1
gaussblurinc
  • 3,642
  • 9
  • 35
  • 64
  • Do I read frustration in your question? :-) I went through this as well. By now, I think, it's currently not possible to expose private/internal headers/types within a framework. Still searching for an explanation of why a bridging-header can't be used in a framework. The generated "MyFramework-Swift.h"-header just works. So to make interoperability work in frameworks, all headers/types for mixed use have to be made public - which breaks a key-feature of frameworks. – Felix Lieb Jan 29 '16 at 15:20

0 Answers0