react-native-maps: 0.21.0 iOS build failed when Google Maps are not included

Is this a bug report?

Yes

Have you read the Installation Instructions?

Yes

Environment

react: 16.3.0 react-native: 0.54.4 react-native-maps: 0.21.0 iOS only, without Google Maps

Steps to Reproduce

Expected Behavior

The build succeeds.

Actual Behavior

The iOS build crashes with AIRGoogleMapCircle.h:7:9: fatal error: 'GoogleMaps/GoogleMaps.h' file not found even if I do not use Google Maps. The cause is commit https://github.com/react-community/react-native-maps/commit/d22f96f9115f10b50085206463143c421f8d948d where some Google-depending sources have been added to AirMaps.xcodeproj/project.pbxproj.

For now I got things moving again with a npm postinstall script that deletes the references: "postinstall": "sed -i '' '/Google.*\\.[h|m]/d' node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj/project.pbxproj"

Reproducible Demo

I expect that any iOS project that does not use Google Maps will have the same problem.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 32
  • Comments: 46 (4 by maintainers)

Most upvoted comments

I ran into the same issue using:

react: 16.3.0
react-native: 0.54.2
react-native-maps: 0.21.0

without having the GoogleMaps headers configured for iOS. Fixed by applying the.patch file below to react-native-maps tag v0.21.0 during postinstall. I’m not using Pod yet.

https://gist.github.com/meylor/442cf17ae6ff6213b358866dde4f5b77 To use the patch, copy the file above to node_modules/react-native-maps and run patch -p1 < react-native-maps-remove-google-support.patch

The sed command didn’t fix the issue for me.

Is there any installation instructions for people who do not use cocoapods? Cann’t get the new version work in ios because of the GoogleMap.h not fount error.

Or, does anyone who managed to work by manually installing GoogleMap SDK?

I just upgraded from 0.20.1 to 0.21.0 and am also having problems.

Environment react: ^16.3.0-alpha.1 react-native: 0.54.4 react-native-maps: 0.21.0 iOS, without Google Maps

Screenshot screenshot 2018-04-03 16 53 06

We managed to get it installed without CocoaPods!

cc: @theonetheycallneo maybe we could share what we did with this thread to help others looking to do a pure manual install.

nothing has worked for me so far 😦

@rborn @rafaellincoln I can try to take a look at making a PR this weekend. I don’t think that removing the AirGoogleMaps dependencies from project.pbxproj is the right approach since someone may actually want to use GoogleMaps on iOS. I’m guessing that most people are having an issue because they’re not using CocoaPods, which is a requirement in the installation instructions.

Simple solution should be to add instructions for manually adding the GoogleMaps header files. I haven’t yet looked at the source, but it seems odd that the default behavior for not using GoogleMaps is to not have the Pod dependencies, which are a requirement in the project.pbxproj file.

  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS

@billtlee @radubatori suggested a workaround himself.

I automated it (for CI etc.) by having this in the package.json:

  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "postinstall": "cross-os fix-maps"
  },
  "cross-os": {
    "fix-maps": {
      "darwin": "sed -i '' '/Google.*\\.[h|m]/d' node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj/project.pbxproj"
    }
  },

and of course npm install -S cross-os

It basically removes all references to Google Maps in the faulty AirMaps.xcodeproj/project.pbxproj

@TheWrongAlice If running sed -i '' '/Google.*\\.[h|m]/d' node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj/project.pbxproj (macos) will fix your problem, then it’s probably the same issue.

#2396 was merged, please test with the latest git version. Please keep in mind that you might have to setup the module again as now it works with react-native link Read the install manual carefully

This issue looks like a duplicate of https://github.com/react-community/react-native-maps/issues/2270.

I opened a PR at https://github.com/react-community/react-native-maps/pull/2310 which coincidentally appears to implement the same patch that @meylor came up with, please test it to see if it fixes this issue for y’all!

@radubatori The gradle 4 issue you mentioned sounds like it could be https://github.com/facebook/react-native/issues/16906

@meylor I got some type of error running that patch. Now I got 33 new build errors. Did I use it wrong?

project_root$ cd node_modules/react-native-maps/
project_root/node_modules/react-native-maps$ patch -p1 < react-native-maps-remove-google-support.patch
patching file ./lib/ios/AirMaps.xcodeproj/project.pbxproj
patch unexpectedly ends in middle of line
Hunk #4 succeeded at 240 with fuzz 1.

