2016-06-16 37 views
2

我有下一個問題,我必須添加NSAppTransportSecurity密鑰到我的info.plist文件。Phonegap修改config.xml爲NSAppTransportSecurity

因爲我有很多不同的config.xml用於測試,開發和生產服務器,所以手動將NSAppTransportSecurity密鑰添加到plist並不好。

這可以在config.xml本身內完成嗎?

我已經試過這樣:

<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> 

但經過科爾多瓦打造的iOS我得到這個在我的info.plist:

<key>[object Object]</key> 
<string>NSAppTransportSecurity</string> 

但CFBundleURLTypes得到正常移植。我究竟做錯了什麼?

+0

只是增加平臺的ios –

+0

然後使用默認的info.plist文件進行訪問 –

回答

1

可以使用cordova-custom-config插件來實現這一目標:

$ cordova plugin add cordova-custom-config 

然後添加到config.xml文件:

<platform name="ios"> 
    <config-file platform="ios" target="*-Info.plist" parent="NSAppTransportSecurity"> 
     <dict> 
      <key>NSAllowsArbitraryLoads</key> 
      <true/> 
     </dict> 
    </config-file> 
</platform> 
1

我與DaveAlden的解決方案達成一致。但是,如果NSAppTransportSecurity是你有興趣在*-Info.plist文件操作的唯一的事情,那麼你可以使用cordova-ios-security plugin

這個插件需要您手動在做*-Info.plist文件的作業的護理