16658
```

    2015-09-15 21:33:04.489 xxxxx-Keyboard[1132:13790] ***storageTaskManagerExistsWithIdentifier:withIdentifier failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlstorage-cache was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
    NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
    }
    2015-09-15 21:33:04.532 xxxxx-Keyboard[1132:13790] ***cachedResponseDictionaryForRequest:key:handler failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlstorage-cache was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
    NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
    }
    fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSURLErrorDomain Code=-1003 "指定されたホスト名のサーバが見つかりませんでした。" UserInfo={NSUnderlyingError=0x14109acc0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "指定されたホスト名のサーバが見つかりませんでした。" UserInfo={NSErrorFailingURLStringKey=http://www.social-ime.com/api/?string=%E3%81%84, NSErrorFailingURLKey=http://www.social-ime.com/api/?string=%E3%81%84, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10, NSLocalizedDescription=指定されたホスト名のサーバが見つかりませんでした。}}, NSErrorFailingURLStringKey=http://www.social-ime.com/api/?string=%E3%81%84, NSErrorFailingURLKey=http://www.social-ime.com/api/?string=%E3%81%84, _kCFStreamErrorDomainKey=10, _kCFStreamErrorCodeKey=-72000, NSLocalizedDescription=指定されたホスト名のサーバが見つかりませんでした。}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.59/src/swift/stdlib/public/core/ErrorType.swift, line 50
    (lldb)
    
```

シミュレータで通信（通信可能に設定）して、得た結果をモニターできるのに、実機はエラーになります。

<http://www.social-ime.com/api/?string=%E3%81%84>
も、単体で実行すれば返答があります。サーバーがないことはありません。  
HTTP通信もシミュレータでは、動きます。

こんなのも関係あるでしょうか？

```

    2015-09-15 21:51:30.092 xxxxx-Keyboard[1455:22588] XPC unexpectedly invalidated
    2015-09-15 21:51:30.094 xxxxx-Keyboard[1455:22588] __27-[_UIRemoteKeyboards proxy]_block_invoke Failed to access remote service: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.UIKit.KeyboardManagement.hosted was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.UIKit.KeyboardManagement.hosted was invalidated.}
    
    Optional(〈xxxxx_Keyboard.KeyboardViewController: 0x146809800〉)
    Optional(〈xxxxx_Keyboard.KeyboardViewController: 0x146809800〉)
    
    
    2015-09-15 23:07:41.237 xxxxx-Keyboard[2694:47752] ***storageTaskManagerExistsWithIdentifier:withIdentifier failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlstorage-cache was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
    NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
    }
    2015-09-15 23:07:41.301 xxxxx-Keyboard[2694:47752] ***cachedResponseDictionaryForRequest:key:handler failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlstorage-cache was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
    NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
    }
    2015-09-15 23:07:41.305 xxxxx-Keyboard[2694:47800] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
    fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x13906c6f0 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSErrorFailingURLStringKey=http://www.social-ime.com/api/?string=%E3%81%84, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=http://www.social-ime.com/api/?string=%E3%81%84}}, NSErrorFailingURLStringKey=http://www.social-ime.com/api/?string=%E3%81%84, NSErrorFailingURLKey=http://www.social-ime.com/api/?string=%E3%81%84, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.59/src/swift/stdlib/public/core/ErrorType.swift, line 50
    (lldb) 
    
```

キーボード用のinfo.plistで追加したいるもの。

```

    〈key〉NSAppTransportSecurity〈/key〉
    〈dict〉
        〈key〉NSExceptionDomains〈/key〉
        〈dict〉
            〈key〉www.social-ime.com〈/key〉
            〈dict〉
                〈key〉NSTemporaryExceptionAllowsInsecureHTTPLoads〈/key〉
                〈true/〉
            〈/dict〉
        〈/dict〉
    〈/dict〉
    
```

確認すべきところを教えていただけないでしょうか？
CC BY-SA 3.0
2015-09-15T12:57:37.443
16648
2015-10-16T16:11:29.917
2015-10-16T16:11:29.917
5519
10845
question
swift xcode
Xcode 7 (iOS 9) で外部通信がエラーになる
App Transport Security(ATS)について確認すべきです。

iOS9以降、アプリとWebの接続をよりセキュアにするATSという機構が追加されました。

対応方法についてはperomasamune氏の投稿が参考になります。  
[iOS9のWebviewでNSURLErrorDomainとなる場合の対処法(ATS)](http://qiita.com/peromasamune/items/f5b72c4dbd33b5019611)

オフィシャルな情報はこちら。  
[App Transport Security
Technote](https://developer.apple.com/library/prerelease/ios/technotes/App-
Transport-Security-Technote/)

日本語での概要説明はクラスメソッド様の記事にまとまっています。  
[[iOS 9] iOS 9 で追加された App Transport Security
の概要](http://dev.classmethod.jp/smartphone/iphone/ios-9-intro-ats/)

対応方法の記事中にもあるように、ベータ版バージョン単位でも挙動の差異があるようなので注意してください。
CC BY-SA 3.0
2015-09-15T16:30:06.487
16658
2015-09-15T16:30:06.487
11109
16648
answer