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

Chip Apple M1, unable to compile the example project in IOS simulator #1139

Closed
babeone opened this issue Jan 3, 2021 · 40 comments
Closed

Chip Apple M1, unable to compile the example project in IOS simulator #1139

babeone opened this issue Jan 3, 2021 · 40 comments
Labels
bug 🪲 Something isn't working iOS iOS related tickets upstream the bug source is a bug in native mapbox gl

Comments

@babeone
Copy link

babeone commented Jan 3, 2021

Describe the bug

Error in compiling for IOS simulator in new mac M1 chip. The project compile and run correctly on physical devices for both IOS/ANDROID (ipad and android phone). This is the error i'm getting on Xcode when trying to compile for a simulator : building for iOS Simulator, but linking in dylib built for iOS, file '/Users/xxxx/xxxx/xxxx/xxxx/maps/example/ios/Pods/@react-native-mapbox-gl-mapbox-static/dynamic/MapboxMobileEvents.framework/MapboxMobileEvents' for architecture arm64

To Reproduce

  1. git clone [email protected]:react-native-mapbox-gl/maps.git
  2. cd maps
  3. yarn add @react-native-mapbox-gl/maps
  4. cd example
  5. yarn
  6. try to run example folder on an IOS simulator in new mac M1 chip

maps Package.json

{ "name": "@react-native-mapbox-gl/maps", "description": "A Mapbox GL react native module for creating custom maps", "version": "8.1.0-rc10", "publishConfig": { "access": "public" }, "author": "React Native Mapbox Team", "main": "./javascript/index.js", "keywords": [ "gl", "ios", "android", "mapbox", "react-native" ], "license": "MIT", "repository": { "type": "git", "url": "https://github.com/react-native-mapbox-gl/maps" }, "scripts": { "fetch:style:spec": ". ./scripts/download-style-spec.sh", "generate": "node ./scripts/autogenerate", "test": "npm run lint && npm run unittest", "unittest": "jest", "unittest:single": "jest --testNamePattern", "format": "npm run lint -- --fix", "lint": "eslint . --ignore-pattern 'example' --fix && cd example/ && eslint ./src --fix" }, "peerDependencies": { "prop-types": ">=15.5.8", "react": "^16.6.1", "react-native": ">=0.59.9" }, "dependencies": { "@mapbox/geo-viewport": ">= 0.4.0", "@react-native-mapbox-gl/maps": "^8.1.0-rc10", "@turf/along": ">= 4.0.0 <7.0.0", "@turf/distance": ">= 4.0.0 <7.0.0", "@turf/helpers": ">= 4.6.0 <7.0.0", "@turf/length": ">= 4.6.0 <7.0.0", "@turf/nearest-point-on-line": ">= 4.0.0 <7.0.0", "@types/geojson": "^7946.0.7", "debounce": "^1.2.0" }, "devDependencies": { "@babel/core": "7.5.0", "@babel/plugin-proposal-class-properties": "7.10.4", "@babel/plugin-transform-exponentiation-operator": "7.10.4", "@babel/plugin-transform-runtime": "7.11.5", "@babel/runtime": "7.11.2", "@react-native-community/eslint-config": "^2.0.0", "@sinonjs/fake-timers": "^6.0.0", "babel-core": "6.26.3", "babel-eslint": "^10.0.1", "documentation": "13.1.0", "ejs": "^3.1.3", "ejs-lint": "^1.1.0", "eslint": "^7.3.0", "eslint-plugin-fp": "^2.3.0", "eslint-plugin-import": "2.22.1", "husky": "4.3.0", "jest": "25.5.4", "jest-cli": "25.5.4", "lint-staged": "^10.1.3", "metro-react-native-babel-preset": "0.49.1", "node-dir": "0.1.17", "prettier": "^2.0.4", "react": "16.8.6", "react-docgen": "^5.0.0-beta.1", "react-native": "0.59.10", "react-native-testing-library": "^6.0.0", "react-test-renderer": "16.8.3", "typescript": "4.0.5" }, "jest": { "preset": "react-native", "collectCoverageFrom": [ "javascript/**/*.js" ], "setupFiles": [ "./setup-jest.js", "./__tests__/__mocks__/react-native.mock.js" ], "modulePathIgnorePatterns": [ "example", "__tests__/__mocks__" ] }, "husky": { "hooks": { "pre-commit": "lint-staged && npm run generate" } }, "lint-staged": { "*.js": [ "yarn lint" ] } }

