zoukankan      html  css  js  c++  java
  • 【ios】Settings 设置项

    成果展示

    1、创建Setttings.Bundle

    2、修改Root.plist

    <?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>PreferenceSpecifiers</key>
    	<array>
    		<dict>
    			<key>DefaultValue</key>
    			<string>1.0</string>
    			<key>Key</key>
    			<string>app_version</string>
    			<key>Title</key>
    			<string>版本</string>
    			<key>Type</key>
    			<string>PSTitleValueSpecifier</string>
    		</dict>
    		<dict>
    			<key>Title</key>
    			<string></string>
    			<key>Type</key>
    			<string>PSGroupSpecifier</string>
    		</dict>
    		<dict>
    			<key>File</key>
    			<string>UserProtocol</string>
    			<key>Key</key>
    			<string></string>
    			<key>Title</key>
    			<string>用户协议</string>
    			<key>Type</key>
    			<string>PSChildPaneSpecifier</string>
    		</dict>
    		<dict>
    			<key>File</key>
    			<string>PravacyProtocol</string>
    			<key>Key</key>
    			<string></string>
    			<key>Title</key>
    			<string>隐私协议</string>
    			<key>Type</key>
    			<string>PSChildPaneSpecifier</string>
    		</dict>
    	</array>
    	<key>StringsTable</key>
    	<string>Root</string>
    </dict>
    </plist>
    

      

    3、创建Root.plist中的两个子面板中,file对应的plist文件:

    UserProtocol.plist

    <?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>New item</key>
    	<string></string>
    	<key>StringsTable</key>
    	<string>Root</string>
    	<key>PreferenceSpecifiers</key>
    	<array>
            <dict>
                <key>Type</key>
                <string>PSGroupSpecifier</string>
                <key>Title</key>
                <string>用户啊用户</string>
            </dict>
    	</array>
    </dict>
    </plist>
    

      

    PravacyProtocol.plist

    <?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>StringsTable</key>
        <string>Root</string>
        <key>PreferenceSpecifiers</key>
        <array>
            <dict>
                <key>Type</key>
                <string>PSGroupSpecifier</string>
                <key>Title</key>
                <string>隐私啊隐私</string>
            </dict>
        </array>
    </dict>
    </plist>
    

      

    4、保证Root.plist   UserProtocol.plist   PravacyProtocol.plist 都在Settings.Bundle包中

     

     

    5、脚本读取版本号

    Build Phase,“+”icon

     

    6、添加脚本

    version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $SRCROOT/SLLiveChild/Info.plist`
    /usr/libexec/PlistBuddy "$SRCROOT/SLLiveChild/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:0:DefaultValue $version"
    

      注释:

    PreferenceSpecifiers:0:DefaultValue的意思是在PreferenceSpecifiers这个array下的第0个item的DefaultValue


    最后
    参考:

    http://blog.rocketmade.com/post/60213039759/how-to-automatically-add-version-and-build-number

    http://stackoverflow.com/questions/6851660/version-vs-build-in-xcode
  • 相关阅读:
    Redis分布式限流器
    [转] 详解Spring boot启动原理
    [转] 总结了N个真实线上故障
    加一(66)
    原地删除(27)
    旋转数组(189)
    买卖股票的最佳时机 II(122)
    最长公共前缀(14)
    两个数组的交集II(350)
    Django时区及naive datetime object和aware datetime object的区别
  • 原文地址:https://www.cnblogs.com/kaysun/p/5481079.html
Copyright © 2011-2022 走看看