How do I access the host machine itself from the iPhone simulator

前端 未结 2 992
盖世英雄少女心
盖世英雄少女心 2020-12-29 00:39

I\'m developing an app that connects to a web service for most of it\'s operations. As a shortcut, I\'d like to run a copy of my development server on my machine. Question i

相关标签:
2条回答
  • 2020-12-29 01:14

    The iOS Simulator uses the host machine network so you should be able to just use localhost or your machines IP address, whichever IP your web service is listening on.

    0 讨论(0)
  • 2020-12-29 01:21

    In swift 5 just call:

    http://localhost:<port>/file_path 
    

    but you will need to add this part to the project Info.plist.

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
            <true/>
    </dict>  
    

    Otherwise this error is going to happen.

    Cannot start load of Task <xx-xx>.<x> since it does not conform to ATS policy.

    0 讨论(0)
提交回复
热议问题