Swift Blocker

I did some work to switch Vesper over to frameworks. In a framework I built for FMDB, a public header file has the following line:

#import "sqlite3.h"

That’s not allowed by default. But there’s an Xcode setting for it: “Allow Non-modular Includes in Framework Modules.”

This setting is the user-friendly version of CLANG​_ALLOW​_NON​_MODULAR​_INCLUDES​_IN​_FRAMEWORK​_MODULES. Here’s what Xcode’s Quick Help has to say:

Enabling this setting allows non-modular includes to be used from within framework modules. This is inherently unsafe, as such headers might cause duplicate definitions when used by any client that imports both the framework and the non-modular includes themselves.

Okay. I understand the issue and I’m willing to press the button — and I did, and everything works. Great.

Well, until I added some Swift code that imports that framework. Then I get the error:

Include of non-modular header inside framework module 'FMDB.FMDatabase'

Swift apparently doesn’t respect the CLANG​_ALLOW​_NON​_MODULAR​_INCLUDES​_IN​_FRAMEWORK​_MODULES setting, while Objective-C does.

Filed as rdar://20184784.

The bug report includes a small sample project that you can download: NonModularBug.zip.

Why I’m blocked

The VesperData framework — where VSNote, VSTag, and VSAttachment live — depends on QSDB (similar in purpose to FCModel) which depends on FMDB.

The upshot is that I can’t write any Swift code that references the data model. Which doesn’t leave me a whole lot else. (Given what’s already completed or at least started as Objective-C files.)

(Half of my friends — Gus included — are shouting at the monitor that this is a feature of FMDB and I should take it as a sign.)

16 Mar 2015

Archive