我想使用Swift来改变默认的应用程序来处理一个给定的文件类型(例如,MacOS )。
在macOS 10.13.6 (高塞拉)/ Xcode版本7.3 (7D175)上运行时出现错误-可能“基础”没有正确导入?在网上搜索了一大堆,但找不到解决方案...
import Foundation
LSSetDefaultRoleHandlerForContentType("com.adobe.pdf" as CFString, LSRolesMask.all, "com.adobe.Acrobat.Pro" as CFString)这是我得到的错误,有什么想法吗?谢谢!
Playground execution failed: Test KM.playground:3:1: error: use of unresolved identifier 'LSSetDefaultRoleHandlerForContentType'
LSSetDefaultRoleHandlerForContentType("com.adobe.pdf" as CFString, LSRolesMask.all, "com.adobe.Acrobat.Pro" as CFString)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test KM.playground:3:68: error: use of unresolved identifier 'LSRolesMask'
LSSetDefaultRoleHandlerForContentType("com.adobe.pdf" as CFString, LSRolesMask.all, "com.adobe.Acrobat.Pro" as CFString)
^~~~~~~~~~~发布于 2019-01-22 22:52:22
我想通了。出于某种原因,在我的Swift版本上(如果是模块?)我不得不使用LSRolesMask.All (vs LSRolesMask.all)。
https://stackoverflow.com/questions/54307691
复制相似问题