React-native-mapbox-gl: (Ios) Error Module 'Mapbox' not found

Created on 21 Oct 2018  Â·  13Comments  Â·  Source: nitaliano/react-native-mapbox-gl

Install With CocoaPods

Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'xxxx' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'RNSound', :path => '../node_modules/react-native-sound'

  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'react-native-maps', path: rn_maps_path

  # pod 'GoogleMaps'  # Remove this line if you don't want to support Google Maps on iOS
pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Error

/@mapbox/react-native-mapbox-gl/ios/RCTMGL/CameraStop.h:9:9: fatal error: module 'Mapbox' not found
@import Mapbox;
 ~~~~~~~^~~~~~
1 error generated.


** BUILD FAILED **

react-native-cli: 2.0.1
react-native: 0.51.0

Most helpful comment

I solved this problem.
Follow the steps below:

  1. yarn add @mapbox/react-native-mapbox-gl

  2. react-native link
    If this step is finished, running react-native run-ios directly will report undel this error.found` this error. The official documentation does not give the corresponding detailed steps.

  3. react-native-mapbox-gl/example/node_modules/@mapbox/react-native-mapbox-gl/ios/Mapbox.framework add Link Binary with Libraries

Looks like this:
121540372433_ pic_hd

Then run react-native run-ios will not report an error again. But running the program will crash.
Reason: image not found


  1. image
    image

finally, Looks like this:
image

Then run react-native run-ios will not report an error again.

All 13 comments

@chaipipatP same issue here,Have you solved the problem?

I solved this problem.
Follow the steps below:

  1. yarn add @mapbox/react-native-mapbox-gl

  2. react-native link
    If this step is finished, running react-native run-ios directly will report undel this error.found` this error. The official documentation does not give the corresponding detailed steps.

  3. react-native-mapbox-gl/example/node_modules/@mapbox/react-native-mapbox-gl/ios/Mapbox.framework add Link Binary with Libraries

Looks like this:
121540372433_ pic_hd

Then run react-native run-ios will not report an error again. But running the program will crash.
Reason: image not found


  1. image
    image

finally, Looks like this:
image

Then run react-native run-ios will not report an error again.

@giantss Shouldn't be pod install be enough to have this included?

Anyway, I'm facing a strange issue. On a fresh installed machine, this does not happen using XCode 10, on another machine with the SAME code this produces the mentioned error above :( is there anything to solve this issue? (like some hidden lock-file which I need to remove, as the native mapbox SDK seems to be downloaded somewhere ...)

@FibreFoX I started to think the same as you, but it was not as perfect as I thought.
I have not upgraded to xcode 10 , I am using xcode 9.4 .
I have not encountered such a problem. Sorry.

@giantss no worries :) just wanted to state that the provided solution via "configuration via clicking" is against the idea of using that Podfile (at least IMHO).

If it helps, we are using RN 0.57.4 and @mapbox/react-native-mapbox-gl in version 6.1.3.

@FibreFoX I upgraded my environment today and encountered the same problem as you. #1424

I'm seeing this issue just today on App Center. Going to try @giantss linking procedures though I thought I had it all done correctly.

I'm getting the same error, but just on CircleCi. Locally (from Xcode or Fastlane) it works fine, but when it builds with CircleCi+Fastlane, on both Xcode 9.3 and 10.1.0, id doesn't work out.

Manual installation or via podfile, the same error happens:

â–¸ /Users/distiller/project/packages/my-project/node_modules/@mapbox/react-native-mapbox-gl/ios/RCTMGL/RCTMGLCallout.h:11:9: fatal error: module 'Mapbox' not found
â–¸ @import Mapbox;

Any idea of what can be done on Fastlane or CircleCi to make it works?


Update:

After almost 20 different trial and error, and all related to module/framework resolving on Xcode - following basically StackOverflow posts like this, I realized something that was not clear: when I look into ios folder I don't see Mapxbox.framework. Then I saw that Mapxbox.framework is installed from an npm preinstall hook. So taking a look in the logs I figured out that this was not being called somehow from CircleCi.

(I don't know yet why this npm hook works fine locally, but doesn't work for CircleCi - maybe it's a Lerna issue).

A not ideal solution that I found for it: call mapbox's script to download the framework manually before the ios build (npm explore @mapbox/react-native-mapbox-gl -- npm run fetch:ios:sdk).

Are you using pods?

We got this tracked in a duplicate issue and a PR open to use pods. Expect this to become easier very soon.

@kristfal that's great to hear – can you link to the duplicate issue?

I was experiencing this issue as well, and was surprised CocoaPods wasn't handling this. Turns out I was on CocoaPods 1.5.0; upgrading to 1.6.1 solved the issue for me.

I just spent a couple of hours struggling with pretty much the same issue using @react-native-mapbox-gl/maps (and RN 0.61). Here are some brief notes, in case it helps anyone else in a similar situation. It's mostly the same as what estevaolucas said above but with a little bit of extra context.

  • In CircleCI, we split our workflow into separate jobs for installing npm deps then building on iOS, building on Android, deploying to TestFlight, etc.
  • The npm install step was running on a Linux machine (and the iOS build step was running on a Mac)
  • The npm run fetch:ios:sdk preinstall hook calls another script scripts/download-mapbox-gl-native-ios-if-on-mac.js
  • That script checks the platform and will only download the Mapbox SDK if it's running on a Mac
  • Because our npm install step was running on Linux, the Mapbox SDK never got downloaded
  • To fix it, I ran npm explore @react-native-mapbox-gl/maps -- npm run fetch:ios:sdk in the job running on a Mac
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Maxence-Machu picture Maxence-Machu  Â·  3Comments

Craytor picture Craytor  Â·  3Comments

alexisohayon picture alexisohayon  Â·  4Comments

Amalp picture Amalp  Â·  3Comments

madroneropaulo picture madroneropaulo  Â·  4Comments