example Package.json

{ "name": "RNMapboxGLExample", "version": "1.0.0", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ./src", "postinstall": "node ./scripts/set_access_token.js && jetifier" }, "dependencies": { "@mapbox/geo-viewport": "^0.4.0", "@mapbox/mapbox-sdk": "^0.6.0", "@react-native-community/masked-view": "^0.1.7", "@turf/along": "^5.1.5", "@turf/bbox-polygon": "^6.0.1", "@turf/bearing": "^5.1.5", "@turf/distance": "^5.1.5", "@turf/helpers": "^6.1.4", "@turf/length": "^6.0.2", "@turf/line-distance": "^4.7.3", "@turf/nearest": "^4.7.3", "@turf/nearest-point-on-line": ">= 4.0.0 <7.0.0", "buffer": "^5.1.0", "debounce": "^1.2.0", "install": "^0.12.2", "moment": "^2.24.0", "npm": "^6.13.4", "prop-types": "^15.7.2", "react": "16.13.1", "react-native": "0.63.3", "react-native-elements": "^2.2.1", "react-native-gesture-handler": "^1.6.1", "react-native-safe-area-context": "^0.7.3", "react-native-safe-area-view": "^0.13.1", "react-native-screens": "^2.4.0", "react-native-svg": "^12.1.0", "react-native-vector-icons": "6.6.0", "react-navigation": "^4.3.7", "react-navigation-stack": "^2.3.11", "url": "^0.11.0" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^1.1.0", "@types/jest": "^26.0.0", "@types/react": "^16.9.36", "@types/react-native": "^0.62.13", "@types/react-test-renderer": "^16.9.2", "@typescript-eslint/eslint-plugin": "^3.0.0", "@typescript-eslint/parser": "^3.0.0", "babel-jest": "^25.1.0", "babel-plugin-module-resolver": "^3.2.0", "eslint": "^7.3.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.22.0", "glob-to-regexp": "^0.4.0", "jest": "^25.1.0", "jetifier": "^1.6.4", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1", "typescript": "^4.0.3" }, "jest": { "preset": "react-native", "setupFilesAfterEnv": [ "../setup-jest" ] } }

Expected behavior
Example run without a problem in IOS simulator on M1 mac

Actual behavior
Compiling error

Screenshots
Schermata 2021-01-03 alle 12 08 09
Schermata 2021-01-03 alle 12 08 14

  • Platform: [IOS]
  • Platform OS: [IOS 10]
  • Simulator: [yes]
  • Dev OS: [Mac Os Big Sur 11.1]
  • Mac: [Apple MacBook Pro 13 M1 2020]
  • Xcode: [12.3]
  • react-native-mapbox-gl Version: [8.1.0-rc10]
  • React Native Version: [0.63.3]
@mfazekas
Copy link
Contributor

mfazekas commented Jan 3, 2021

Two things you can try:

  1. Mapbox 6.3.0
  2. try with use_frameworks!

@babeone
Copy link
Author

babeone commented Jan 3, 2021

@mfazekas Thank you, i've tried but got the same error.

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'

INHIBIT_WARNING_BY_DEFAULT = true

if INHIBIT_WARNING_BY_DEFAULT
ORIG_POD = method(:pod)

def pod(name, *requirements)
options = requirements.last
if options.is_a?(Hash)
options[:inhibit_warnings] = true unless options.has_key?(:inhibit_warnings)
else
requirements.push({inhibit_warnings: true})
end
ORIG_POD[name, *requirements]
end
end

target 'RNMapboxGLExample' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])

pod 'react-native-mapbox-gl', :path => '../../', :inhibit_warnings => false
$ReactNativeMapboxGLIOSVersion = '~> 6.3'

target 'RNMapboxGLExampleTests' do
inherit! :search_paths
end

use_native_modules!
use_frameworks!

end

target 'RNMapboxGLExample-tvOS' do
target 'RNMapboxGLExample-tvOSTests' do
inherit! :search_paths
end

