10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOS シュミレータ・実機からローカルの開発サーバに繋いで開発する

Posted at

iOS シュミレータの場合

iOS 側のAPI Endpoint を

にすることで、ローカルの開発サーバに繋いで確認しつつ開発が出来る。サブドメインをつけたかったら lvh.me を利用する。

lvh.me は prefix に何をつけても、127.0.0.1 を返してくれる便利ドメイン。

iOS 実機の場合

開発機と同一ネットワークに居る条件。ローカルの開発サーバの待ち受けをどの IP からも許可する。

例えば Rails なら以下で許可する。

$ rails s -b 0.0.0.0

続いて iOS 側の API Endpoint を変更する。まずはローカルのネットワークの IP を確認。

$ ipconfig getifaddr en0 # en0 は適切に変更する
192.168.0.10

API Endpoint に xip.io を使う。xip.io は 192.168.0.10.xip.io で名前を引くと、その IPアドレスを返してしてくれる便利ドメイン。Basecamp が運営してる。

$ dig 192.168.0.10.xip.io
; <<>> DiG 9.8.3-P1 <<>> 192.168.0.10.xip.io
(略)
;; QUESTION SECTION:
;192.168.0.10.xip.io.           IN      A

;; ANSWER SECTION:
192.168.0.10.xip.io.    253     IN      A       192.168.0.10

なので、それを利用して API Endpoint にセットする。

なお、サブドメインをつけた場合、最初のアクセス時には名前解決に失敗する。数秒たつと成功する(裏側で何らかのDNSの設定を動的追加してるっぽい)ので注意。

10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?