Skip to content

How to mix Swift & Objective-C in a static library? #3

@jsorge

Description

@jsorge

First, thank you so much for your blog post. It's been helping me a ton to figure this stuff out.

But I'm curious how I'd go about mixing Swift & Objective-C in a static library. I have a framework that I want to make into a static library that has a private module as well to share code internally between Swift & Objective-C code (so this would require a module.private.modulemap file, which also means I need to make my module map by hand).

I see that on a framework target, the built product has a Modules/module.modulemap file which has a sub-module to expose the Swift generated header to Objective-C like so:

framework module MyFramework {
  umbrella header "MyFramework.h"

  export *
  module * { export * }
}

module MyFramework.Swift {
    header "MyFramework-Swift.h"
    requires objc
}

I'm not sure if there's a way for me to manually make this file to also then have my private module map expose the internal Objective-C to my internal Swift.

If you've got any ideas on how I can proceed here I'd much appreciate it. Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions