Use CocoaPods Module in React Native Custom UI Component
In the case that you have a React Native App Project, let's call it MyApp.xcodeproj
, and you are including a library project, GoogleMapView.xcodeproj
, you won't be able to use CocoaPods in GoogleMapView just by dragging it into MyApp.xcodeproj
as you have done in this example.
If you want to use CocoaPods to pull in the GoogleMaps
Pod, you must pull in your GoogleMapView
project ALSO using CocoaPods.
Like so:
# MyApp/Podfilepod 'GoogleMapView', :path => 'Libraries/GoogleMapView'
But before you do that, you'll need to make sure that the GoogleMapView
project / private CocoaPod is correctly configured.
First, the Podfile:
# MyApp/Libraries/GoogleMapView/Podfilepod 'GoogleMaps'
Then, the Podspec. This file is what marks the project as a CocoaPods library.
You can generate this with pod spec create GoogleMapView
.
Here's what yours needs to look like:
# MyApp/Libraries/GoogleMapView/GoogleMapView.podspec Pod::Spec.new do |s| s.name = "GoogleMapView" s.version = "0.0.1" s.summary = "A short description of GoogleMapView." s.description = <<-DESC DESC s.homepage = "http://EXAMPLE/GoogleMapView" s.license = "MIT (example)" s.author = { "David Young-Chan Kay" => "davidykay@gmail.com" } s.source = { :git => "http://EXAMPLE/GoogleMapView.git", :tag => "0.0.1" } s.source_files = "Classes", "Classes/**/*.{h,m}" s.exclude_files = "Classes/Exclude" # This is the key line. You must add it by hand. s.dependency 'GoogleMaps' end
Once these three files are in place, you will be able to re-use your GoogleMapView
using CocoaPods!
You can even upload it to the central CocoaPods repository for sharing with others.
Hope this helps. Let me know if you need clarification.