Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
f1sh1918 opened this issue Jul 26, 2021 · 32 comments · Fixed by #1571
Closed

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

f1sh1918 opened this issue Jul 26, 2021 · 32 comments · Fixed by #1571

Comments

@f1sh1918
Copy link

f1sh1918 commented Jul 26, 2021


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

@f1sh1918 f1sh1918 changed the title Build Issue in MGLModule.m Multiple Errors in Build Issue in MGLModule.m Multiple Errors Jul 26, 2021
@ferdicus
Copy link
Member

Can you try with the default pack in Mapbox ios sdk please instead of MapLibre

@f1sh1918
Copy link
Author

  • Commented out: $RNMBGL_Use_SPM = true to use MapBox
  • pod install

Downloading dependencies
Installing Mapbox-iOS-SDK (5.9.0)
Installing MapboxMobileEvents (0.10.2)
Installing react-native-mapbox-gl 8.2.1

Rebuild project leads to the same errors

@f1sh1918 f1sh1918 changed the title Build Issue in MGLModule.m Multiple Errors Build issue for ios in MGLModule.m Multiple Errors Jul 26, 2021
@ferdicus
Copy link
Member

could you also please change the order of these:

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

@f1sh1918
Copy link
Author

f1sh1918 commented Jul 26, 2021

could you also please change the order of these:

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

did not solve the issue unfortunately.
Even the prebuilding fails because MGLStyle object is missing the types

@ferdicus
Copy link
Member

but a vanilla react-native app, without any dependencies does work?!

@ferdicus
Copy link
Member

or, what does happen when you try building the /example app?

@f1sh1918
Copy link
Author

yes it builds and loads in the emulator without any issues.
I'm not using expo but react native cli

  • just removed @react-native-mapbox-gl/maps
  • Set podfile back to default
  • pod install
  • rebuild app

@jutaz
Copy link

jutaz commented Jul 26, 2021

I'm also seeing this happen in an application where we've upgraded to latest @react-native-mapbox-gl/maps and switched to Maplibre - both 5.12.0 and 5.11.0 seem to be broken:
Screen Shot 2021-07-26 at 18 58 25

@noway
Copy link

noway commented Jul 27, 2021

Happens to me too. Podfile:

platform :ios, '10.0'
plugin 'cocoapods-patch'

begin
  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
rescue LoadError
  puts "WARNING: ../node_modules/@react-native-community/cli-platform-ios/native_modules couldn't be loaded. Should be fine if you're in prepenv"
end

project 'myapp',
    'Debug' => :debug,
    'Release' => :release,
    'DevDebug' => :debug,
    'DevRelease' => :release


target 'myapp' do
  $RNMBGL_Use_SPM = {
    url: "https://github.com/maplibre/maplibre-gl-native-distribution",
    requirement: {
      kind: "upToNextMajorVersion",
      minimumVersion: "5.11.0"
    },
    product_name: "Mapbox"
  }
  $ReactNativeMapboxGLIOSVersion = "6.3.0"

  # Pods for myapp
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  permissions_path = '../node_modules/react-native-permissions/ios'

  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
  pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec"
  pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
  pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec"
  pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
  pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"

  pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency.podspec"

  target 'myappTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

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

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

def fix_mapbox_events(installer)
  installer.pod_targets.each do |pod|
    if pod.name == 'MapboxMobileEvents'
      def pod.build_type;
        Pod::BuildType.dynamic_framework
      end
    end
  end
end

puts "Podfile has been eval'd"

package.json:

    ...
    "react-native": "0.61.5",
    "@react-native-mapbox-gl/maps": "8.2.1",
    ...

react-native info:

warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-comparison-slider: https://npmjs.com/package/react-native-comparison-slider
  - react-native-orientation: https://github.com/yamill/react-native-orientation#readme
  - react-native-video: https://npmjs.com/package/react-native-video
  - react-native-zip-archive: https://github.com/mockingbot/react-native-zip-archive
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Fetching system and libraries information...
System:
    OS: macOS 11.3.1
    CPU: (8) arm64 Apple M1
    Memory: 106.03 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.5.0 - /var/folders/85/2xpmzxms1tsgzr9nqnhszzfw0000gn/T/yarn--1627356302717-0.9925064687240368/node
    Yarn: 1.22.10 - /var/folders/85/2xpmzxms1tsgzr9nqnhszzfw0000gn/T/yarn--1627356302717-0.9925064687240368/yarn
    npm: 7.19.1 - /opt/homebrew/bin/npm
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 23, 25, 27, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7199119
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
✨  Done in 15.25s.

@ferdicus ferdicus changed the title Build issue for ios in MGLModule.m Multiple Errors Build issue for ios in MGLModule.m Multiple Errors - MapLibre SDK Jul 27, 2021
@f1sh1918
Copy link
Author

f1sh1918 commented Jul 27, 2021

@jutaz
which package versions and podfile did you use before upgrading that worked?

@jutaz
Copy link

jutaz commented Jul 27, 2021

@f1sh1918 I've had:

(from podfile.lock):

@react-native-mapbox-gl-mapbox-static (5.8.0)
react-native-mapbox-gl (8.0.0)
Mapbox-iOS-SDK (5.9.0)
MapboxMobileEvents (0.10.2)

And:

in package.json:

@react-native-mapbox-gl/[email protected]

I've switched to Maplibre in this change.

@f1sh1918
Copy link
Author

@jutaz
When i downgrade to 8.0.0 i'm facing pre_install errors.
How was your podfile looking?
Do you have the pre & post_install hooks like this:

$RNMBGL.pre_install(installer)

@jutaz
Copy link

jutaz commented Jul 27, 2021

