On Oct 13, 2016, at 06:13 , David Hoerl <email@hidden> wrote:
I did this, but no matter what I try, I cannot get this to work:
- construct a Swift 3 only framework and add it to my app - insure that the framework is in the link phase, and there is a dependency on it - insure that "Defines Module" is enabled - add a "@import MyFramework;" line to an Objective C .m file in the app
Build: - the framework builds, I see the MyFramework-Swift.h file - Objective C app files that have the @import MyFramework; generate errors: "Cannot access such and such a property on a forward class declaration."
If this is *precisely* what you did, then you might be Doing It Wrong™.
The document you linked to describes 3 separate use cases:
1. Mixed Swift and Obj-C in an app target.
2. Mixed Swift and Obj-C in a framework target.
3. External framework.
You’re doing #3. In that case, the instructions are very short:
make sure the Defines Module build setting for the framework you’re importing is set to “Yes” It’s the “Defines Module” setting in the *framework* target that matters, not in the app target (and in that case the MyFramework-Swift.h file is irrelevant: it’s only for mixing code *within* a target).
So, on the face of it, there could be two errors in what you’re doing:
a. Your framework target has “Defines Module” set to NO.
b. Your app target doesn’t know that the framework exists for compile purposes. It’s not enough for the framework to be linked against, e.g. if specified only in the link phase or specified as a linker option. You have to add the framework reference to the project (typically in the project’s General tab, under “Embedded Binaries”). Note that a Swift framework has to be embedded, since binary ABI compatibility is *not* yet available.
What you’ll actually do here depends whether the framework target is in the same project and/or workspace as the app target. You weren’t clear on that point.
I’m hoping your problem is one of these two straightforward things. Otherwise, tracking down the problem gets harder.
P.S. I guess I should add another simple error:
c. Your framework target must have its module name build setting set to or defaulted to “MyFramework”. |