How to import an objective-c framework into a SwiftUI app in Xcode 13?

Hi,

I followed some online guides to import an objective-c framework into a SwiftUI app but did not work correctly. I am using Xcode 13.4. Here are the problems and my questions:

  1. The objective-c framework (Cronet from Chromium) has multiple versions:

Debug-iphonesimulator

Debug-iphoneos

Release-iphoneos

But in Xcode, the SwiftUI app only has one target, i.e. no different targets for Debug or Release, or iPhone device vs. Simulator.

Which version of the objective-c framework should I import for the SwiftUI app target?

  1. I tried to import the version of "Debug-iphonesimulator" into SwiftUI app. The import seems to be OK, i.e. it shows under "Frameworks", but if I click the framework name, there are no header files listing. (see attached screenshots).

Is there supposed to be a list of header files from the framework after importing? How can I use the framework if no header files available in the project?

Thanks.

Replies

If you want to use a framework from multiple platforms — and keep in mind that iOS and the iOS simulator are different platforms — you need to package it as an XCFramework. If this framework is from a third-party vendor, I encourage you to escalate this via that vendor’s support channel; it’s likely that either the vendor or some other third-party developer has done this already.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Is this required only for Swift apps? I have another (older) version of the same app that is written in Objective-C, and XCode allows me to specify different versions of the framework for the different platforms.

Add a Comment