2015-10-06 24 views
11

Vorrei unire un sito Web basato su HTML come app per iPhone usando Xcode versione 7.0.1, tutto funziona correttamente e il mio unico problema è che quando provo l'applicazione su iPhone 4s, non mostrerò le immagini a cui si accede tramite http. Tuttavia, ho potuto accedere alle immagini di un altro sito Web che fornisce l'accesso alle sue immagini. httpsCome aggiungere NSExceptionDomains a plist di xcode Versione 7.0.1?

C'è un modo per aggiungere il supporto http al pacchetto?

Aggiornamento

ho aggiunto un NSExceptionDomains al mio file plist, ma ho ancora lo stesso problema

<?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>CFBundleDevelopmentRegion</key> 
    <string>English</string> 
    <key>CFBundleDisplayName</key> 
    <string>My Project</string> 
    <key>CFBundleExecutable</key> 
    <string>${EXECUTABLE_NAME}</string> 
    <key>CFBundleIcons</key> 
    <dict/> 
    <key>CFBundleIcons~ipad</key> 
    <dict/> 
    <key>CFBundleIdentifier</key> 
    <string>com.myproject.names</string> 
    <key>CFBundleInfoDictionaryVersion</key> 
    <string>1.0</string> 
    <key>CFBundleName</key> 
    <string>${PRODUCT_NAME}</string> 
    <key>CFBundlePackageType</key> 
    <string>APPL</string> 
    <key>CFBundleShortVersionString</key> 
    <string>1.0.1</string> 
    <key>CFBundleSignature</key> 
    <string>myproject</string> 
    <key>CFBundleVersion</key> 
    <string>1.1</string> 
    <key>LSRequiresIPhoneOS</key> 
    <true/> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSAllowsArbitraryLoads</key> 
     <true/> 
    </dict> 
    <key>UIMainStoryboardFile</key> 
    <string>Main_iPhone</string> 
    <key>UIMainStoryboardFile~ipad</key> 
    <string>Main_iPad</string> 
    <key>UIRequiresFullScreen</key> 
    <string>YES</string> 
    <key>UIStatusBarHidden</key> 
    <false/> 
    <key>UIStatusBarStyle</key> 
    <string>UIStatusBarStyleLightContent</string> 
    <key>UISupportedInterfaceOrientations</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>UISupportedInterfaceOrientations~ipad</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>UIViewControllerBasedStatusBarAppearance</key> 
    <false/> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>appanalytics.embarcadero.com</key> 
      <dict> 
       <key>NSExceptionAllowsInsecureHTTPLoads</key><true/> 
      </dict> 
     </dict> 
    </dict> 
</dict> 
</plist> 

Ho anche provato seguito sulla base di questo question

<dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>mydomain.com</key> 
      <dict> 
       <!--Include to allow subdomains--> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <!--Include to allow HTTP requests--> 
       <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> 
       <true/> 
       <!--Include to specify minimum TLS version--> 
       <key>NSTemporaryExceptionMinimumTLSVersion</key> 
       <string>TLSv1.1</string> 
      </dict> 
     </dict> 
    </dict> 

Aggiornamento

Ho aggiunto il codice indicato in here ma ho ancora lo stesso problema.

Aggiornamento

Come suggerito, ho cambiato il plist al seguente ma ha ancora lo stesso problema. Inoltre, ho aggiunto http: // ai valori dei tag chiave senza alcun risultato.

<?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>CFBundleDevelopmentRegion</key> 
    <string>English</string> 
    <key>CFBundleDisplayName</key> 
    <string>My Project</string> 
    <key>CFBundleExecutable</key> 
    <string>${EXECUTABLE_NAME}</string> 
    <key>CFBundleIcons</key> 
    <dict/> 
    <key>CFBundleIcons~ipad</key> 
    <dict/> 
    <key>CFBundleIdentifier</key> 
    <string>com.myproject.names</string> 
    <key>CFBundleInfoDictionaryVersion</key> 
    <string>1.0</string> 
    <key>CFBundleName</key> 
    <string>${PRODUCT_NAME}</string> 
    <key>CFBundlePackageType</key> 
    <string>APPL</string> 
    <key>CFBundleShortVersionString</key> 
    <string>3.1.6</string> 
    <key>CFBundleSignature</key> 
    <string>myproject</string> 
    <key>CFBundleVersion</key> 
    <string>1.2</string> 
    <key>LSRequiresIPhoneOS</key> 
    <true/> 
    <key>UIMainStoryboardFile</key> 
    <string>Main_iPhone</string> 
    <key>UIMainStoryboardFile~ipad</key> 
    <string>Main_iPad</string> 
    <key>UIRequiresFullScreen</key> 
    <string>YES</string> 
    <key>UIStatusBarHidden</key> 
    <false/> 
    <key>UIStatusBarStyle</key> 
    <string>UIStatusBarStyleLightContent</string> 
    <key>UISupportedInterfaceOrientations</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>UISupportedInterfaceOrientations~ipad</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>UIViewControllerBasedStatusBarAppearance</key> 
    <false/> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>myproject.com.ca</key> 
      <dict> 
       <key>NSExceptionAllowsInsecureHTTPLoads</key> 
       <true/> 
      </dict> 
      <key>myproject.com.ca</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSExceptionAllowsInsecureHTTPLoads</key> 
       <true/> 
      </dict> 
     </dict> 
    </dict> 
</dict> 
</plist> 
+0

visitare: https://nabla-c0d3.github.io/blog/2015/06/16/ios9-security-privacy/ –

risposta

10

In primo luogo, Info.plist ha due coppie di valori-chiave NSAppTransportSecurity distinte. Dovresti aggiustarlo così c'è solo la coppia.

La tua domanda non dice da quale dominio vengono caricate le tue immagini. Sarebbe più facile dare una risposta specifica se potessi includere queste informazioni.

Se, ad esempio, le immagini vengono caricati dal example.com o sottodomini, si potrebbe aggiungere un'eccezione nel modo seguente:

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>appanalytics.embarcadero.com</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
     <key>example.com</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
    </dict> 
</dict> 

Se non si sa in anticipo quali domini le immagini verranno caricate dalla, allora si può invece permette l'accesso HTTP a tutti i domini:

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>appanalytics.embarcadero.com</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
    </dict> 
</dict> 

Nota che, anche se l'inclusione di appanalytics.embarcadero.com in questo secondo esempio è tecnicamente ridondante, si consiglia di specificare le eccezioni ATS per tutti i domini noti TH alla tua app accederà.

+0

grazie, conosco il dominio delle immagini e ho aggiunto che come hai suggerito ma non aiuto, ho aggiornato la domanda. – Jack

+0

Guardando il tuo ultimo plist aggiornato, hai preso il mio esempio anche alla lettera, dato che hai incluso due voci diverse per 'myproject.com.ca' in NSExceptionDomains. Dovresti avere una sola voce per ogni dominio, con le eccezioni necessarie per quel dominio. – adurdin

1

si può leggere questo tutorial su come configurare App Transport Security o si può solo permettere tutto come prima con l'aggiunta di dizionario "NSAppTransportSecurity" con una chiave booleana denominata "NSAllowsArbitraryLoads" con il valore "SI" nella vostra Info.plist.

1

tuo nome chiave è NSExceptionAllowsInsecureHTTPLoads ma dovrebbe essere NSTemporaryExceptionAllowsInsecureHTTPLoads

Inoltre, ha fatto si tenta di aggiungere

<key>NSExceptionRequiresForwardSecrecy</key> 
<false/> 

alla chiave di dominio ATS?
Alcuni domini lo richiedono.

Problemi correlati