正在执行像"defaults write com.blahblah key true"这样的命令私有API吗?

use*_*624 3 cocoa appstore-approval mac-app-store

Mac App Store指南说您不能使用私有API.

我正在玩一个使用终端命令将showAllFiles设置为true来修改Finder设置的应用程序:

defaults write com.apple.Finder AppleShowAllFiles TRUE
Run Code Online (Sandbox Code Playgroud)

有没有办法能够将这样的东西提交到Mac App Store?对我来说它似乎是一个私人API.我的问题是:是否有公共等价物?

Tod*_*orf 5

我认为这取决于你如何执行这个命令.您使用哪些C/ObjC API来执行此操作?肯定有公共API可用于执行此命令.

但是,要记住的一件重要事情是Apple将要求提交到Mac App Store的应用程序从2012年3月开始采用他们的"沙盒"计划.文档在这里:

http://developer.apple.com/library/mac/#documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html

我怀疑在沙盒应用程序中执行此命令(甚至通过公共API)将要求您声明需要特殊权利.有关权利的更多详情:

http://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/EntitlementKeyReference/Introduction/AboutEntitlements.html%23//apple_ref/doc/uid/TP40011195

具体来说,我认为你可能需要这个"临时权利":

com.apple.security.temporary-exception.files.home-relative-path.read-write
Run Code Online (Sandbox Code Playgroud)

因为我认为编写像Finder这样的应用程序的用户默认值需要写入用户主目录下的磁盘上的文件:

~/Library/Preferences/com.apple.finder.plist
Run Code Online (Sandbox Code Playgroud)