I have a next issue, i have to add NSAppTransportSecurity key into my info.plist file.
我有下一个问题,我必须将NSAppTransportSecurity密钥添加到我的info.plist文件中。
Because i have many different config.xml for Test, Development and Production servers it is not good to add NSAppTransportSecurity key into plist manually.
因为我有许多不同的config.xml用于测试,开发和生产服务器,所以不能手动将NSAppTransportSecurity密钥添加到plist中。
Could this be done inside the config.xml itself?
这可以在config.xml本身内完成吗?
I have tried this:
我试过这个:
<manifest device="ios" tag="plist/dict">
<key>CFBundleURLTypes</key>
<array>
<dict>
...
</dict>
</array>
<!--Here is my own:-->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</manifest>
But after cordova build iOS i get this in my info.plist:
但是在cordova构建iOS之后,我在info.plist中得到了这个:
<key>[object Object]</key>
<string>NSAppTransportSecurity</string>
But the CFBundleURLTypes gets ported normally. What am i doing wrong?
但CFBundleURLTypes正常移植。我究竟做错了什么?
2 个解决方案
#1
1
You can use the cordova-custom-config plugin to achieve this:
您可以使用cordova-custom-config插件来实现此目的:
$ cordova plugin add cordova-custom-config
then add to config.xml:
然后添加到config.xml:
<platform name="ios">
<config-file platform="ios" target="*-Info.plist" parent="NSAppTransportSecurity">
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</config-file>
</platform>
#2
1
I do agree with DaveAlden's solution. But if NSAppTransportSecurity
is the only thing you are interested in manipulating in *-Info.plist
file, then you can use cordova-ios-security plugin
我同意DaveAlden的解决方案。但是如果NSAppTransportSecurity是你唯一感兴趣的操作* -Info.plist文件,那么你可以使用cordova-ios-security插件
This plugin takes care of the job which you were doing manually in *-Info.plist
file
这个插件负责在* -Info.plist文件中手动完成的工作
#1
1
You can use the cordova-custom-config plugin to achieve this:
您可以使用cordova-custom-config插件来实现此目的:
$ cordova plugin add cordova-custom-config
then add to config.xml:
然后添加到config.xml:
<platform name="ios">
<config-file platform="ios" target="*-Info.plist" parent="NSAppTransportSecurity">
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</config-file>
</platform>
#2
1
I do agree with DaveAlden's solution. But if NSAppTransportSecurity
is the only thing you are interested in manipulating in *-Info.plist
file, then you can use cordova-ios-security plugin
我同意DaveAlden的解决方案。但是如果NSAppTransportSecurity是你唯一感兴趣的操作* -Info.plist文件,那么你可以使用cordova-ios-security插件
This plugin takes care of the job which you were doing manually in *-Info.plist
file
这个插件负责在* -Info.plist文件中手动完成的工作