end
`

@mfazekas
Copy link
Contributor

mfazekas commented Jan 4, 2021

@babeone can you verify it's the correct version in Podfile.lock

I think

pod 'react-native-mapbox-gl', :path => '../../', :inhibit_warnings => false
$ReactNativeMapboxGLIOSVersion = '~> 6.3'

should be reversed. That is $ReactNativeMapboxGLIOSVersion should be before pod

@babeone
Copy link
Author

babeone commented Jan 4, 2021

@mfazekas tried and i got the same error, Podfile.lock have the correct version (6.3)

adjusted Podfile like this
$ReactNativeMapboxGLIOSVersion = '~> 6.3' pod 'react-native-mapbox-gl', :path => '../../', :inhibit_warnings => false

@mfazekas
Copy link
Contributor

mfazekas commented Jan 4, 2021

I guess this is coming from the upstream issue: mapbox/mapbox-gl-native-ios#558

@mfazekas mfazekas added upstream the bug source is a bug in native mapbox gl iOS iOS related tickets bug 🪲 Something isn't working labels Jan 4, 2021
@qu4sar
Copy link

qu4sar commented Jan 4, 2021

Same for me with M1 Chip :(
Tried with all the solution on this link -> https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios but nothing ...

@babeone
Copy link
Author

babeone commented Jan 4, 2021

@mfazekas so at the moment the only solution is to use a physical device, until mapbox fixes the sdk?

@babeone
Copy link
Author

babeone commented Jan 4, 2021

@mfazekas Found a workaround, just open Xcode with Rosetta. Right click on Xcode icon -> More information and check "Rosetta".

@stale
Copy link

stale bot commented Mar 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 20, 2021
@noway
Copy link

noway commented Apr 1, 2021

@Stale don't mark it as stale, this issue is a huge blocker for using RN mapbox on M1 chip. Please remove the wontfix label.

@stale stale bot removed the wontfix This will not be worked on label Apr 1, 2021
@Cucak

This comment has been minimized.

@kenjichanhkg
Copy link

so anyone got any idea? something to do with cocopod in M1, or mapbox in M1?

@noway
Copy link

noway commented Apr 10, 2021

It looks like the issue in upstream is resolved!!

mapbox/mapbox-navigation-ios#2672

Can anyone try to get it running with the latest sdk? We going to need to update the sdk dependency in react-native-mapbox-gl and release a new version.

@mfazekas
Copy link
Contributor

@noway we're using mapbox-gl-native-ios ATM. I don't think it's fixed there. It's fixed in the MapboxMaps SDK that replaces MapboxGLNativeIOS, but we're still using the MapboxGLNative libs.

@mfazekas
Copy link
Contributor

FWIW #1311 might solve this. I assume MapLibre does not have this M1 issue. Not sure if Mapbox-gl-ios has SPM distribution, in case it does it might work as well

@kenjichanhkg
Copy link

kenjichanhkg commented Apr 17, 2021

@mfazekas so is it fixed? which library / version should I use now?

@ferdicus
Copy link
Member

@kenjichanhkg, what #1311 does is adding support for MapLibre iOS SDKs which are actively maintained compared to Mapbox's "old" SDK.
You can try out MapLibre instead of Mapbox as a native dependency (instructions are in our installation guide for iOS) and report back.

The issue itself is mentioned in this ticket: maplibre/maplibre-native#4

@yasirlateef
Copy link

I was facing the same issue and tried everything. The only solution that worked for me was to run Xcode with Rosetta and it builds fine for the iOS simulator.

@noway
Copy link

noway commented Jul 27, 2021

@kenjichanhkg, what #1311 does is adding support for MapLibre iOS SDKs which are actively maintained compared to Mapbox's "old" SDK.
You can try out MapLibre instead of Mapbox as a native dependency (instructions are in our installation guide for iOS) and report back.

The issue itself is mentioned in this ticket: maplibre/maplibre-gl-native#4

Unfortunately I couldn't build rn mapbox gl with maplibre due to this issue: https://github.com/react-native-mapbox-gl/maps/issues/1472

@zbeucler2018
Copy link

I was able to find a workaround on my 2020 M1 macbook air. My solution was to open Xcode with Rosetta, and then build and run the react native project from there. This allowed me to get the demo in the README to run correctly

@noway
Copy link

noway commented Aug 5, 2021

this is not a workaround. you are just running your xcode on rosetta

@zbeucler2018
Copy link

this is not a workaround. you are just running your xcode on rosetta

My bad! I thought it constituted as a workaround because it allowed me to use the package and run my app in the iOS simulator without any errors or problems. Why would this not count as a workaround?

@noway
Copy link

noway commented Aug 5, 2021

This is an issue which you can only reproduce on Apple Silicon. If you're not using Apple Silicon but rather simulating running x86, of course the issue wouldn't be there.
It's kinda redundant to say it works on Rosetta. We can run our whole dev environments on Rosetta, but you'd be sacrificing performance and not moving forward.

@ferdicus
Copy link
Member

ferdicus commented Aug 6, 2021

@kenjichanhkg, what #1311 does is adding support for MapLibre iOS SDKs which are actively maintained compared to Mapbox's "old" SDK.
You can try out MapLibre instead of Mapbox as a native dependency (instructions are in our installation guide for iOS) and report back.
The issue itself is mentioned in this ticket: maplibre/maplibre-gl-native#4

Unfortunately I couldn't build rn mapbox gl with maplibre due to this issue: #1472

@noway , does building with MapLibre work for you now with the help of the comments in #1472 ?

@noway
Copy link

noway commented Aug 6, 2021

@kenjichanhkg, what #1311 does is adding support for MapLibre iOS SDKs which are actively maintained compared to Mapbox's "old" SDK.
You can try out MapLibre instead of Mapbox as a native dependency (instructions are in our installation guide for iOS) and report back.
The issue itself is mentioned in this ticket: maplibre/maplibre-gl-native#4

Unfortunately I couldn't build rn mapbox gl with maplibre due to this issue: #1472

@noway , does building with MapLibre work for you now with the help of the comments in #1472 ?

I've tried it out just now. It compiles and runs!! This is as furthest I've gotten so far. This is great!!

But, the map is REALLY slow. When I try to interact with the map, I get a visual response around 5 seconds later, my app consumes 100% CPU in Activity Monitor.

Screen Shot 2021-08-07 at 2 07 08 AM

The stdout is also spammed with the following:

'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)
'cyclone' is not a recognized processor for this target (ignoring processor)

To me it seems like the library doesn't turn on accelerated GPU rendering and falls back to software rendering... Not sure if that's something Mapbox even does though.

This is awesome progress, great job on getting this workaround to work!

@noway
Copy link

noway commented Aug 6, 2021

I'd say for the scope of just getting it to run, this GitHub issue is resolved. To make it usable, we can create a separate issue.

@ferdicus
Copy link
Member

ferdicus commented Aug 6, 2021

did you only try on simulator or also on device?

@noway
Copy link

noway commented Aug 7, 2021

only tried on simulator

@noway
Copy link

noway commented Aug 8, 2021

ok, tried on real device and it works too. on the real device, performance is fine btw.

@SkylerSeamans
Copy link

Running into this issue as well.

@sanatem
Copy link

sanatem commented Sep 26, 2021

Any news on this issue ? Is there any workaround ?

@ferdicus
Copy link
Member

workaround is described above - try using MapLibre 5.11.0

@doylemark
Copy link

@noway Did you ever manage to either build without maplibre or solve the performance issues in iOS simulator?

@noway
Copy link

noway commented Jan 9, 2022

@doylemark I was only able to build with maplibre. That was really slow on Simulator.

I currently have a script which rips out react-native-mapbox-gl completely out of the project for simulator builds and replaces all MapViews/ShapeSources etc to () => null components.

@minkhantlu
Copy link

Any update on this issue ?

@mfazekas
Copy link
Contributor

I don't have an M1 but I'd assume the main branch should work fine on an M1 with either MapLibre or v10 Mapbox. ($RNMapboxMapsImpl="mapbox")

Closing the issue, please open new issue if it's still relevant with the #main branch.

@okaybeydanol
Copy link

I'm having the same problem, no one has given a proper answer, I tried them all, it didn't work. Do they plan to fix this?

@rastapasta
Copy link
Contributor

@okaybeydanol try using the current version on #main together with v10 - it works very fine on M1.

@okaybeydanol
Copy link

I'm already trying the current version, but it gives the same error. When I convert it to arm64, this time libpods starts to give an error. I didn't know what to do.

@t0ma5h
Copy link

t0ma5h commented Aug 9, 2022

I've had the same problem with trying to run it on M1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working iOS iOS related tickets upstream the bug source is a bug in native mapbox gl
Projects
None yet
Development

No branches or pull requests