ios info.plist知多少「建议收藏」 -金沙1005

ios info.plist知多少「建议收藏」文章目录一、什么是info.plist二、info.plist长什么样1info.plist的打开方式2每个key的含义三、info.plist中的常见的keys类别1corefoundationkeys2lanchserviceskeys3cocoakeys4appextensionkeys四、读取info.plist一、什么是info.plistios中很多功能需要配置info.plist才能实现,如设置后台运行、支持打开的文件类型等。了解info.plist中各字段及其含

一、什么是info.plist

ios中很多功能需要配置info.plist才能实现,如设置后台运行、支持打开的文件类型等。了解info.plist中各字段及其含义,可以访问苹果开发网站相关文档,

苹果官方对info.plist的定义:
to provide a better experience for users, ios and macos rely on the presence of special metadata in each app or bundle. this metadata is used in many different ways. some of it is displayed to the user, some of it is used internally by the system to identify your app and the document types it supports, and some of it is used by the system frameworks to facilitate the launch of apps. the way an app provides its metadata to the system is through the use of a special file called an information property list file, or info.plistfor short.
a property list is a way to structure arbitrary data that the system can access at runtime. an information property list is a specialized type of property list that contains configuration data for a bundle. the keys and values in the file describe the various behaviors and configuration options you want applied to your bundle. an xcode project template typically specifies an information property list file with an initial set of keys and appropriate default values. you can edit the file to change or add keys and values, as appropriate for your project.
翻译:
为了提供更好的用户体验,ios 和 macos 的每个app或bundle都依赖于特殊的元数据。元数据有多种用途,包括:直接向用户展示信息;系统内部用来标识你的app或其支持的文档类型;系统框架用来辅助app的加载等。这个提供给系统的元数据是通过一个名字叫 information property list file(属性列表文件)的特殊文件来实现的,这个特殊的文件简称 info.plist
info.plist可用来构建任意数据,这些数据在运行时是可访问的。info.plist是每个bundle的专属配置,info.plist文件中的keys和values描述了许多要应用于该bundle的行为以及配置选项。xcode工程通常会自动创建一个info.plist,并且提供许多合适的keys以及其对应的默认的values。我们可以修改或增加keys和values。

二、info.plist长什么样

1 info.plist的打开方式

xcode工程中打开
在这里插入图片描述
代码打开方式
在这里插入图片描述

2 每个key的含义

属性 名称 类型 描述
cfbundledevelopmentregion localization native development region string 本地化相关数据,如果用户没有响应的语言资源,则默认使用这个key的value
cfbundleexecutable executable file string 程序安装包的名称
cfbundleidentifier bundle indentifier string 唯一标识字符串
cfbundleinfodictionaryversion infodictionary version string info.plist格式的版本信息,xcode会自动填写,不要修改这个值
cfbundlename bundle name string 程序安装后在界面上显示的名称
cfbundlepackagetype bundle os type code string 例:bndl、appl、fmwk。
cfbundleshortversionstring bundle versions string, short string 版本号,三位,例:1.0.0。
cfbundletypeostypes bundle creator os type code array of strings 该字段包含了一组映射到这个类型的四字母长的类型代码。为了打开所有类型的文档,可以把它设为 “****” 。
cfbundleversion bundle version string 应用程序版本号,每次部署应用程序的一个新版本时,应该增加这个编号,app store审核需要用
lsrequiresiphoneos application require iphone environment boolean 用于指示程序包是否只能运行在iphone os 系统上。默认是yes
uilaunchstoryboardname launch screen interface file base name string 程序启动时的所加载的启动画面,主要成xib文件中加载,这里的值为launchscreen,说明从launchscreen.storyboard中加载
uimainstoryboardfile mian storyboard file base name string 程序的启动时的主画面,此文件中的视图将作为程序启动后的主画面
uisupportedinterfaceorientations supported interface orientations array of strings 横竖屏设置,uiinterfaceorientationportrait,uiinterfaceorientationportraitupsidedown,uiinterfaceorientationlandscapeleft,uiinterfaceorientationlandscaperight
uirequireddevicecapabilities required device capabilities array of strings 应用程序运行所需的设备限制,

三、info.plist中的常见的keys类别

根据功能的分类,info.plist文件的keys大致划分为以下几类

1 core foundation keys

该类的keys的特点是以cf为前缀,用以代表core foundation,描述了一些常用的行为项
详见官方文档

2 lanch services keys

该类的keys的特点是以ls为前缀。加载服务项,提供了app加载所依赖的配置,描述了app启动的方式选择。
详见官方文档

