Monday, March 26, 2018

[React-Native][IOS]How to dynamic set Debug server host for device setting like Android

Leave a Comment

My mac-os using Wifi and when i move to other place my ip change and i always rebuild app for testing. Rebuild app is annoying.

  • How can i set Development Server IP Address in IOS after build and run on Physical Device?

on Android, i can set Development Server in Dev Menu, Dev Settings, Debug server host for device setting but nowhere found in IOS.

2 Answers

Answers 1

I use this tool to solve the problem.

https://www.npmjs.com/package/http-server

http-server -p 8081 -P Http://{host}:{port} 

and use Xcode run app project.

Answers 2

Why couldn't you have a UIViewController with a UITextField that contains the URL or IP you want to use and a UIButton on it that saves and updates this, then store the result in UserDefaults and pull from that for a URL every time?

There are also other options like Firebase Remote Config, which I would use instead of the above if you have many variables you'd want to configure on the fly like this.

If you're just trying to swap the IP/port as you move to a new network, I'd still just store it in UserDefaults and make a page to update it, though.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment