Capabilities 开启SandBox权限--转载--https://juejin.cn/post/6844904199688290318
应用开发完成提交到App Store时,必须进行沙盒化。切换到工程target设置Tab的Capabilities中。
- 第一项就是App SandBox开关,点击ON,表示应用使用沙盒。
- Network:网络访问控制
Incoming Connections (Server)
: 应用做为Server对外提供HTTP,FTP等服务时需要打开。如果你的App担任服务器角色,需要连接通信需要开启此权限。Outgoing Connections (Client)
: 做为客户端,访问服务器时需要打开。如果你的App需要作为客户端进行socket连接通信需要开启此权限。
- Hardware:硬件资源控 它包含下面这些子项:
- App Data:获取系统的联系人,位置,日历服务时需要打开
Contacts
: 如果要访问联系人,需要勾选此项Location
: 如果需要定位,需要勾选此项。Calendar
: 如果需要访问日历,需要勾选此项。
特别注意:如果应用中不需要的权限项,一律不要打开。否则App Review团队会拒绝你的应用上架.
3.1.2 Entitlements 直接变xml,开启SandBox权限
实际上,在沙盒中每个需要访问权限的项都对应一个key,对应的value,YES 或 NO表示是否允许访问。当你选择了项后,都会记录在一个扩展名为.entitlements的plist 的文件中,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<? xml version = "1.0" encoding = "UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
< key >com.apple.security.app-sandBox</ key >
< true />
< key >com.apple.security.assets.movies.read-write</ key >
< true />
< key >com.apple.security.assets.music.read-only</ key >
< true />
< key >com.apple.security.assets.pictures.read-only</ key >
< true />
< key >com.apple.security.cs.allow-dyld-environment-variables</ key >
< true />
< key >com.apple.security.cs.allow-jit</ key >
< true />
< key >com.apple.security.cs.allow-unsigned-executable-memory</ key >
< true />
< key >com.apple.security.cs.disable-executable-page-protection</ key >
< true />
< key >com.apple.security.cs.disable-library-validation</ key >
< true />
< key >com.apple.security.device.audio-input</ key >
< true />
< key >com.apple.security.device.camera</ key >
< true />
< key >com.apple.security.device.usb</ key >
< true />
< key >com.apple.security.files.bookmarks.app-scope</ key >
< true />
< key >com.apple.security.files.downloads.read-write</ key >
< true />
< key >com.apple.security.files.user-selected.read-write</ key >
< true />
< key >com.apple.security.network.client</ key >
< true />
< key >com.apple.security.network.server</ key >
< true />
< key >com.apple.security.personal-@R_991_404[email protected]</ key >
< true />
< key >com.apple.security.print</ key >
< true />
< key >com.apple.security.temporary-exception.apple-events</ key >
< array >
< string >com.apple.itunes</ string >
</ array >
< key >com.apple.security.temporary-exception.files.absolute-path.read-write</ key >
< true />
< key >com.apple.security.temporary-exception.shared-preference.read-only</ key >
< array >
< string >com.apple.iphoto</ string >
< string >com.apple.photobooth</ string >
< string >com.apple.photos</ string >
</ array >
</ dict >
</ plist >
复制代码
|
应用打包时会对这个文件进行签名。 当应用运行期间要获取某个权限时,系统都会通过.entitlements
去检查应用是否有授权,如果没有就拒绝访问。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。