-
yarn add react-native-maps
- Enabling Google Maps:
-
In pod file put these line before "use_native_modules!".
rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path
-
put these line in your
AppDelegate.m
-
#import <GoogleMaps/GoogleMaps.h>
-
add this line
[GMSServices provideAPIKey:@"_YOUR_API_KEY_"];
to your function
@implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GMSServices provideAPIKey:@"_YOUR_API_KEY_"]; //Add this ... }
-
-
- Enabling Google Maps:
-
yarn add react-native-photo-editor
- Put these line after use_native_modules as mentioned here.
pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios' use_frameworks! :linkage => :static pod 'iOSPhotoEditor', :git => 'https://github.com/prscX/photo-editor', :branch => 'master' post_install do |installer| installer.pods_project.targets.each do |target| if target.name.include?('iOSPhotoEditor') target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '5' end end end end $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly', 'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion', 'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit', 'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native'] pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} installer.pod_targets.each do |pod| if $static_framework.include?(pod.name) def pod.build_type; Pod::BuildType.static_library end end end end
-
Other necessary changes in pod file
- As mentioned here add the following line to your post install script
flipper_post_install(installer)
- To avoid error
'RCTConvert+AirMap.h' file not found
add the following lines too in your post install script as mentioned here:
if target.name == 'react-native-google-maps' target.build_configurations.each do |config| config.build_settings['CLANG_ENABLE_MODULES'] = 'No' end end
- As mentioned here add the following line to your post install script
-
Error:
Cycle inside FBReactNativeSpec; building could produce unreliable results. This usually can be resolved by moving the shell script phase '[CP-User] Generate Specs' so that it runs before the build phase that depends on its outputs. Cycle details: → Target 'FBReactNativeSpec': Libtool /Users/../Library/Developer/Xcode/DerivedData/../Build/Products/Debug-iphonesimulator/FBReactNativeSpec/FBReactNativeSpec.framework/FBReactNativeSpec normal ○ Target 'FBReactNativeSpec' has compile command with input '/Users/../Documents/ReactNative/../ios/Pods/Target Support Files/FBReactNativeSpec/FBReactNativeSpec-dummy.m' ○ That command depends on command in Target 'FBReactNativeSpec': script phase “[CP-User] Generate Specs” ○ Target 'FBReactNativeSpec' has copy command from '/Users/../Documents/ReactNative/../node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h' to '/Users/../Library/Developer/Xcode/DerivedData/../Build/Products/Debug-iphonesimulator/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h' ○ That command depends on command in Target 'FBReactNativeSpec': script phase “[CP-User] Generate Specs”```
Solution: as mentioned here and here, put these line on your pod file
if (target.name&.eql?('FBReactNativeSpec')) target.build_phases.each do |build_phase| if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs')) target.build_phases.move(build_phase, 0) end end end
-
Finally run
cd ios/ && pod install && cd ..
-
Goto target->build settings-> search for
library search path
and add the following line (with quotation) for both debug and release,"$(PODS_ROOT)/../../node_modules/react-native-maps/lib/ios/AirMaps"
-
Add AirMaps and AirGoogleMaps. source
-
Add google-maps-ios-utils: According to these official instruction
-
git clone https://github.com/googlemaps/google-maps-ios-utils master
on ios folder . We need only the content ofsrc
folder. You can delete other files and folders -
On XCODE, Right click on a project and create a group named
Google-Maps-iOS-Utils
. -
Right click on that folder and click
Add files to ...
-
Select all the folders of
ios/master/src
directory of previously cloned directory of step(i). -
Make sure the the options is selected "create groups" and target is selected as your app target.
-
Delete the
Google-Maps-iOS-Utils/Heatmap/HeatMapInterpolationPoint.swift file
as mentioned here. Select remove reference when deleting. -
Goto project -> build settings -> search for
preprocessor macros
and add the following for both Debug and Release. -
run
cd ios/ && pod intall && cd ..
-
Multiple commands produce '/Users/../Library/Developer/Xcode/DerivedData/...app/LaunchScreen.storyboardc':
- Target '..' (project '..'): LinkStoryboards
- That command depends on command in Target '..' (project '..'): script phase “[CP] Copy Pods
As mentioned "Multiple commands produce ... LaunchScreen.storyboardc", we can safely remove LaunchScreen.storyboard
from build phases as it is already generated without us explicitly importing it.
Caution: There is another solution to this. Setting the Buil System
to Legacy Build System
in File -> Workspace Settings
. But this leed to another problem later on. Error: library not found for -lCocoaAsyncSocket
. In legacy build system this problem occurs but not in new build system.
react-native-maps official guide says to follow this instructions on google-maps-ios-utils/Swift.md
. However these instructions are vague. Here is a more clear instructions set:
-
We have cloned and added google-maps-ios-utils in step 2. If not, please follow these instructions on step 2(3).
-
Create Swift Bridging Header
-
Put these following line on the header file:
#import "GMUMarkerClustering.h" #import "GMUGeoJSONParser.h" #import "GMUKMLParser.h" #import "GMUGeometryRenderer.h"
-
Put these following line in
Google-Maps-iOS-Utils/Clustering/GMUMarkerClustering.h
#import "GMUCluster.h" #import "GMUClusterItem.h" #import "GMUClusterManager.h" #import "GMUDefaultClusterIconGenerator.h" #import "GMUDefaultClusterRenderer.h" #import "GMUGridBasedClusterAlgorithm.h" #import "GMUNonHierarchicalDistanceBasedAlgorithm.h" #import "GMUStaticCluster.h" #import "GQTPointQuadTree.h"
-
Change to import statement to
#import "GMUHeatmapTileLayer.h"
inAirGoogleMaps/AIRGoogleMapHeatmap.h
file. -
Put these following line in
AirGoogleMaps/AIRGoogleMap.m
#import "GMUKMLParser.h" #import "GMUPlacemark.h" #import "GMUPoint.h" #import "GMUGeometryRenderer.h"
- Delete
Google-Maps-iOS-Utils
fromPods/Pods
pods section (select the option "Remove References"). Because we have manually addedGoogle-Maps-iOS-Utils
Manually.
if we compile we'll get ld: 470 duplicate symbols for architecture x86_64
.
Now the project will finally run.