我已将 MobileCoreServices.framework 添加到我的 Xcode 项目中,并且在我的文件顶部有语句 import MobileCoreServices
.
I've added MobileCoreServices.framework to my Xcode project, and have the statement import MobileCoreServices
in top of my file.
我有这行代码
让 test = LSApplicationWorkspace.defaultWorkSpace()
而xcode说Unresolved Identifier LSApplicationWorkspace
我尝试清理和重建项目.有什么想法吗?
I tried cleaning and rebuilding the project. Any ideas?
第1点: LSApplicationWorkspace 是私有的api,所以如果你使用这个并将你的应用上传到应用商店,它会被拒绝.
Point 1: LSApplicationWorkspace is private api, so if you use this and will upload your app to app store, it will get rejected.
第 2 点:如果您有任何内部应用,但仍想在您的应用中使用它,那么下面是使用它的方法.
Point 2: If you are having any in-house app and still want to use this in your app, then below is the way to use it.
MobileCoreServices
框架LSApplicationWorkspace.h
文件https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/MobileCoreServices.framework/LSApplicationWorkspace.h".LSApplicationWorkspace.h
文件添加到您的包中#import "LSApplicationWorkspace.h"
import MobileCoreServices
并添加你的代码let test = LSApplicationWorkspace.defaultWorkSpace()
,它就可以正常工作了.MobileCoreServices
Framework in your bundleLSApplicationWorkspace.h
file with the code exactly same as the code provided at here "https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/MobileCoreServices.framework/LSApplicationWorkspace.h".LSApplicationWorkspace.h
file into your bundle#import "LSApplicationWorkspace.h"
in your bridging headerimport MobileCoreServices
in your current file and add your code let test = LSApplicationWorkspace.defaultWorkSpace()
, it will work fine.注意:要使用任何私有标头,您必须将其 .h
文件包含到您的代码中.您可以通过在 google 中搜索运行时标头"来找到任何私有标头.您将获得所有运行时标头.要在您的 swift 代码中包含该标头,您需要通过 bridging-header.
NOTE: For using any private header, you must have to include its .h
file into your code. You can find any private headers by searching "runtime headers" in google. You will get all runtime headers. And to include that header in your swift code, you need to go via bridging-header.
这篇关于在 Swift 中使用 LSApplicationWorkspace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!