1

I have a project that is mostly Swift, but has some (internal) Objective-C code wrapping around CommonCrypto functions. It took some some tinkering, but we managed to make it work without exposing the internals by making all the headers private and using a bridging header, not added to any target but referenced in build setting "Objective-C Bridging Header" (on the targets, not the project).

Now we decided to move this part of the project into its own framework. So I created a new project (as Cocoa Touch Framework, same as the old), copied over the necessary source files, recreated the bridging header, and expected it to compile.

However, I'm getting

error: using bridging headers with framework targets is unsupported

This is confusing since there is one in the other project, which builds just fine (for iOS and macOS).

I went through all of the build settings, project and target. The only differences are

  • iOS target version 10.3 (new) vs 10.2 (old),
  • no signing vs signing (that may just be because the new project never built), and
  • some static analysis setting about suspicious conversions.

Neither of those should impact this matter. Nevertheless, I confirmed that the new project doesn't build for 10.2, either.

So what's going on here?

Raphael
  • 9,779
  • 5
  • 63
  • 94
  • Did you have a look at [Importing CommonCrypto in a Swift framework](https://stackoverflow.com/questions/25248598/importing-commoncrypto-in-a-swift-framework) ? – Martin R Jun 01 '17 at 07:24
  • @MartinR My issue is not with CommonCrypto. It's with compiling my own Objective-C without exposing the headers to the outside of the framework, and why an approach that works with one project doesn't with the other. – Raphael Jun 01 '17 at 07:29
  • Of course, importing CommonCrypto in a way that makes it possible to use without an intermediate Objective-C layer would circumvent the issue (causing some rewriting) -- but not solve it! – Raphael Jun 01 '17 at 07:40
  • Is you CocoaTouch Framework in Swift or in Objective-C ? If it's in Swift, take a look at this post: https://stackoverflow.com/questions/31751547/how-to-import-objective-c-static-library-to-swift-framework – Duyen-Hoa Jun 01 '17 at 08:02
  • @Hoa It's Swift, but I'm not trying to import a static library; the sources are right there in my project. Can you please elaborate how that post helps me? – Raphael Jun 01 '17 at 08:17
  • I thought that you want to import the CommonCrypto static library to your Swift framework. But anyway, in this topic, there is an answer about using module map. I think that you can use it to import Objective-C .h in your Swift framework. – Duyen-Hoa Jun 01 '17 at 08:36
  • 1
    @Hoa 1) I'm only using CommonCrypto from the Objective-C files right now, so that's not an issue. 2) We tried module maps before but had issues with deployment down the road: the framework built on machine A wouldn't work on B because of linking errors due to different paths. The bridging header was the solution that (finally!) worked. – Raphael Jun 01 '17 at 08:43

0 Answers0