[英][React-Native][IOS]How to dynamic set Debug server host for device setting like Android
我的mac-os使用Wifi,當我移動到其他地方我的IP更改,我總是重建應用程序進行測試。 重建應用程序很煩人。
在Android上,我可以在Dev Menu, Dev Settings, Debug server host for device setting
設置開發服務器以Dev Menu, Dev Settings, Debug server host for device setting
但在IOS中找不到。
你為什么不能擁有一個包含你想要使用的URL或IP的UITextField
的UIViewController
,以及一個保存和更新它的UIButton
,然后將結果存儲在UserDefaults
並每次從URL獲取?
還有其他選項,如Firebase遠程配置 ,如果你想要動態配置許多變量,我將使用它而不是上面的選項。
如果您只是在移動到新網絡時嘗試交換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后,你必須殺死應用程序並再次運行它。
-
Pod整合
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.