常用的属性
lsbackgroundonly
如果该字段存在并且被设为“ 1 ”,启动服务将只会运行在后台。您可以使用该字段来创建无用户界面的后台应用程序。如果您的应用程序使用了连接到窗口服务器 的高级框架,但并不需要显示出来,您也应该使用该字段。后台应用程序必须被编译成 mach-o可执行文件。该选项不适用于cfm应用程序。
您也可以指定该字段的类型为 booleannumber。然而,只有 mac os x 10.2或以上的版本才支持这些类型的值。

lspreferscarbon
如果该字段被设为“ 1 ”finder将会在显示简介面板中显示“ 在 classic 环境中打开 ”控制选项,缺省情况下该控件未被选中。如果需要,用户可以修改这个控制选项来在 classic环境中启动应用程序。

您也可以指定该字段的类型为 booleannumber。然而,只有 mac os x 10.2或以上的版本才支持这些类型的值。如果您在您的属性列表中加入了该字段,那么就不要同时加入 lsprefersclassic, lsrequirescarbon, 或lsrequiresclassic字段 。

lsprefersclassic
如果该字段被设为“ 1 ”finder将会在显示简介面板中显示“ 在 classic 环境中打开 ”控制选项,缺省情况下该控件被选中。如果需要,用户可以修改这个控制选项来在 carbon环境中启动应用程序。

您也可以指定该字段的类型为 booleannumber。然而,只有mac os x 10.2或以上的版本才支持这些类型的值。如果您在您的属性列表中加入了该字段,那么就不要同时加入lspreferscarbon, lsrequirescarbon, 或 lsrequiresclassic字段。

lsrequirescarbon
如果该字段被设为 “ 1 ”,启动服务将只在 carbon环境中运行应用程序。如果您的应用程序不应该运行在 classic环境中的话,可以使用该字段。

您也可以指定该字段的类型为booleannumber。然而,只有 mac os x 10.2或以上的版本才支持这些类型的值。如果您在您的属性列表中加入了该字段,那么就不要同时加入 lspreferscarbon, lsprefersclassic, 或 lsrequiresclassic字段。

lsrequiresclassic
如果该字段被设为 “ 1 ”,启动服务将只在classic环境中运行应用程序。如果您的应用程序不应该运行在carbon兼容环境中的话,可以使用该字段。

您也可以指定该字段的类型为 booleannumber。然而,只有 mac os x 10.2或以上的版本才支持这些类型的值。如果您在您的属性列表中加入了该字段,那么就不要同时加入 lspreferscarbon, lsprefersclassic, 或 lsrequirescarbon字段。

lsuielement
如果该字段被设为“ 1 ”,启动服务会将该应用程序作为一个用户界面组件来运行。用户界面组件不会出现在 dock或强制退出窗口中。虽然它们通常作为后台应 用程序运行,但是如果希望的话,它们也可以在前台显示一个用户界面。点击属于用户界面组件的窗口,应用程序将会处理产生的事件。
dock和登录窗口是两个用户界面组件应用程序。

3 cocoa keys

该类的keys的特点是以ns为前缀。cocoa框架或cocoa touch框架依赖这些keys来标识更高级别的配置项目,如appmain nib文件,主要类。这些key描述影响着cocoacocoa touch框架初始化和运行app的运行方式。
详见官方文档

常见的权限配置


<key>nsphotolibraryusagedescriptionkey>
<string>需要您的同意,app才能访问相册string>
<key>nscamerausagedescriptionkey>
<string>需要您的同意,app才能访问相机string>
<key>nsmicrophoneusagedescriptionkey>
<string>需要您的同意,app才能访问麦克风string>
<key>nslocationusagedescriptionkey>
<string>需要您的同意, app才能访问位置string>
<key>nslocationwheninuseusagedescriptionkey>
<string>app需要您的同意, app才能在使用期间访问位置string>
<key>nslocationalwaysusagedescriptionkey>
<string>app需要您的同意, app才能始终访问位置string>
<key>nscalendarsusagedescriptionkey>
<string>app需要您的同意, app才能访问日历string>
<key>nsremindersusagedescriptionkey>
<string>需要您的同意, app才能访问提醒事项string>
<key>nsmotionusagedescriptionkey>
<string>需要您的同意, app才能访问运动与健身string>
<key>nshealthupdateusagedescriptionkey>
<string>需要您的同意, app才能访问健康更新 string>
<key>nshealthshareusagedescriptionkey>
<string>需要您的同意, app才能访问健康分享string>
<key>nsbluetoothperipheralusagedescriptionkey>
<string>需要您的同意, app才能访问蓝牙string>
<key>nsapplemusicusagedescriptionkey>
<string>需要您的同意, app才能访问媒体资料库string>
ios info.plist知多少「建议收藏」

