Cannot reference classes and methods of a Swift universal framework from Objective-C universal framework

Hi,

I have an Objective-C framework called "Box" that uses a Swift framework called "Utils". Both have a standard target which I use during development, plus a custom target which I use when the development is done and I need to build a universal framework.


Until Xcode 10.2/swift 4 all worked well and I was able to compile both "Box" and "Utils" universal frameworks and use them in a test app written in swift, or as frameworks inside other frameworks.


Switching to Xcode 10.2/swift 5 I cannot reference objects and methods of "Utils" from "Box" anymore, at least not for all targets.

If I use the "Box" standard target and a real device I can build the framework and run them into a test app. I can point and click "Utils" objects/methods from "Box" so I can reference them.

If I use the "Box" standard target and a simulator I cannot build the framework and I have errors like:

"No visible @interface for 'UIColor' declares the selector 'initWithHexString:'" -> initWithHexString is a method declared into an extension of UIColor inside "Utils" framework
"use of undeclared identifier 'StringUtils'" -> StringUtils is a class declared inside "Utils" framework

the same if I try to build the "Box" universal framework with its custom target (target with the classic script used to build universal frameworks)


So for an unknown reason, starting from Xcode 10.2, for some target I cannot reference "Utils" framework from "Box" anymore.

All the methods are marked with @objc so that is not the problem.


Any idea about what could be the problem?

I don't know if I have to add some other useful information...


Thanks a lot!


Update: I tried to import "Utils" framework into a Swift framework created on the fly to do a test. And it seems to work. So it seems a problem when I try to import Swift "Utils" framework into Objective-C "Box" framework.

Replies

I believe you are using the term “universal framework” to indicate a framework that supports iOS devices and iOS simulators. If so, be aware that this is not supported officially, because iOS and the iOS simulator are two different platforms, and all of the slices of a universal framework must be for the same platform. Read this thread for more.

Despite this, I suspect that the Xcode 10.2 problem you’re seeing is a known issue and you can learn more about it in the Xcode 10.2 Release Notes (see for “48635615”).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo,

you were right and the problem was due to the Xcode's 10.2 "48635615" known issue.

The forum thread you suggest me was wery helpful to understand the problem, thank you.

With your suggestions I have also found this thread

https://forums.developer.apple.com/thread/115433

that pointed me to this github webpage

https://gist.github.com/Shehryar/0c29cce7eead9c724b4c16b018bab63f

with a script that solved my problem (with a little customization of mine).


I have also opened a suggestion/enhancement request to apple to highlight that would be extremely useful for us developers apple's support of "fat frameworks".


Thank you so much for your precious support

I have also opened a suggestion/enhancement request to apple to highlight that would be extremely useful for us developers apple's support of "fat frameworks".

Thanks. What was your bug number?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"