React Native 0.29.0版本iOS端BundleURL加载方法
React Native iOS在0.29.0版本中BundleURL加载方法做了重大改变,新增了 默认加载方式在Debug模式下,执行react-native-xcode.sh编译脚本会自动获取当前网卡en0的IP地址,并打入App包中一个配置文件ip.txt,App运行时会读取ip文件,自动生成Developer Server URL,通过这种加载方式,我们不再需要手动去把"localhost"改成Mac的IP了,每次编译都会读取当前最新的IP。 if [[ "$CONFIGURATION" = "Debug" && "$PLATFORM_NAME" != "iphonesimulator" ]]; then PLISTBUDDY='/usr/libexec/PlistBuddy' PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH IP=$(ipconfig getifaddr en0) $PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" $PLIST $PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP.xip.io:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" $PLIST echo "$IP.xip.io" > "$DEST/ip.txt" fi 非Debug模式时,没有ip.txt文件,会直接读取本地jsbundle文件,和以前版本的Load from pre-bundled file on disk方式相同。 手动设置IPRCTBundleURLProvider在接口中暴露了 NSURL *jsCodeLocation; [[RCTBundleURLProvider sharedSettings] setDefaults]; #if DEBUG [[RCTBundleURLProvider sharedSettings] setJsLocation:@"192.168.1.101"]; #endif jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 另需要在Info设置 总之
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 为什么即使设置/ MT选项,我也会看到MSVCR90依赖?
- postgresql – 如何在OS X上使用Postgres.app启用日志记录?
- ruby-on-rails – Railstutorial(Michael Hartl):练习4.6
- ruby – 如何将字符串分割成多个单词的数组?
- expdp 遇到 "Streams AQ: enqueue blocked on low memo
- Configuring solrconfig.xml (1)
- 触发器在Oracle中无效
- jquery用ajax方式从后台获取json数据后如何将内容填充到下拉
- Cocos2d-x_Win7_Eclipse_Android使用学习
- Flex弹出窗口请求Action函数