nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

(Ios) Error Module 'Mapbox' not found #1402

Closed chaipipatP closed 5 years ago

chaipipatP commented 6 years ago

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

giantss commented 6 years ago

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

giantss commented 6 years ago

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.

FibreFoX commented 5 years ago

@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 ...)

giantss commented 5 years ago

@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.

FibreFoX commented 5 years ago

@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.

giantss commented 5 years ago

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

alburdette619 commented 5 years ago

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.

estevaolucas commented 5 years ago

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).

onitzschke commented 5 years ago

Are you using pods?

kristfal commented 5 years ago

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

ashfurrow commented 5 years ago

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

ashfurrow commented 5 years ago

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.

davidxmoody commented 5 years ago

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.