@hlbp I do still get the “unexpectedly ends in middle of line” but it seems harmless as I am still able to build my application in Xcode. I think I just needed to do a Clean and delete my build folder (rm -rf ios/build) and then it worked 😃

I’ve reopened the issue, but I cannot provide a clean environment to reproduce it.

@arichnad The extra backslash is there to escape the backslash in package.json. If the command is ran directly, then yes, one backslash has to be removed.

Can you reopen this ticket? I’m also having this problem. The sed line that @radubatori suggests does fix this problem for me. (@radubatori you should remove one of the backslashes in your sed line)

@nolan12345 it doesn’t work. Solution by @dj-hedgehog is awsome! 👍

Add pod ‘GoogleMaps’, ‘~> 2.7.0’ and then pod install solves the problem

@theonetheycallneo Hi! I tried your instruction, but maybe something missed.

What I am doing.

  1. Install react-native-map via yarn (it help to install for react-native@0.55.x
  2. Download ios sdk zip 2.0.1 from https://developers.google.com/maps/documentation/ios-sdk/start and extract it in my temporarly folder.

question: what means the line $(SRCROOT)/Frameworks/Google-Maps-iOS-Utils in this step?

  1. Open xcode, I have had already folder Frameworks and it contains libReact.a, so I added GoogleMaps.framework, GoogleMapsCore.framework and GoogleMapsBase.framework from unzipped ios sdk folder.

airgooglemap m 2018-05-24 09-36-42

Drag this three frameworks to Embedded Binaries

rbtse xcodeproj 2018-05-24 09-42-02

notice: I noticed, that after that, there were no changes in Build Phases/Compile Sources, it contains only main.m and AppDelegate.m.

question: What it means? I dont have a folder Google-Maps-iOS-Utilsin xcodeFrameworks`.

  • Search Xcode Build Settings for “Header Paths” and add your new framwork folder from above:
$(SRCROOT)/Frameworks/Google-Maps-iOS-Utils
  1. Add AirMaps folder from node_modules/react-native-maps/lib/ios. I drag from finder to Frameworks folder in xcode. You could see it in left sidebar in above screenshot.
$(GITROOT)/node_modules/react-native-maps/lib/ios/AirGoogleMaps
$(GITROOT)/node_modules/react-native-maps/lib/ios/AirMaps

notice: In Build Phases/Compile Sources` there are a lot of files after step 4.

  1. After that I was trying to build an ios app.

But I got an error:

airgooglemap m 2018-05-24 09-47-20

I research a problem and found that this is a dependency from https://github.com/googlemaps/google-maps-ios-utils but I don`t have it. How I could install it?

@TheWrongAlice what were you doing wrong? i have the same problem like you. im getting

Helmers-Mac:react-native-maps helmer$ patch -p1 < react-native-maps-remove-google-support.patch
patching file ./lib/ios/AirMaps.xcodeproj/project.pbxproj
patch unexpectedly ends in middle of line
Hunk #4 succeeded at 240 with fuzz 1. 

@meylor I got your solution to work now (I guess I was doing something wrong the first time). My build is succeeding! 🎈 I hope that this can be fixed in the master branch soon.

@dj-hedgehog worked ! thx !

@duro would love to see manual install instructions sans cocoa pods cc @theonetheycallneo

I would love to see some installation instructions that do not require CocoaPods. No matter how complicated they may be.

@hamsddxn this solution means it needs to be done every time yarn install re-installs libraries and it will not work for CI-s.

I use cocoa-pods in my projects but I prefer to keep react-native out of it so far, as there are other libraries that depend on react and don’t support cocoapods (react-native-navigation is one of them).

@TheWrongAlice here are the versions from my package.json

{
  "name": "MobileApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "postinstall": "scripts/postinstall.sh",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.3.0",
    "react-native": "0.54.2",
    "react-native-maps": "0.21.0"
    ...
  },
  "devDependencies": {
    ...
  },
  "jest": {
    "preset": "react-native"
  }
}

postinstall.sh is is just doing patch -p1 < $patchfile ; perhaps you’re not having the same issue?

@rafaellincoln could you please have a look? 🤗

I did not use Google Maps from the start, so the podfile does not reference ‘react-native-google-maps’ or ‘GoogleMaps’. The same result is obtained if I do not use pods and add AirMaps as a library directly.