Flo*_*son 8 xml ios phonegap-plugins cordova phonegap-build
对于我的应用程序,我需要为iOS的Info.plist文件添加一些设置.我认为最好的方法是将这些设置添加到我的config.xml文件中(我正在使用PhoneGap).当我将以下内容添加到config.xml文件并运行时
cordova build ios
Run Code Online (Sandbox Code Playgroud)
要么
cordova update platform ios
Run Code Online (Sandbox Code Playgroud)
我的Info.plist文件中没有添加任何内容,我完全不知道为什么会这样.构建显示"成功",所以我认为没有语法错误.
我试过了:
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<config-file target="*-Info.plist" parent="NSAppTransportSecurity">
<array>
<dict>
<key>NSExceptionDomains</key>
<array>
<dict>
<key>s3.amazonaws.com</key>
<array>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</array>
</dict>
</array>
</dict>
</array>
</config-file>
</platform>
Run Code Online (Sandbox Code Playgroud)
和
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<config-file target="*-Info.plist" parent="NSAppTransportSecurity">
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>s3.amazonaws.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
</config-file>
</platform>
Run Code Online (Sandbox Code Playgroud)
和
<gap:config-file platform="ios" parent="NSAppTransportSecurity">
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>s3.amazonaws.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
</gap:config-file>
Run Code Online (Sandbox Code Playgroud)
和
<gap:config-file platform="ios" parent="NSAppTransportSecurity">
<array>
<dict>
<key>NSExceptionDomains</key>
<array>
<dict>
<key>s3.amazonaws.com</key>
<array>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</array>
</dict>
</array>
</dict>
</array>
</gap:config-file>
Run Code Online (Sandbox Code Playgroud)
但是没有任何内容添加到Info.plist文件中.我在这做错了什么?
我使用iOS的构建钩子来实现这一点.所以,在config.xml中我会添加如下内容:
<hook type="before_build" src="../scripts/ios_before_build.sh" />
Run Code Online (Sandbox Code Playgroud)
在 - 的里面:
<platform name="ios">
Run Code Online (Sandbox Code Playgroud)
config.xml中的元素
然后我创建一个名为../scripts/ios_before_build.sh的文件,确保它具有执行权限(chmod 755 ../scripts/ios_before_build.sh)然后将脚本设置为使用PlistBuddy对.plist进行必要的更改文件.
例如,我在关闭SSL安全后端URL的iOS 9要求,因为我正在开发的应用程序的API不使用https:
val=$(/usr/libexec/plistbuddy -c "add NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" platforms/ios/AppName/AppName-Info.plist 2>/dev/null)
Run Code Online (Sandbox Code Playgroud)
我正在抑制plistbuddy的返回代码,因为如果项目已经存在,它将失败.这里我添加了一个dict并设置了一个布尔值,但你可以根据PlistBuddy文档做各种其他的东西.
然后你做的时候:
cordova build ios
Run Code Online (Sandbox Code Playgroud)
脚本将运行,改变你的plist然后cordova构建将继续.
我觉得这个更干净,因为我不喜欢在我的Cordova项目中将平台或插件文件夹检入版本控制.
| 归档时间: |
|
| 查看次数: |
5014 次 |
| 最近记录: |