iOS开发中怎么创建Plist文件

iOS开发中怎么创建Plist文件,第1张

Info.plist配置项说明1、设置启动图标(CFBundleIcons)<key>CFBundleIcons</key><dict><key>CFBundlePrimaryIcon</key><dict><key>CFBundleIconFiles</key><array><string>Icon</string><string>Icon@2x</string><string>Icon_120@2x</string></array></dict></dict>2、设置启动闪屏图片(UILaunchImages)<key>UILaunchImages</key><array><dict><key>UILaunchImageMinimumOSVersion</key><string>7.0</string><key>UILaunchImageName</key><string>Default</string><key>UILaunchImageOrientation</key><string>Portrait</string><key>UILaunchImageSize</key><string>{320, 568}</string></dict><dict><key>UILaunchImageMinimumOSVersion</key><string>7.0</string><key>UILaunchImageName</key><string>Default</string><key>UILaunchImageOrientation</key><string>Portrait</string><key>UILaunchImageSize</key><string>{320, 480}</string></dict></array>3、设置版本号相关(1)设置Bundle的版本号(Bundle versions string, short)。一般包含该束的主、次版本号,这个字符串的格式通常是“n.n.n”(n表示某个数字,如1.1.1)。第一个数字是束的主要版本号,另两个是次要版本号。该关键字的值会被显示在Cocoa应用程序的关于对话框中。该关键字不同于CFBundleVersion,它指定了一个特殊的创建号。而CFBundleShortVersionString的值描述了一种更加正式的并且不随每一次创建而改变的版本号。<key>CFBundleShortVersionString</key><string>1.0</友猛string>(2)设置应用程序版本号(Bundle version)。每次部署应用程序的一个新版本时,将会增加这个编号,用于标识不同的版本。<key>CFBundleVersion</key><string>1.0</string>4、设置字体相关(Fonts provided by application)在iOS应用中需要使用系统提供的字体之外的字体,可以将字体文件(.ttf/.odf)复制到项目文件中,另外需要在Info.plist中添加Fonts provided by application的项,对应的源码文件如下:<key>UIAppFonts</key><array><string>华文行楷.ttf</string><string>华文新魏.ttf</string><string>黑体_GB2312.ttf</string></array>P.S关于如何使用系统支持的字体信息:(1)在调用字体的时候,要使用字体名。字搭猛体名不是文件名,而是字体的Family Name。Family Name可以在Font Book中查看。label.font = [UIFont fontWithName:@"字好枝桥体名称" size:16.0](2)遍历出系统支持的全部字体NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]]for(int indFamily = 0indFamily <familyNames.count++indFamily){NSLog(@"Family Name: %@", [familyNames objectAtIndex:indFamily])NSString *fontFamilyName = [familyNames objectAtIndex:indFamily]NSArray *fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:fontFamilyName]]for(int indFont = 0indFont <fontNames.count++indFont){NSLog(@" Font Name: %@", [fontNames objectAtIndex:indFont])}}5、设置应用名称(Bundle display name)<key>CFBundleDisplayName</key><string>应用程序名称</string>可以通过在InfoPlist.strings中使用配置让应用在不同的语言环境下显示不同的应用名称,如在English中使用CFBundleDisplayName="Hello World"配置应用程序的名称为Hello World,在Chinese的环境下使用CFBundleDisplayName="你好世界"配置应用程序的名称为你好世界。6、设置应用标识号(Bundle identifier)<key>CFBundleIdentifier</key><string>com.devzeng.demo</string>7、设置应用支持的屏幕方向(Supported interface orientations)iOS应用程序支持以下四个方向的设置:UIInterfaceOrientationPortrait(默认竖直方向,HOME键向下)、UIInterfaceOrientationLandscapeLeft(横屏靠左)、UIInterfaceOrientationLandscapeRight(横屏向右)和UIInterfaceOrientationPortraitUpsideDown(竖直方向倒置,HOME键向上)对应的配置源码如下:<key>UISupportedInterfaceOrientations</key><array><string>UIInterfaceOrientationPortrait</string><string>UIInterfaceOrientationLandscapeLeft</string><string>UIInterfaceOrientationLandscapeRight</string><string>UIInterfaceOrientationPortraitUpsideDown</string></array>8、设置应用程序是否支持后台运行(Application does not run in background)通过UIApplicationExitsOnSuspend可以设置iOS的应用程序进入到挂起状态下是否立即退出,设置为YES表示不支持后台运行退出到后台立即退出,设置为NO表示支持后台运行。(1)设置支持后台运行<key>UIApplicationExitsOnSuspend</key><false/>(2)设置不支持后台运行<key>UIApplicationExitsOnSuspend</key><true/>

1、首先使用弯慧企业证书打包应用ipa文件并埋乎答发布到资源服务器。<br>2、其次生成plist文件,在文件配置汇中设置ipa文件路径,指向上一步中生成ipa文件下载路径,发布plist文件。<br>3、最后创建下载页面,页面中添加标签下载安装顷燃按钮,href指向上一步汇总plist文件url,发布页面。

plist文件在iOS系统中一类非常重要的配置文件,Mac上提供了对plist文件 *** 作的命令,方便脚本生成想要的plist文件,下面将对其作一个介绍

首先命令是/usr/libexec/PlistBuddy,默认可能没有加到Path当中,需要全路径运行,你也可以回到Path里面。

首先看看脚本的基蠢盯本格式:

/usr/libexec/PlistBuddy -c "�Add :dict1:item1 integer 1" new.plist

其中Add :dict1:item1 integer 1是PlistBuddy需要解析的命令,new.plist是保存的plist文件。

运行命令生成的结果:

:dict1:item1使用:符号来对层进行分组,PlistBuddy平常能用到的命令包括:

Add[] - Adds Entry to the plist, with value Value  

Set- Sets the value at Entry to Value

 Delete- Deletes Entry from the plist  

set与delete前字段必须存在,不然会报错Set: Entry, ":dict1:item2", Does Not Exist

add的之前字段不能存在,拆戚否则也会报错,如/usr/带御和libexec/PlistBuddy -c "Add :dict1:item1 integer 2" new.plist

Add: ":dict1:item1" Entry Already Exists

item1仍然保留1的值。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12258069.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存