2016-12-31 275 views
-1

我试图访问本地ip地址,以便我可以更改/更新本地覆盆子pi上的信息。即IM使用下列内容:使用xcode访问本地ip地址

https://github.com/Jopyth/MMM-Remote-Control 

香港专业教育学院更新了我的plist看起来像这样:

<?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>en</string> 
     <key>CFBundleExecutable</key> 
     <string>$(EXECUTABLE_NAME)</string> 
     <key>CFBundleIdentifier</key> 
     <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> 
     <key>CFBundleInfoDictionaryVersion</key> 
     <string>6.0</string> 
     <key>CFBundleName</key> 
     <string>$(PRODUCT_NAME)</string> 
     <key>CFBundlePackageType</key> 
     <string>APPL</string> 
     <key>CFBundleShortVersionString</key> 
     <string>1.0</string> 
     <key>CFBundleVersion</key> 
     <string>1</string> 
     <key>LSApplicationCategoryType</key> 
     <string></string> 
     <key>LSRequiresIPhoneOS</key> 
     <true/> 
     <key>NSAppTransportSecurity</key> 
     <dict> 
      <key>NSExceptionDomains</key> 
      <dict> 
       <key>http://192.168.0.40</key> // need to add your domain name of webservice 
       <dict> 
        <key>NSIncludesSubdomains</key> 
        <true/> 
        <key>NSExceptionAllowsInsecureHTTPLoads</key> 
        <true/> 
        <key>NSExceptionRequiresForwardSecrecy</key> 
        <true/> 
        <key>NSExceptionMinimumTLSVersion</key> 
        <string>TLSv1.2</string> 
        <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> 
        <false/> 
        <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
        <true/> 
        <key>NSThirdPartyExceptionMinimumTLSVersion</key> 
        <string>TLSv1.2</string> 
        <key>NSRequiresCertificateTransparency</key> 
        <false/> 
       </dict> 
      </dict> 
     </dict> 
     <key>NSTemporaryExceptionMinimumTLSVersion</key> 
     <string>TLSv1.1</string> 
     <key>UILaunchStoryboardName</key> 
     <string>LaunchScreen</string> 
     <key>UIMainStoryboardFile</key> 
     <string>Main</string> 
     <key>UIRequiredDeviceCapabilities</key> 
     <array> 
      <string>armv7</string> 
     </array> 
     <key>UISupportedInterfaceOrientations</key> 
     <array> 
      <string>UIInterfaceOrientationPortrait</string> 
      <string>UIInterfaceOrientationLandscapeLeft</string> 
      <string>UIInterfaceOrientationLandscapeRight</string> 
     </array> 
     <key>UISupportedInterfaceOrientations~ipad</key> 
     <array> 
      <string>UIInterfaceOrientationPortrait</string> 
      <string>UIInterfaceOrientationPortraitUpsideDown</string> 
      <string>UIInterfaceOrientationLandscapeLeft</string> 
      <string>UIInterfaceOrientationLandscapeRight</string> 
     </array> 
    </dict> 
    </plist> 

但SIM或设备装载时,我仍然得到一个空白,尽管黑暗的一页。

我做了最基本的应用程序,以便我的兄弟可以访问他的魔镜时,他在家里更新,但我似乎无法看到本地IP地址。任何帮助都会很棒。

+0

你打算把这个提交给苹果公司,或只是把它给你的兄弟和更新配置文件每年的应用程序? – wottle

+0

例外域不适用于IP地址。 – wottle

回答

1

实际上,真正的问题是ATS异常不适用于IP地址。它仅适用于域名

选项:

选项1 - 禁用ATS

关闭ATS一共是不是一个好主意,如果你正在提交您的应用程序到应用程序商店 - 这样会使你来证明当苹果开始执行该规则时,如果您希望将其提交给应用商店,那么可以做出决定。通常我不建议将此作为SO的一个选项。但是,考虑到您在那里放置了一个硬编码的IP地址,我怀疑这是针对特定用例创建的一次性应用程序,并且您不需要提交给Apple进行审阅(您可能会直接在设备上进行安装使用开发配置文件)。如果是这样的话,我会完全使用Info.plist中的NSAllowsArbitraryLoads键来禁用ATS。

enter image description here

这将禁用所有ATS的保护,但如果您的应用程序仅在本地网络实体通过HTTPS通信,应用程序传输安全性就不会被保护反正什么。

选项2 - 使用NSAllowsLocalNetworking

如果你把两个NSAllowsArbitraryLoadsNSAllowsLocalNetworking在Info.plist中,iOS中9,将禁用ATS完全,但在iOS的10(即支持NSAllowsLocalNetworking的第一个版本设置),iOS将忽略NSAllowsArbitraryLoads,并且仅在本地网络呼叫上禁用ATS。这样会更安全,但是如果您只是进行本地网络呼叫,那么我只会禁用ATS(选项1)。

选择3 - xip.io

如果你想离开ATS上,其他人使用xip.io服务“转换”本地IP地址到域名取得了成功。因此,您需要将xip.io添加到Exception域,并将NSIncludesSubdomains的子值设置为true。然后,当你连接到你的域名,而不是连接到192.168.0.40,你会连接到192.168.0.40.xip.io