If you use already CocoaPods in your react-native project, you can also add the react-native-mapbox-gl project to your Podfile.
- Run
npm install --save react-native-mapbox-gl - Add
pod 'RCTMapboxGL', :path => 'node_modules/react-native-mapbox-gl/ios'to yourPodfilefile.
(The path dependence on your Podfile location.) - Open your Xcode project and ensure that the "Build Settings" parameter
"Other linker flags" (
OTHER_LDFLAGS) contains the CocoaPods generated linker options!- If you have used
react-natve initto setup your project you can just remove this parameter. Just select the line and press the backspace key. - Alternative, if you setup your Xcode project yourself, ensure that the
parent configuration was included with a
$(inherited)variable.
- If you have used
- Install the new CocoaPods dependency with
pod install.
This command must not have output any warning. ;)
Because react-native is only available as npm module (and not as "regular" CocoaPods dependency, see v0.13 release notes for more informations).
So it is required that you import react-native also from a local path.
Ensure that you include React before you include react-native-mapbox-gl in
your Podfile. Here is a complete working example if you want add your Podfile
in the project root while your generated Xcode project is still in the ios
folder:
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'ios/YourProject'
workspace 'ios/YourProject'
pod 'React', :path => 'node_modules/react-native'
pod 'React/RCTGeolocation', :path => 'node_modules/react-native'
pod 'React/RCTImage', :path => 'node_modules/react-native'
pod 'React/RCTNetwork', :path => 'node_modules/react-native'
pod 'React/RCTText', :path => 'node_modules/react-native'
pod 'React/RCTWebSocket', :path => 'node_modules/react-native'
pod 'RCTMapboxGL', :path => 'node_modules/react-native-mapbox-gl/ios'Verify that your "Build Settings" parameter "Other linker flags" (OTHER_LDFLAGS)
is defined correctly. This is NOT the case in a react-native init project which doesn't
use CocoaPods. See Step 3 above!