为防止网络爬虫,请关注公众号回复”口令”

激活idea 激活clion
datagrip dataspell
dotcover dotmemory
dottrace goland
phpstorm pycharm
resharper reshac
rider rubymine
webstorm 全家桶

4 app extension keys

app可能需要扩展默认的plist来描述更多的信息,如定制app启动后的默认旋转方向,标识app是否支持文件共享等等。
详见官方文档

四、读取info.plist

app运行的时候,需要读取info.plist中的信息,用以下代码可获取整个info.plist的信息

[[nsbundle mainbundle] infodictionary]

例,根据 key值去取 urltypes里面对应的值

 (nsstring *)urlschemesforkey:(nsstring *)key { 

nsdictionary *dict = [[nsbundle mainbundle] infodictionary];
nsarray *urltypes = dict[@"cfbundleurltypes"];
nsstring *urlschemes = nil;
for (nsdictionary *scheme in urltypes) { 

nsstring *schemekey = scheme[@"cfbundleurlname"];
if ([schemekey isequaltostring:key]) { 

urlschemes = scheme[@"cfbundleurlschemes"][0];
break;
}
}
return urlschemes;
}
js555888金沙老品牌的版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由思创斯整理,转载请注明出处:https://ispacesoft.com/129706.html

(0)

相关推荐

  • ios – opengl es 调节图像色度 gpuimagehuefilter目录 一.简介 二.效果演示 三.源码下载 二.猜你喜欢 零基础 opengl (es) 学习路线推荐 : opengl (es) 学习目录 >> opengl es 基础 零基础 ope

  • php如何实现ios推送[通俗易懂]php实现ios推送的方法:首先把要发送的消息以及iphone标识打包,并发给apns;然后查找有相应标识的iphone,并把消息发送到iphone;最后把发来的消息传递给相应的应用程序,并且按照设定弹出push通知即可。

  • ios逆向之深入解析如何hook所有 load方法及category的处理一、类方法 loadios四种方法可方便的在premain阶段执行代码:objectivec类的 load方法;c staticinitializer;c/c attribute(constructor)functions;动态库中的上面三种方法。所有类的 load方法是在main函数之前、在主线程,以串行方式调用,因此任何一个 load方法的耗时大小将直接影响到app的启动耗时。objectivecruntim

  • axios delete请求传参数_delete请求带body 1、问题; vue项目前台用axios发请求;由于之前也是一直用axios发请求,所以这一次遇到问题一脸懵逼; 请求方式:delete;请求头类型:application/json, charset=utf-8 看着没问题参数确实传了,但是后台就是收不到, 后台我用的是nodejs 解决:axios …

  • uni-app 真机测试ios上报错 request:fail abort

    uni-app 真机测试ios上报错 request:fail abort先吐槽一下我的心情,我tm这会想骂人!!!!!!简单说明下,我使用uni-app写了一个混合app,安卓真机测试一直没问题,之前用了几个ios也测试了,没什么问题,可以正常运行。然而昨天下午,客户过来了,需要给自己手机安装一下,回去测测效果。尴尬的事情来了,客户手机6p安装成功,打开后所有的uni-request请求直接走fail回调。。。我tm当时整个人都是蒙的,什么鬼???然…

  • ios提交应用至app store流程以及appstore开发者申请流程一、申请苹果开发者账号首先需要申请苹果开发者账号才能在appstore里发布应用。1、 准备材料1.1     公司的邓白氏编码给苹果公司发个邮件(或则直接拨打苹果开发者服务热线:40067018552)。他会给你提供免费注册邓白氏码的网址。直接注册就好.  https://developer.apple.com/ios/enroll/dunslo

  • vue-axios使用_vue 路由拦截
    axios是一个就promise的http库,可以用在浏览器和node.js中 main.js import vue from ‘vue’ import axios from ‘axios’ // 使用拦截器// 添加请求拦截器 axios.interceptors.response.use( re …

  • ios安卓模拟器_同步器使用教学【区分安卓和ios】>>>信任考验,同步器【区分安卓和ios】安卓同步器教学,同步器功能要在电脑端才能使用1.打开百度,下载雷电模拟器或者其他模拟器 同步器软件2.按照视频里的方法进行设置,如果用的是其他同步软件的话则自己选取两个火影的游戏进程,然后用同步器软件同步。3.适用于:帮助多个账号进行同类型活动,帮助小号打活动,制作同时放大或者同时出招的视频和素材。ios(苹果)同步器教学,同步…

发表回复

您的电子邮箱地址不会被公开。

联系金沙1005

关注“java架构师必看”公众号

回复4,添加站长微信。

附言:ispacesoft.com网而来。

关注微信
网站地图