I do have them like so:

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

Previously (@8.0.0) neither hook was present for $RNMBGL.

@jutaz
Copy link

jutaz commented 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

@f1sh1918
Copy link
Author

f1sh1918 commented Jul 28, 2021

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

Is there a configuration with mapbox 5.x working on android and ios for you?
I even get the same errors using mapbox instead of maplibre, even with @8.0.0

Update:
I just had to remove swift package of MapLibre manually to get normal mapBox work ;)

@ferdicus
Copy link
Member

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

@jutaz
Copy link

jutaz commented Jul 30, 2021

@ferdicus you are absolutely correct - it did download 5.12.0 of MapLibre. Applied your suggestion and now it builds. however it seem to crash when running the app with 5.11.0 (though probably not related to the original issue):

2021-07-30 14:24:59.955555+0300 app[64582:3617029] Failed to make complete framebuffer object 8cd6
2021-07-30 14:25:02.958816+0300 app[64582:3617029] Failed to bind EAGLDrawable: <CAEAGLLayer: 0x600000bb9ac0> to GL_RENDERBUFFER 1
libc++abi: terminating with uncaught exception of type std::domain_error
terminating with uncaught exception of type std::domain_error
CoreSimulator 757.5 - Device: iPhone 12 (C9643721-E984-49ED-9F0C-9A53CFF6E894) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12

After deeper digging it looks like it's fixed in 5.13.0 - I'll try building on x86 now (I was building on arm64 M1).

I'll also test on Android 👍

@jutaz
Copy link

jutaz commented Jul 30, 2021

Hrm, look like I'm seeing exactly the same crash on x86 when trying to open up the map. Rest of the app seems to work just fine, however.

@ferdicus
Copy link
Member

hmm, yeah - the complication with M1 chipsets certainly doesn't help 😅

I was building fine with 5.11.0 on pre M1 MacBook for ARM64 architecture.

My assumption why it doesn't build for anything post that, is probably this change: maplibre/maplibre-native#90
Which "replac[es] hardcoded configuration with configurable API and remov[ed] Mapbox assets and dependencies"

@ferdicus
Copy link
Member

Also build under Release configuration onto a device (iPad mini 5. Gen) - worked fine with 5.11.0 also opened map and all 👍🏿

@f1sh1918
Copy link
Author

f1sh1918 commented Aug 2, 2021

@ferdicus @jutaz

thx for the great support :)

I can confirm that maplibre 5.11 is working fine.
Just had to remove manually version 5.12 swift package before installing v5.11.

@ferdicus
Copy link
Member

ferdicus commented Aug 2, 2021

@ferdicus @jutaz

thx for the great support :)

I can confirm that maplibre 5.11 is working fine.
Just had to remove manually version 5.12 swift package before installing v5.11.

Great to hear 👍🏿

I'll close this ticket then

@ferdicus ferdicus closed this as completed Aug 2, 2021
@noway
Copy link

noway commented Aug 10, 2021

yeah it worked for me too. thanks ferdicus!

@mvanroon
Copy link

mvanroon commented Sep 28, 2021

Pinning Maplibre version 5.11 fixes the build, but this critical bug was fixed in Maplibre 5.12. Does anyone know of a way to make this library work with Maplibre >= 5.12.0 ?

@ferdicus
Copy link
Member

ferdicus commented Sep 28, 2021

Pinning Maplibre version 5.11 fixes the build, but this critical bug was fixed in Maplibre 5.12. Does anyone know of a way to make this library work with Maplibre >= 5.12.0 ?

Making MapLibre 5.12 work is a non-trivial undertaking, which atm no one is working on afaik

@mvanroon
Copy link

Pinning Maplibre version 5.11 fixes the build, but this critical bug was fixed in Maplibre 5.12. Does anyone know of a way to make this library work with Maplibre >= 5.12.0 ?

Making MapLibre 5.12 is a non-trivial undertaking, which atm no one is working on afaik

Users are seeing crashes happen on a regular base. We're seeing the same thing. Sounds trivial to me.

@ferdicus
Copy link
Member

ferdicus commented Sep 28, 2021

Pinning Maplibre version 5.11 fixes the build, but this critical bug was fixed in Maplibre 5.12. Does anyone know of a way to make this library work with Maplibre >= 5.12.0 ?

Making MapLibre 5.12 is a non-trivial undertaking, which atm no one is working on afaik

Users are seeing crashes happen on a regular base. We're seeing the same thing. Sounds trivial to me.

Sorry, my message was missing a word "work".
I'm not saying the issue at hand is trivial - making MapLibre work 5.12 is non-trivial.
It will require some rework on the repo and could potentially hinder support for MapBox v10 SDKs moving forward...

@mvanroon
Copy link

Gotcha! Thanks!

@tomgreco
Copy link

tomgreco commented Oct 8, 2021

@ferdicus any idea if/when MapLibre 5.12 will be supported?

I cannot run on iOS simulator with 5.11 because of issue similar to this: https://github.com/react-native-mapbox-gl/maps/issues/1355#issuecomment-928994988

And Apple review team will reject the app if it crashes on simulator.

@ferdicus
Copy link
Member

@ferdicus any idea if/when MapLibre 5.12 will be supported?

I cannot run on iOS simulator with 5.11 because of issue similar to this: #1355 (comment)

And Apple review team will reject the app if it crashes on simulator.

Nope, nothing on the roadmap yet

@mfazekas
Copy link
Contributor

I've added a fix for this: #1571

You can test this using react-native-mapbox-gl/maps#mfazekas/map-libre-support in your package.json

@yurilawnguru
Copy link

I'm still facing the error using the maplibre v5.12, have you guys find any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants