V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
lyragosa
V2EX  ›  iDev

iOS 模拟器如果要访问需要 hosts 才能访问的网站(例如本地测试网站),本机 Mac 上的 hosts 设置 IP 只能一对一的写

  •  
  •   lyragosa · Oct 26, 2015 · 2717 views
    This topic created in 3837 days ago, the information mentioned may be changed or developed.
    如果 hosts 中写

    127.0.0.1 a.test.com b.test.com

    那么在 iOS 模拟器中访问这两个 url 是无法跳转到 127.0.0.1 的。无论是模拟器中的 safari 还是应用内的访问请求

    只能写成

    127.0.0.1 a.test.com
    127.0.0.1 b.test.com

    才有效
    不知道是不是个例,反正我这里是有这个问题

    木有技术博客只能发到v2了,肯定是火星了,此贴仅用于中文搜索引擎存档,方便后来者用中文搜索到。
    6 replies    2015-10-26 21:44:02 +08:00
    111111111111
        1
    111111111111  
       Oct 26, 2015
    host 一行只能一条记录吧

    如果记录多的话自建 dns ,

    如果少的话就一条一条写
    xiao201261
        2
    xiao201261  
       Oct 26, 2015
    +1 自建 dns

    @google dnsmasq
    lyragosa
        3
    lyragosa  
    OP
       Oct 26, 2015   ❤️ 1
    @111111111111 每一行的 IP 只能写一个,但是对应的域名可以写多个。
    111111111111
        4
    111111111111  
       Oct 26, 2015
    @lyragosa 果然可以,
    本机访问两个域名都访问到 127.0.0.1 模拟器的事就不晓得了

    另外想起有些路由器也可以实现 DNS 劫持
    lawder
        5
    lawder  
       Oct 26, 2015
    用 Xcode 7.1 带的模拟器测试正常。
    defunct9
        6
    defunct9  
       Oct 26, 2015 via iPhone
    dnsmasq ,我们公司就是这么做的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4530 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 10:10 · PVG 18:10 · LAX 03:10 · JFK 06:10
    ♥ Do have faith in what you're doing.