Integrating a Framework (having Swift) in a strict ObjC consuming Project

If your consuming (or sample) project is fully ObjC, no single line (or no empty file) of Swift, and you want to consume a Framework that has Swift. I know the typical "trick" of using an empty.swift file, but is there something more "neat"?

Do you really need to do anything? I have just set up a project like that and can’t remember doing anything extra. In the worst case the linker will forget to include Swift runtime, but that can be fixed with a single flag.

Which flag would that be? From my test right now this is what adding a .swift file adds:

LastSwiftMigration = 0940;
CLANG_ENABLE_MODULES = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";   /* Only in DEBUG Configuration */
SWIFT_VERSION = 3.0;

It’s Always Embed Swift Standard Libraries, not sure about the symbol, not at a (proper) computer right now.

That's interesting (Always Embed) but my project works without this.

It works but the binary will be rejected by the App Store.

BTW if you don't do anything not even the linker complains but the runtime does:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /path.to/ObjC.app/Frameworks/Driver.framework/Driver
  Reason: image not found
(lldb)

So from my test I don't need any of the the flags up there that are added when I add a file, but I only need ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES. Thanks @zoul and @gwendal.roue for helping. It was important for me to know what I need to tell to the users of the framework.

1 Like