如何将私有框架导入Xcode 9.2(iOS 11),swift

如何将私有框架导入Xcode 9.2(iOS 11),swift,ios,swift,frameworks,private,xcode9.2,Ios,Swift,Frameworks,Private,Xcode9.2,我想测试一些用于研究目的的东西(不是应用商店!),其中我想使用Xcode 9.2(iOS 11)中的私有框架。为此,我需要将我想要使用的私有框架导入到我的Xcode项目中 但在Xcode 9.2的文件夹结构中,private frameworks文件夹不存在 有什么想法可以实现这一点吗?私有框架就像公共框架一样是一个捆绑包。您可以使用以下命令显式加载它: if let framework = Bundle(path: "/System/Library/PrivateFrameworks/Batt

我想测试一些用于研究目的的东西(不是应用商店!),其中我想使用Xcode 9.2(iOS 11)中的私有框架。为此,我需要将我想要使用的私有框架导入到我的Xcode项目中

但在Xcode 9.2的文件夹结构中,private frameworks文件夹不存在


有什么想法可以实现这一点吗?

私有框架就像公共框架一样是一个捆绑包。您可以使用以下命令显式加载它:

if let framework = Bundle(path: "/System/Library/PrivateFrameworks/BatteryCenter.framework") {
    // Works only on real devices
    framework.load()
}
但是您需要为包含的类声明。您可以使用as-Objective C头创建它们,并将over-a桥接头导入Swift

使用
类转储/../PrivateFrameworks/XXX.framework/XXX
执行
类转储。您需要将框架作为二进制文件,而不是
*.tbd
文件。
BatteryCenter.framework
示例:

类dump/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/privateframes/BatteryCenter.framework/BatteryCenter.framework/BatteryCenter

这将打印框架中包含的所有类的类声明

注意,在设备或模拟器上,您应该使用

/System/Library/PrivateFrameworks/BatteryCenter.framework

用于加载捆绑包。

私有框架就像公共框架一样是捆绑包。您可以使用以下命令显式加载它:

if let framework = Bundle(path: "/System/Library/PrivateFrameworks/BatteryCenter.framework") {
    // Works only on real devices
    framework.load()
}
但是您需要为包含的类声明。您可以使用as-Objective C头创建它们,并将over-a桥接头导入Swift

使用
类转储/../PrivateFrameworks/XXX.framework/XXX
执行
类转储。您需要将框架作为二进制文件,而不是
*.tbd
文件。
BatteryCenter.framework
示例:

类dump/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/privateframes/BatteryCenter.framework/BatteryCenter.framework/BatteryCenter

这将打印框架中包含的所有类的类声明

注意,在设备或模拟器上,您应该使用

/System/Library/PrivateFrameworks/BatteryCenter.framework


用于加载捆绑包。

要使用哪个私有框架?你是怎么用的?请显示代码如果该框架在Cocoapods上,您可以通过pods安装,就像您为其他人安装一样。@Nitish不,它不在Cocoapods上,它是一个apple@PPL我想使用BatteryCenter.framework。到目前为止,我还没有编写任何代码,因为我不确定如何首先导入框架。您想使用哪个私有框架?你是怎么用的?请显示代码如果该框架在Cocoapods上,您可以通过pods安装,就像您为其他人安装一样。@Nitish不,它不在Cocoapods上,它是一个apple@PPL我想使用BatteryCenter.framework。到目前为止,我还没有编写任何代码,因为我不知道如何首先导入框架。我们如何使用类转储,我无法理解相同的内容。@nehaSingh:我已经扩展了我的帖子。我使用以下代码以给定路径访问包,该路径为零。NSBundle*bundle=[NSBundle bundleWithPath:@”/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks“;如果(![bundle load]){NSLog(@“Error”);//可能会引发异常}否则{u supporter=[NSClassFromString(@“BCBatteryDevice”)valueForKey:@“sharedInstance”];\u handler=[BCBatteryDeviceHandler alloc]init];}@nehaSingh:您的路径没有指向有效的框架bundle。请看我上面的帖子。SDK目录中的框架不包含有效的二进制文件。仅包含类dump.bathcenter.Framework无法加载或检查的.tbd文件在给定路径下不存在:/System/Library/PrivateFrameworks,我们如何使用类dump,我不能理解同样的内容。@nehaSingh:我已经扩展了我的帖子。我使用下面的代码以给定的路径访问包,该路径为零。NSBundle*bundle=[NSBundle bundleWithPath:@”/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks“;如果(![bundle load]){NSLog(@“Error”);//可能会引发异常}否则{u supporter=[NSClassFromString(@“BCBatteryDevice”)valueForKey:@“sharedInstance”];\u handler=[BCBatteryDeviceHandler alloc]init];}@nehaSingh:您的路径没有指向有效的框架bundle。请看我上面的帖子。SDK目录中的框架不包含有效的二进制文件。类dump.bathcenter.Framework无法加载或检查的just contain.tbd文件在给定路径:/System/Library/PrivateFrameworks中不存在,