2015-10-06 5 views
11

Xcodeバージョン7.0.1を使用してiPhoneベースのWebサイトをiPhoneアプリとしてバンドルしたいのですが、すべて問題なく動作します。私のiPhone 4Sでアプリケーションをテストすると、httpでアクセスする画像は表示されません。しかし、私はその画像へのアクセスをhttpsに提供する別のウェブサイトの画像にアクセスすることができました。xcodeバージョン7.0.1のplistにNSExceptionDomainsを追加する方法は?

バンドルにhttpサポートを追加する方法はありますか?

更新

私は私のplistファイルにNSExceptionDomainsを追加しましたが、私はまだ同じ問題に

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

を持って、私はまた、この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> 

に基づいて、次を試してみました更新

hereに記載されているコードを追加しましたが、それでも同じ問題があります。

更新

示唆したように、私は次のようにplistのを変えたが、それでも同じ問題があります。また、キータグの値にhttp://を追加して無駄にしました。

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

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

答えて

10

まず、Info.plistには2つの別々のNSAppTransportSecurityキーと値のペアがあります。あなたはそれを修正する必要がありますので、1つだけのペアがあります。

あなたの質問では、画像がどのドメインから読み込まれたのかはわかりません。この情報を含めることができれば、特定の回答を出す方が簡単です。

例えば、あなたのイメージがexample.comまたはサブドメインからロードされ、場合は、次のように例外を追加することができます。

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

を使用すると、画像がからロードされますドメインどのような事前にわからない場合は、この第二の例ではappanalytics.embarcadero.comを含めることが技術的に冗長であるが、あなたがすべての既知のドメイン番目のためのATSの例外を指定することが推奨されていること

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

注:その後、あなたの代わりに、すべてのドメインへのHTTPアクセスを許可することができますあなたのアプリでアクセスします。

+0

おかげで、私はイメージのドメインを知っていて、あなたが示唆したようにそれを加えましたが、ヘルプ、私は質問を更新しました。 – Jack

+0

最後に更新されたplistを見ると、NSExceptionDomainsに 'myproject.com.ca'の2つの異なるエントリが含まれているので、私の例をあまりにも上手く取りました。ドメインごとに1つのエントリしか持たず、そのドメインに必要な例外があります。 – adurdin

1

このチュートリアルではApp Transport Securityを設定するか、辞書 "NSAppTransportSecurity"に "NSAllowsArbitraryLoads"という名前のブールキー(info.plistの値が "YES")を追加することで、以前と同様にすべてを許可することができます。

1

あなたのキー名がNSExceptionAllowsInsecureHTTPLoadsですが、それはまたNSTemporaryExceptionAllowsInsecureHTTPLoads

する必要があり、あなたはATSドメインのキーに

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

を追加しようとしたのですか?
一部のドメインで必要です。

関連する問題