上一篇我整理的是安裝RN環境以及建立第一個RN項目,也是我初識RN的第一步,爲了看相似熱更新的效果,我先開始集成的CodePush。node
網上文章都還挺多的,可是我第一次集成的時候就有問題,此次寫的時候又鼓搗了半天。。。寫的不對的地方,請你們多多指點~~react
npm install -g code-push-cli
複製代碼
code-push register
複製代碼
code-push app add RNTest ios react-native
複製代碼
RNTest:項目的名稱,ios:若是是安卓用android。成功後,以下圖所示。android
好了,codePush安裝完了,並且項目也建立了。這個跟我們平時用的極光、友盟等第三方帳號同樣。添加完後,可在appcenter裏面看到。ios
npm install react-native-code-push --save
複製代碼
安裝成功後,可在項目以下圖路徑裏找到對應文件。npm
react-native link react-native-code-push
複製代碼
Podfile以下所示,多一個CodePushjson
cd ios
pod install
複製代碼
將下圖Library處刪掉。這是RN建立項目的時候,沒有pod本身添加進來的 react-native
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # Needed for debugging
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
複製代碼
如今運行,又報了下方的錯誤。 瀏覽器
莫慌,解決辦法以下:bash
這篇我確實想小吐槽一下,多是第一次裝的時候,太不熟悉了,徹底一臉慒,還遇到了各類奇葩的問題。各類查資料,詢問各位RN大神。如今感受,好像遇到的那些奇葩的問題(當時網上找了好多,試了很差使的)均可以用下面這些來解決,雖然簡單粗暴,可是挺好使。app
OK,這篇就先到這裏了~目前我是按我學習的順序來整理的。下篇整理集成CodePush後APP的展現效果,主要包括Xcode配置、打包上傳和app的最終呈現。