Table of contents
Things to note when compiling ios projects
Packaging script (buildRNiOSBunble.sh)
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
#rn分支的名字
rnfilename="bjy_rn"
#原生分支的名字
nativefilename="bjy_ios"
# .xcworkspace的名字
workspace_name="ZYWXOnlineSchool"
step
1 Compile RN code
- The bjy_rnreactnative branch and the bjy_ios native branch are placed in the same directory, and enter the bjy_rn directory
- Update the latest rn code
- Compile rn code
- node_modules introduced
- yarn install
2 Generate .jsbundle file
react-native bundle --entry-file index.js --bundle-output …/bjy_ios/ w o r k s p a c e n a m e / {workspace_name}/ workspacename/{workspace_name}/RNBundle/main.jsbundle --platform ios --assets-dest …/bjy_ios/ w o r k s p a c e n a m e / {workspace_name}/ workspacename/{workspace_name}/RNBundle --dev false
3 Debug script
- Install yarn tools
- cd to the bjy_ios directory
- node_modules introduction and its pod installation
yarn install
pod install --verbose --no-repo-update
- Enable local service
yarn start
4 debug simulator joint debugging
Search for sourceURLForBridge in the code and modify it to the following
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [NSURL URLWithString:@“http://localhost:8081/index.bundle?platform=ios”];
}
5 Real machine joint debugging
⚠️Mobile phone and Mac are under the same wifi and change localhost to the IP address of the current wifi)
Search sourceURLForBridge in the code and change it to the following
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [NSURL URLWithString:@“http://ip.host:8081/index.bundle?platform=ios”];
}
Real machine joint debugging reference link: https://reactnative.cn/docs/running-on-device
6 reload page
reload stop dismiss etc.