在Swift中使用LSApplicationWorkspace

ble*_*908 4 xcode frameworks iphone-privateapi ios swift

我已经将MobileCoreServices.framework添加到我的Xcode项目中,并将该语句import MobileCoreServices放在文件顶部。

我有代码行

let test = LSApplicationWorkspace.defaultWorkSpace()

和xcode说 Unresolved Identifier LSApplicationWorkspace

我尝试清理和重建项目。有任何想法吗?

Meh*_*kar 5

要点1: LSApplicationWorkspace是私有api,因此,如果使用它并将应用程序上载到应用程序商店,它将被拒绝。

要点2:如果您有任何内部应用程序,但仍想在应用程序中使用它,则下面是使用它的方法。

  1. MobileCoreServices在捆绑包中添加框架
  2. LSApplicationWorkspace.h使用与此处“ https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/MobileCoreServices.framework/LSApplicationWorkspace.h ”中提供的代码完全相同的代码创建文件。
  3. 现在将此LSApplicationWorkspace.h文件添加 到您的捆绑包中
  4. 为您的快速应用程序创建桥接头
  5. 添加#import "LSApplicationWorkspace.h"您的桥接头
  6. 现在添加import MobileCoreServices您的当前文件并添加您的代码let test = LSApplicationWorkspace.defaultWorkSpace(),它将正常工作。

注意:要使用任何专用标头,必须必须将其.h文件包含在代码中。您可以通过在Google中搜索“运行时标头”来找到任何私有标头。您将获得所有运行时标头。并将该标头包含在您的快速代码中,您需要通过桥接标头。