question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ferdicuscommented, Jul 30, 2021

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 🙇🏿

2reactions
jutazcommented, Jul 27, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common crash referencing ...
I am using this library through react-native-mapbox-gl. Since switching the base library from mapbox-gl-native, I am seeing a huge increase ...
Read more >
Troubleshooting Mapbox Maps and Navigation SDKs for iOS ...
Learn how to troubleshoot issues when installing the Mapbox Maps or Navigation SDK for iOS with Swift Package Manager, CocoaPods, and Carthage.
Read more >
Mapbox Maps SDK for iOS
The Mapbox Maps SDK for iOS is an open-source framework for embedding interactive map views with scalable, customizable vector maps into Cocoa Touch ......
Read more >
ld: building for iOS Simulator, bu… | Apple Developer Forums
Hi! Running Xcode 12.5 using Rosetta 2 on simulator with iOS 14.5, and I get the following error: ld: building for iOS Simulator,...
Read more >
Using the MapLibre GL Native SDK for iOS with Amazon ...
The MapLibre GL Native SDK for iOS is a library based on Mapbox GL Native , and is compatible with the styles and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found