maps: Build issue for ios in MGLModule.m Multiple Errors - MapLibre SDK


Describe the bug
The IOS Build Process fails with multiple errors in MGLModule.m after adding react-native-mapbox lib and installing pods

To Reproduce

  • npx react-native init MapTest
  • yarn add @react-native-mapbox-gl/maps
  • adjust podfile (like below)
  • pod install
  • open workspace file with XCode 12.5.1 and run build

Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'MapTest' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'MapTestTests' do
    inherit! :complete
    # Pods for testing
  end

  $RNMBGL_Use_SPM = true

    pre_install do |installer|
      $RNMBGL.pre_install(installer)
    end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
     $RNMBGL.post_install(installer)
  end
end

Expected behavior
Build runs successfully

Actual behavior
Build fails with multiple errors in MGLModule.m

 // style urls
    NSMutableDictionary *styleURLS = [[NSMutableDictionary alloc] init];
    [styleURLS setObject:[MGLStyle.streetsStyleURL absoluteString] forKey:@"Street"];
    [styleURLS setObject:[MGLStyle.darkStyleURL absoluteString] forKey:@"Dark"];
    [styleURLS setObject:[MGLStyle.lightStyleURL absoluteString] forKey:@"Light"];
    [styleURLS setObject:[MGLStyle.outdoorsStyleURL absoluteString] forKey:@"Outdoors"];
    [styleURLS setObject:[MGLStyle.satelliteStyleURL absoluteString] forKey:@"Satellite"];
    [styleURLS setObject:[MGLStyle.satelliteStreetsStyleURL absoluteString] forKey:@"SatelliteStreet"];
....
RCT_EXPORT_METHOD(setAccessToken:(NSString *)accessToken)
{
    [MGLAccountManager setAccessToken:accessToken];
}

Errors:

  • Property ‘streetsStyleURL’ not found on object of type ‘MGLStyle’ (line 30-35)
  • occurring for all attributes of MGLStyle object
  • Use of undeclared identifier ‘MGLAccountManager’ (line 243+258)
Bildschirmfoto 2021-07-26 um 15 57 44

Versions (please complete the following information):

  • Platform: iOS
  • Platform OS: iOS 10
  • Device: IPhone 12 mini
  • Emulator/ Simulator: yes
  • Dev OS: OSX 11.4
  • react-native-mapbox-gl Version 8.2.1
  • Mapbox GL version 5.9.0
  • React Native Version 0.63.4

Additional context
Build run on XCode 12.5.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 32 (12 by maintainers)

Most upvoted comments

Can everyone observing this issue let me know which version is actually downloaded and used in
XCode > PROJECT > Swift Packages??

My suspicion is, that it actually downloads version 5.12.0 of MapLibre, because these are the requirements that are used when nothing specific is defined (and you aren’t on master):

    requirement: {
      kind: "upToNextMajorVersion",
      minimumVersion: "5.11.0"
    }

You can circumvent this by adding this to your Podfile:

  $RNMBGL_Use_SPM = {
    url: "https://github.com/maplibre/maplibre-gl-native-distribution",
    requirement: {
        kind: "exactVersion",
        version: "5.11.0"
    },
    product_name: "Mapbox"
  }

Make sure to previously remove the current swift package download in XCode, just to be sure. 👍🏿

@jutaz, reason why it probably works in Android is, that it doesn’t use something like this upToNextMajorVersion. Could you try with android-v9.5.0 and report back please if you find the time? Thanks in advance 🙇🏿

FWIW this works beautifully on Android w/ Maplibre and the same versions of packages. So it seems like something is off w/ iOS

yeah it worked for me too. thanks ferdicus!