我的mac-os使用Wifi,当我移动到其他地方我的IP更改,我总是重建应用程序进行测试。重建应用程序很烦人。
在Android上,我可以在Dev Menu, Dev Settings, Debug server host for device setting
中设置开发服务器,但在IOS中找不到。
你为什么不能拥有一个包含你想要使用的URL或IP的UIViewController
的UITextField
,以及一个保存和更新它的UIButton
,然后将结果存储在UserDefaults
中并每次从中获取一个URL?
还有其他选项,比如Firebase Remote Config,如果你有很多你想要动态配置的变量,我会使用它而不是上面的选项。
如果您只是在移动到新网络时尝试交换IP /端口,我仍然只是将其存储在UserDefaults
中并创建一个页面来更新它。
我用这个工具来解决问题。
https://www.npmjs.com/package/http-server
http-server -p 8081 -P Http://{host}:{port}
并使用Xcode运行应用程序项目。
安装react-native-DebugServerHost,将其链接并再次运行:
npm install react-native-DebugServerHost --save
react-native link
react-native run-ios
然后,新选项将显示在“开发人员菜单”中。设置开发服务器的IP后,你必须杀死应用程序并再次运行它。
--
在整合下
npm install react-native-DebugServerHost --save
podFile文件添加:
pod 'DebugServerHost', :path => '../node_modules/react-native-DebugServerHost'
pod install
手动整合:
只需将DebugServerHost文件夹添加到项目中,无需任何设置。
存储库:https://github.com/xuwening/react-native-debug-server-host