Reputation: 71
I want to test something for research purposes (not App Store!) in which I want to use the private frameworks in Xcode 9.2 (iOS 11). For that, I needed to import the private framework I want to use to my Xcode project.
But in Xcode 9.2 in folder structure private frameworks folder is not present.
Any ideas through which I can achieve that?
Upvotes: 2
Views: 2968
Reputation: 17711
A private framework is just a bundle like a public framework. You can load it explicitly with:
if let framework = Bundle(path: "/System/Library/PrivateFrameworks/BatteryCenter.framework") {
// Works only on real devices
framework.load()
}
But you need declarations for the included classes. You might create them with class-dump
as Objective C headers, and import the over a bridging header into Swift.
You execute class-dump
with class-dump /.../PrivateFrameworks/XXX.framework/XXX
. You need the framework as binary not as *.tbd
file. Example for BatteryCenter.framework
:
class-dump /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/BatteryCenter.framework/BatteryCenter
This will print you class declarations for all classes contained in the framework.
Note, on a device or a simulator you should use
/System/Library/PrivateFrameworks/BatteryCenter.framework
for loading the bundle.
Upvotes: 5