如下步驟爲手動添加的方式,使用rnpm的方式請參考官方文檔。html
本文是對官方文檔的一個補充,大部份內容來源於官網文檔。node
官方參考地址: http://facebook.github.io/react-native/docs/linking-libraries-ios.html#contentreact
中文參考地址:http://reactnative.cn/docs/linking-libraries-ios.html#contentios
把須要的.xcodeproj文件,拖到你的XCode工程下(一般拖到XCode的Libraries分組裏)git
react-native須要集成的.xcodeproj文件清單以下:github
node_modules/react-native/React/React.xcodeproj node_modules/react-native/Libraries/Image/RCTImage.xcodeproj node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj node_modules/react-native/Libraries/Text/RCTText.xcodeproj node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj
點擊你的主工程文件,選擇Build Phases,而後把剛纔所添加進去的.xcodeproj下的Products文件夾中的靜態庫文件(.a文件),拖到Link Binary With Libraries組內。npm
須要在原生代碼中使用這個庫,仍是隻須要經過JavaScript訪問?
若是你只須要經過JavaScript訪問這個庫,你就能夠跳過這步了。react-native
打開你的工程文件,選擇Build Settings,而後搜索Header Search Paths,而後添加庫所在的目錄(若是它還有像React這樣的子目錄須要包含,注意要選中recursive選項)xcode
注意:React.xcodeproj是須要註冊的。下面的目錄要改爲本身的目錄。服務器
$(SRCROOT)/RN/node_modules/react-native/React
recursive
報錯緣由是須要開啓內網http的訪問權限。
在Info.plist中添加 NSAppTransportSecurity 類型 Dictionary ;
在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 類型Boolean ,值設爲 YES;
參考地址:
http://www.cnblogs.com/chglog/p/4746683.html
解決方案:
Build Settings -> other linker flags -> -ObjC
參考地址1:https://github.com/facebook/react-native/issues/2396
錯誤信息說的很清楚了。
在Info.plist中添加View controller-based status bar appearance爲NO。
在React.xcodeproj的Build Phases中的第一個(有8081那個)Run Script。用 <<! 代碼代碼代碼 ! 註釋掉便可。