From 5538eb33b1cec33d760fbd546fd9988cfbf718fa Mon Sep 17 00:00:00 2001 From: Whitney Young Date: Tue, 24 Jul 2018 13:41:18 -0700 Subject: [PATCH 1/2] Enable custom configuration for iOS maps This allows setting up the library to work with Google Maps on iOS via `react-native link` instead of only via CocoaPods. Because Google-Maps-iOS-Utils is not distributed as a binary (at this time), it disables functionality that depends on this library and raises an exception that points to the reason why there's a problem. Additionally: - A missing file has been added back into the AirMaps.xcodeproj project. --- docs/installation.md | 43 ++++++++++++------- enable-google-maps | 15 +++++++ lib/ios/AirGoogleMaps/AIRDummyView.h | 4 ++ lib/ios/AirGoogleMaps/AIRDummyView.m | 4 ++ lib/ios/AirGoogleMaps/AIRGMSMarker.h | 4 ++ lib/ios/AirGoogleMaps/AIRGMSMarker.m | 4 ++ lib/ios/AirGoogleMaps/AIRGMSPolygon.h | 4 ++ lib/ios/AirGoogleMaps/AIRGMSPolygon.m | 4 ++ lib/ios/AirGoogleMaps/AIRGMSPolyline.h | 4 ++ lib/ios/AirGoogleMaps/AIRGMSPolyline.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMap.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMap.m | 32 ++++++++++++-- lib/ios/AirGoogleMaps/AIRGoogleMapCallout.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapCallout.m | 4 ++ .../AIRGoogleMapCalloutManager.h | 5 +++ .../AIRGoogleMapCalloutManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapCircle.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapCircle.m | 4 ++ .../AirGoogleMaps/AIRGoogleMapCircleManager.h | 4 ++ .../AirGoogleMaps/AIRGoogleMapCircleManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapManager.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m | 4 ++ .../AirGoogleMaps/AIRGoogleMapMarkerManager.h | 4 ++ .../AirGoogleMaps/AIRGoogleMapMarkerManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m | 4 ++ .../AIRGoogleMapPolygonManager.h | 4 ++ .../AIRGoogleMapPolygonManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.m | 4 ++ .../AIRGoogleMapPolylineManager.h | 4 ++ .../AIRGoogleMapPolylineManager.m | 4 ++ .../AIRGoogleMapURLTileManager.m | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h | 4 ++ lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m | 6 ++- .../AIRGoogleMapUrlTileManager.h | 4 ++ .../AirGoogleMaps/RCTConvert+GMSMapViewType.h | 4 ++ .../AirGoogleMaps/RCTConvert+GMSMapViewType.m | 4 ++ lib/ios/AirMaps.xcodeproj/project.pbxproj | 10 +++++ lib/ios/User.xcconfig | 0 react-native-google-maps.podspec | 2 +- 43 files changed, 232 insertions(+), 21 deletions(-) create mode 100755 enable-google-maps create mode 100644 lib/ios/User.xcconfig diff --git a/docs/installation.md b/docs/installation.md index acfbb2875..27c6818a7 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -80,20 +80,24 @@ post_install do |installer| end ~~~ +## iOS - ReactNative Link -## IMPORTANT!! +Run `react-native link react-native-maps`. Note that by default this will use +Apple Maps and that the configuration of Google Maps will be more difficult. -**!! DO NOT USE !!** `react-native link` +Functionality that depends on `Google-Maps-iOS-Utils` has been disabled for this +configuration via runtime errors due to the fact that this framework is not +available for download as a pre-compiled binary. An exception will be raised if +you try to use the following features: -Have ran it already? Read [this](#on-ios). +- Making markers via KML files ## If you want to use Google maps - Add to `ios/_YOUR_PROJECT_NAME_/AppDelegate.m: ```objc -+ @import GoogleMaps; //add this line if you want to use Google Maps ++ #import @implementation AppDelegate ... @@ -106,6 +110,25 @@ Add to `ios/_YOUR_PROJECT_NAME_/AppDelegate.m: This should be the **first line** of the method. +#### If you are not using CocoaPods + +If you installed via `react-native-link`, add the following to your +`package.json` and replace the `REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL` +with the relative path from your project root to the directory in which you +installed the Google Maps frameworks: + +```json +{ + "name": "your-app", + "scripts": { + "postinstall": "./node_modules/react-native-maps/enable-google-maps REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL" + } +} +``` + +Re-run `npm install` or `yarn` to ensure the `postinstall` script is run. + + ## Notes on running on a real ios device The steps are as described in https://facebook.github.io/react-native/docs/running-on-device.html , however instead of opening the .xcodeproj file you should open .xcworkspace file. @@ -208,16 +231,6 @@ If you have a blank map issue, ([#118](https://github.com/airbnb/react-native-ma If google logo/markers/polylines etc are displayed, this is likely an API key issue. Verify your API keys and their restrictions. Ensure the native `provideAPIKey` call is the first line of `didFinishLaunchingWithOptions`. -If you have ran 'react-native link` by mistake: - -1. delete node_modules -2. delete ios/Pods -3. delete ios/Podfile.lock -4. open Xcode and delete `AIRMaps.xcodeproj` from Libraries if it exists -5. in Build Phases -> Link Binary With Libraries delete `libAIRMaps.a` if it exists -6. delete ios/build folder -7. start again with the installation steps - If you use Xcode with version less than 9 you may get `use of undeclared identifier 'MKMapTypeMutedStandard'` or `Entry, ":CFBundleIdentifier", Does Not Exist` errors. In this case you have to update your Xcode. ### On Android: diff --git a/enable-google-maps b/enable-google-maps new file mode 100755 index 000000000..66ec2be22 --- /dev/null +++ b/enable-google-maps @@ -0,0 +1,15 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" + +GOOGLE_MAPS_INSTALL_LOCATION=$1 + +if [[ -z "$GOOGLE_MAPS_INSTALL_LOCATION" ]]; then + echo "usage: enable-google-maps " + exit 1 +fi + +cat > lib/ios/User.xcconfig < @@ -12,3 +14,5 @@ @property (nonatomic, weak) UIView *view; - (instancetype)initWithView:(UIView*)view; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRDummyView.m b/lib/ios/AirGoogleMaps/AIRDummyView.m index 3775394dc..70921d1b1 100644 --- a/lib/ios/AirGoogleMaps/AIRDummyView.m +++ b/lib/ios/AirGoogleMaps/AIRDummyView.m @@ -5,6 +5,8 @@ // Created by Gil Birman on 10/4/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import "AIRDummyView.h" @@ -17,3 +19,5 @@ - (instancetype)initWithView:(UIView*)view return self; } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSMarker.h b/lib/ios/AirGoogleMaps/AIRGMSMarker.h index 89723ca2a..79a05ad59 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSMarker.h +++ b/lib/ios/AirGoogleMaps/AIRGMSMarker.h @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import @@ -21,3 +23,5 @@ @required -(void)didTapMarker; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSMarker.m b/lib/ios/AirGoogleMaps/AIRGMSMarker.m index 4e7fdfb09..5f270054c 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSMarker.m +++ b/lib/ios/AirGoogleMaps/AIRGMSMarker.m @@ -5,8 +5,12 @@ // Created by Gil Birman on 9/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGMSMarker.h" @implementation AIRGMSMarker @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSPolygon.h b/lib/ios/AirGoogleMaps/AIRGMSPolygon.h index d41c87d5e..3c9947c03 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSPolygon.h +++ b/lib/ios/AirGoogleMaps/AIRGMSPolygon.h @@ -5,6 +5,8 @@ // Created by Gerardo Pacheco 02/05/2017. // +#ifdef HAVE_GOOGLE_MAPS + #import #import @@ -14,3 +16,5 @@ @property (nonatomic, strong) NSString *identifier; @property (nonatomic, copy) RCTBubblingEventBlock onPress; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSPolygon.m b/lib/ios/AirGoogleMaps/AIRGMSPolygon.m index 05de0b029..cf66a84bd 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSPolygon.m +++ b/lib/ios/AirGoogleMaps/AIRGMSPolygon.m @@ -5,8 +5,12 @@ // Created by Gerardo Pacheco 02/05/2017. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGMSPolygon.h" @implementation AIRGMSPolygon @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSPolyline.h b/lib/ios/AirGoogleMaps/AIRGMSPolyline.h index d7ee19783..417a1b685 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSPolyline.h +++ b/lib/ios/AirGoogleMaps/AIRGMSPolyline.h @@ -5,6 +5,8 @@ // Created by Guilherme Pontes 04/05/2017. // +#ifdef HAVE_GOOGLE_MAPS + #import #import @@ -14,3 +16,5 @@ @property (nonatomic, strong) NSString *identifier; @property (nonatomic, copy) RCTBubblingEventBlock onPress; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGMSPolyline.m b/lib/ios/AirGoogleMaps/AIRGMSPolyline.m index 86e7ac055..fb36a9a49 100644 --- a/lib/ios/AirGoogleMaps/AIRGMSPolyline.m +++ b/lib/ios/AirGoogleMaps/AIRGMSPolyline.m @@ -5,7 +5,11 @@ // Created by Guilherme Pontes 04/05/2017. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGMSPolyline.h" @implementation AIRGMSPolyline @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMap.h b/lib/ios/AirGoogleMaps/AIRGoogleMap.h index af362c27e..774468fb8 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMap.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMap.h @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/1/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import #import @@ -65,3 +67,5 @@ + (GMSCameraPosition*)makeGMSCameraPositionFromMap:(GMSMapView *)map andMKCoordinateRegion:(MKCoordinateRegion)region; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMap.m b/lib/ios/AirGoogleMaps/AIRGoogleMap.m index 4205bd458..a3617b254 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMap.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMap.m @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/1/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMap.h" #import "AIRGoogleMapMarker.h" #import "AIRGoogleMapMarkerManager.h" @@ -14,15 +16,27 @@ #import "AIRGoogleMapUrlTile.h" #import "AIRGoogleMapOverlay.h" #import -#import -#import -#import -#import #import #import #import #import "RCTConvert+AirMap.h" +#ifdef HAVE_GOOGLE_MAPS_UTILS +#import +#import +#import +#import +#define REQUIRES_GOOGLE_MAPS_UTILS(feature) do {} while (0) +#else +#define GMUKMLParser void +#define GMUPlacemark void +#define REQUIRES_GOOGLE_MAPS_UTILS(feature) do { \ + [NSException raise:@"ReactNativeMapsDependencyMissing" \ + format:@"Use of " feature "requires Google-Maps-iOS-Utils, you must install via CocoaPods to use this feature"]; \ +} while (0) +#endif + + id regionAsJSON(MKCoordinateRegion region) { return @{ @"latitude": [NSNumber numberWithDouble:region.center.latitude], @@ -496,6 +510,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath } + (NSString *)GetIconUrl:(GMUPlacemark *) marker parser:(GMUKMLParser *) parser { +#ifdef HAVE_GOOGLE_MAPS_UTILS if (marker.style.styleID != nil) { for (GMUStyle *style in parser.styles) { if (style.styleID == marker.style.styleID) { @@ -505,6 +520,9 @@ + (NSString *)GetIconUrl:(GMUPlacemark *) marker parser:(GMUKMLParser *) parser } return marker.style.iconUrl; +#else + REQUIRES_GOOGLE_MAPS_UTILS("GetIconUrl:parser:"); return @""; +#endif } - (NSString *)KmlSrc { @@ -512,6 +530,7 @@ - (NSString *)KmlSrc { } - (void)setKmlSrc:(NSString *)kmlUrl { +#ifdef HAVE_GOOGLE_MAPS_UTILS _kmlSrc = kmlUrl; @@ -563,6 +582,11 @@ - (void)setKmlSrc:(NSString *)kmlUrl { id event = @{@"markers": markers}; if (self.onKmlReady) self.onKmlReady(event); +#else + REQUIRES_GOOGLE_MAPS_UTILS(); +#endif } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.h b/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.h index 784bcf613..29e322f26 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.h @@ -6,6 +6,8 @@ // // +#ifdef HAVE_GOOGLE_MAPS + #import #import @@ -13,3 +15,5 @@ @property (nonatomic, assign) BOOL tooltip; @property (nonatomic, copy) RCTBubblingEventBlock onPress; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.m b/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.m index acc6b86b7..3ed9e78a8 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCallout.m @@ -6,6 +6,8 @@ // // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapCallout.h" #import #import @@ -13,3 +15,5 @@ @implementation AIRGoogleMapCallout @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.h index e5514087e..4d70ea33e 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.h @@ -5,8 +5,13 @@ // Created by Gil Birman on 9/6/16. // // + +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapCalloutManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.m index 1828beb8a..12d8fcb88 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.m @@ -6,6 +6,8 @@ // // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapCalloutManager.h" #import "AIRGoogleMapCallout.h" #import @@ -23,3 +25,5 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.h b/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.h index 685cc649e..478933ee1 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.h @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/24/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import "AIRMapCoordinate.h" @@ -18,3 +20,5 @@ @property (nonatomic, assign) int zIndex; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.m b/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.m index 28741b9f3..f0c73b9c2 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCircle.m @@ -3,6 +3,8 @@ // // Created by Nick Italiano on 10/24/16. // + +#ifdef HAVE_GOOGLE_MAPS #import #import "AIRGoogleMapCircle.h" #import @@ -55,3 +57,5 @@ -(void)setZIndex:(int)zIndex } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.h index c1de72318..02ce07c4b 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.h @@ -4,8 +4,12 @@ // Created by Nick Italiano on 10/24/16. // +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapCircleManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.m index 93afa145f..d113d04bc 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapCircleManager.m @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/24/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapCircleManager.h" #import "AIRGoogleMapCircle.h" #import @@ -31,3 +33,5 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(zIndex, int) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapManager.h index ac841c7bf..a4d40fd2f 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapManager.h @@ -5,8 +5,12 @@ // Created by Gil Birman on 9/1/16. // +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m index 4ae089c1f..21ce5c3c1 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/1/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapManager.h" #import @@ -473,3 +475,5 @@ - (void)mapView:(GMSMapView *)mapView [googleMapView didTapPOIWithPlaceID:placeID name:name location:location]; } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h b/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h index ed4581aec..7cc2f76a2 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/2/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import #import "AIRGMSMarker.h" @@ -44,3 +46,5 @@ - (void)didEndDraggingMarker:(AIRGMSMarker *)marker; - (void)didDragMarker:(AIRGMSMarker *)marker; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m b/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m index 186cc8f5c..b5db8c696 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/2/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapMarker.h" #import #import @@ -319,3 +321,5 @@ - (BOOL)tracksInfoWindowChanges { } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.h index f2698dcd0..ea52ccd59 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.h @@ -5,8 +5,12 @@ // Created by Gil Birman on 9/2/16. // +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapMarkerManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m index a3d931d60..050d7614c 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m @@ -5,6 +5,8 @@ // Created by Gil Birman on 9/2/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapMarkerManager.h" #import "AIRGoogleMapMarker.h" #import @@ -69,3 +71,5 @@ - (UIView *)view }]; } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h index e7719ebee..214e50f41 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/22/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import #import "AIRGMSPolygon.h" @@ -26,3 +28,5 @@ @property (nonatomic, assign) BOOL tappable; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m index bbd5d99c9..6d162a716 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/22/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapPolygon.h" #import "AIRGMSPolygon.h" #import @@ -94,3 +96,5 @@ - (void)setOnPress:(RCTBubblingEventBlock)onPress { } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.h index 3380c61e3..89175e73f 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.h @@ -4,8 +4,12 @@ // Created by Nick Italiano on 10/22/16. // +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapPolygonManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m index 59e239627..7e4e15264 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m @@ -3,6 +3,8 @@ // // Created by Nick Italiano on 10/22/16. // + +#ifdef HAVE_GOOGLE_MAPS #import "AIRGoogleMapPolygonManager.h" #import @@ -40,3 +42,5 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.h b/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.h index 45f69eb35..9524e0880 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.h @@ -3,6 +3,8 @@ // // Created by Nick Italiano on 10/22/16. // + +#ifdef HAVE_GOOGLE_MAPS #import #import #import @@ -28,3 +30,5 @@ @property (nonatomic, assign) BOOL tappable; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.m b/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.m index 250b92aa5..eca6bf02d 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolyline.m @@ -3,6 +3,8 @@ // // Created by Nick Italiano on 10/22/16. // + +#ifdef HAVE_GOOGLE_MAPS #import #import "AIRGoogleMapPolyline.h" #import "AIRGMSPolyline.h" @@ -109,3 +111,5 @@ - (void)configureStyleSpansIfNeeded { } @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.h index 82e7b8e20..7657967f8 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.h @@ -4,8 +4,12 @@ // Created by Nick Italiano on 10/22/16. // +#ifdef HAVE_GOOGLE_MAPS + #import @interface AIRGoogleMapPolylineManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m index e4c49187f..3ec4718e6 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/22/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapPolylineManager.h" #import @@ -41,3 +43,5 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m b/lib/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m index 398d75eff..fc1547caa 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m @@ -3,6 +3,8 @@ // Created by Nick Italiano on 11/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapUrlTileManager.h" #import "AIRGoogleMapUrlTile.h" @@ -26,3 +28,5 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h index bcc6c67fc..5cf94e07f 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h @@ -3,6 +3,8 @@ // Created by Nick Italiano on 11/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import @@ -15,3 +17,5 @@ @property NSInteger *minimumZ; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m index 29eedb461..43a0bcc83 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m @@ -3,6 +3,8 @@ // Created by Nick Italiano on 11/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapUrlTile.h" @implementation AIRGoogleMapUrlTile @@ -44,4 +46,6 @@ - (GMSTileURLConstructor)_getTileURLConstructor return urls; } -@end \ No newline at end of file +@end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTileManager.h b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTileManager.h index affd718b4..cf4fd62b8 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTileManager.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapUrlTileManager.h @@ -3,8 +3,12 @@ // Created by Nick Italiano on 11/5/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import @interface AIRGoogleMapUrlTileManager : RCTViewManager @end + +#endif diff --git a/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h b/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h index 7e02d66a0..27eec257f 100644 --- a/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +++ b/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/23/16. // +#ifdef HAVE_GOOGLE_MAPS + #import #import #import @@ -11,3 +13,5 @@ @interface RCTConvert (GMSMapViewType) @end + +#endif diff --git a/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m b/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m index cfceba559..5a332f53b 100644 --- a/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +++ b/lib/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m @@ -4,6 +4,8 @@ // Created by Nick Italiano on 10/23/16. // +#ifdef HAVE_GOOGLE_MAPS + #import "RCTConvert+GMSMapViewType.h" #import #import @@ -20,3 +22,5 @@ @implementation RCTConvert (GMSMapViewType) } ), kGMSTypeTerrain, intValue) @end + +#endif diff --git a/lib/ios/AirMaps.xcodeproj/project.pbxproj b/lib/ios/AirMaps.xcodeproj/project.pbxproj index 7e2468f62..fd7c0121c 100644 --- a/lib/ios/AirMaps.xcodeproj/project.pbxproj +++ b/lib/ios/AirMaps.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 628F81201FD16DF80058313A /* AIRMapLocalTile.m in Sources */ = {isa = PBXBuildFile; fileRef = 628F811F1FD16DF80058313A /* AIRMapLocalTile.m */; }; 628F81231FD16EFA0058313A /* AIRMapLocalTileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 628F81221FD16EFA0058313A /* AIRMapLocalTileManager.m */; }; 62AEC4D41FD5A0AA003225E0 /* AIRMapLocalTileOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 62AEC4D31FD5A0AA003225E0 /* AIRMapLocalTileOverlay.m */; }; + 8BC85FB02107CFEC0006CEA5 /* AIRGoogleMapOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BC85FAF2107CFEC0006CEA5 /* AIRGoogleMapOverlay.m */; }; 9B9498CA2017EFB800158761 /* AIRGoogleMapUrlTile.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9498A62017EFB400158761 /* AIRGoogleMapUrlTile.m */; }; 9B9498CB2017EFB800158761 /* AIRGoogleMapURLTileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9498A72017EFB400158761 /* AIRGoogleMapURLTileManager.m */; }; 9B9498CC2017EFB800158761 /* AIRGMSPolygon.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9498A82017EFB400158761 /* AIRGMSPolygon.m */; }; @@ -109,6 +110,9 @@ 628F81211FD16EAB0058313A /* AIRMapLocalTileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRMapLocalTileManager.h; sourceTree = ""; }; 628F81221FD16EFA0058313A /* AIRMapLocalTileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIRMapLocalTileManager.m; sourceTree = ""; }; 62AEC4D31FD5A0AA003225E0 /* AIRMapLocalTileOverlay.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AIRMapLocalTileOverlay.m; path = AirMaps/AIRMapLocalTileOverlay.m; sourceTree = ""; }; + 8BC85FAD2107C0BD0006CEA5 /* User.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = User.xcconfig; sourceTree = ""; }; + 8BC85FAE2107CFD80006CEA5 /* AIRGoogleMapOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIRGoogleMapOverlay.h; path = "../../../../../react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h"; sourceTree = ""; }; + 8BC85FAF2107CFEC0006CEA5 /* AIRGoogleMapOverlay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIRGoogleMapOverlay.m; path = "../../../../../react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m"; sourceTree = ""; }; 9B9498A42017EFB400158761 /* AIRGoogleMapCallout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIRGoogleMapCallout.h; path = AirGoogleMaps/AIRGoogleMapCallout.h; sourceTree = ""; }; 9B9498A52017EFB400158761 /* AIRGoogleMapPolygonManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIRGoogleMapPolygonManager.h; path = AirGoogleMaps/AIRGoogleMapPolygonManager.h; sourceTree = ""; }; 9B9498A62017EFB400158761 /* AIRGoogleMapUrlTile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIRGoogleMapUrlTile.m; path = AirGoogleMaps/AIRGoogleMapUrlTile.m; sourceTree = ""; }; @@ -171,6 +175,7 @@ 62AEC4D31FD5A0AA003225E0 /* AIRMapLocalTileOverlay.m */, 11FA5C531C4A1296003AC2EE /* AirMaps */, 11FA5C521C4A1296003AC2EE /* Products */, + 8BC85FAD2107C0BD0006CEA5 /* User.xcconfig */, ); sourceTree = ""; }; @@ -268,6 +273,8 @@ 9B9498C92017EFB800158761 /* AIRGoogleMapPolygonManager.m */, 9B9498B82017EFB600158761 /* AIRGoogleMapPolyline.h */, 9B9498BB2017EFB600158761 /* AIRGoogleMapPolyline.m */, + 8BC85FAE2107CFD80006CEA5 /* AIRGoogleMapOverlay.h */, + 8BC85FAF2107CFEC0006CEA5 /* AIRGoogleMapOverlay.m */, 9B9498B62017EFB500158761 /* AIRGoogleMapPolylineManager.h */, 9B9498B12017EFB500158761 /* AIRGoogleMapPolylineManager.m */, 9B9498C82017EFB800158761 /* AIRGoogleMapUrlTile.h */, @@ -365,6 +372,7 @@ 1125B2DA1C4AD3DA007D0023 /* AIRMap.m in Sources */, 1125B2DF1C4AD3DA007D0023 /* AIRMapCoordinate.m in Sources */, 9B9498D62017EFB800158761 /* AIRGoogleMapCircleManager.m in Sources */, + 8BC85FB02107CFEC0006CEA5 /* AIRGoogleMapOverlay.m in Sources */, 1125B2F21C4AD445007D0023 /* SMCalloutView.m in Sources */, 2163AA501FEAEDD100BBEC95 /* AIRMapPolylineRenderer.m in Sources */, 9B9498D02017EFB800158761 /* AIRGoogleMapPolylineManager.m in Sources */, @@ -469,6 +477,7 @@ }; 11FA5C5B1C4A1296003AC2EE /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8BC85FAD2107C0BD0006CEA5 /* User.xcconfig */; buildSettings = { HEADER_SEARCH_PATHS = ( "$(SRCROOT)/../../react-native/React/**", @@ -483,6 +492,7 @@ }; 11FA5C5C1C4A1296003AC2EE /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8BC85FAD2107C0BD0006CEA5 /* User.xcconfig */; buildSettings = { HEADER_SEARCH_PATHS = ( "$(SRCROOT)/../../react-native/React/**", diff --git a/lib/ios/User.xcconfig b/lib/ios/User.xcconfig new file mode 100644 index 000000000..e69de29bb diff --git a/react-native-google-maps.podspec b/react-native-google-maps.podspec index 92379cef6..740d5a3d4 100644 --- a/react-native-google-maps.podspec +++ b/react-native-google-maps.podspec @@ -14,7 +14,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/airbnb/react-native-maps.git" } s.source_files = "lib/ios/AirGoogleMaps/**/*.{h,m}" - s.compiler_flags = '-fno-modules' + s.compiler_flags = '-DHAVE_GOOGLE_MAPS=1', '-DHAVE_GOOGLE_MAPS_UTILS=1', '-fno-modules' s.dependency 'React' s.dependency 'GoogleMaps', '2.5.0' From ce3cd2cace636b2d96d0d00be2e260337685b18c Mon Sep 17 00:00:00 2001 From: Chris Edwards Date: Thu, 23 Aug 2018 14:59:12 +0100 Subject: [PATCH 2/2] check for HAVE_GOOGLE_MAPS in AIRGoogleMapOverlay --- lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h | 4 ++++ lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h b/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h index 0e2c4e278..0fd00ebdf 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.h @@ -4,6 +4,8 @@ // Created by Taro Matsuzawa on 5/3/17. // +#ifdef HAVE_GOOGLE_MAPS + #import #import #import @@ -21,3 +23,5 @@ @property (nonatomic, weak) RCTBridge *bridge; @end + +#endif diff --git a/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m b/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m index 9caf634aa..20dba83bf 100644 --- a/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m +++ b/lib/ios/AirGoogleMaps/AIRGoogleMapOverlay.m @@ -3,6 +3,8 @@ // Created by Nick Italiano on 3/5/17. // +#ifdef HAVE_GOOGLE_MAPS + #import "AIRGoogleMapOverlay.h" #import @@ -74,3 +76,5 @@ - (void)setBoundsRect:(NSArray *)boundsRect } @end + +#endif