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

GoogleMaps don't compile at Macbook with M1 chip #355

Closed
fnazarios opened this issue Jan 11, 2021 · 143 comments
Closed

GoogleMaps don't compile at Macbook with M1 chip #355

fnazarios opened this issue Jan 11, 2021 · 143 comments
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@fnazarios
Copy link

fnazarios commented Jan 11, 2021

ld: building for iOS Simulator, but linking in object file built for iOS, file '[...]/Pods/GooglePlaces/Frameworks/GooglePlaces.framework/GooglePlaces' for architecture arm64
@fnazarios fnazarios added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 11, 2021
@saqib-saud
Copy link

In my case I'm using Cocoapods to integrate Google maps and I get the same error on M1 chip. This issue only happens with iOs 14 Simulators, working fine with iOs 13.

@mmdumi
Copy link

mmdumi commented Jan 18, 2021

I subscribe to the above. My project doesn't compile on the M1 Macs because GoogleMaps is the only dependency left that hasn't adopted the new xcframework with support for arm64 for simulator.
When can we expect a working GoogleMaps release for the M1 Macs ?

@arriolac
Copy link
Member

The Maps SDK for iOS does not yet contain the architecture necessary to run on the new Arm-based Mac Simulators—we are currently working on supporting this. For now, if you are using the new Arm-based Macs, you will need to develop using a physical device. This has been noted in our FAQ.

@pj4533
Copy link

pj4533 commented Feb 8, 2021

Any update on this?

@vince1393
Copy link

Im having this issue as well. Any update on this? Seems to be the only blocker for getting our app running on silicon

@ErikOutside
Copy link

Adding another vote to advocate for a fix to this issue. We are currently blocked from developing on M1 chipsets due to this issue.

@arriolac arriolac added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed triage me I really want to be triaged. labels Feb 18, 2021
@arriolac
Copy link
Member

Hey everyone, unfortunately I can't share any timelines on when this issue will be addressed since there are a lot of moving parts to supporting an .xcframework that contains the new arm simulator architecture. This is a very high priority for us though. The only workaround at the moment is to develop on a physical device if you are using one of the new Macbooks.

@pj4533
Copy link

pj4533 commented Feb 18, 2021

I appreciate that, but even if you just had an alpha branch that would compile (and just wasn't a full release), that would at least get our CI MacMini machine unblocked.

@ErikOutside
Copy link

Thanks @arriolac for the transparency. Please keep us updated as you get a sense of timelines

@BrentMifsud
Copy link

Would supporting SPM solve the problem?

We have had lots of issues with pods on Apple silicon.

@arriolac
Copy link
Member

Would supporting SPM solve the problem?

We have had lots of issues with pods on Apple silicon.

That wouldn't solve the problem. Even if you manually assemble an .xcframework from the current version of the SDK using lipo you will still get compile errors since the arm architecture for the simulator is missing.

Once that new architecture is supported in a subsequent version of the Maps and Places SDKs though (and the only way to do so is to create an .xcframework), then it would make sense to also add SPM support.

@FabrizioBrancati
Copy link

I found a similar solution for a third-party framework that we had on our app, by using the following Bogo's guide and by manually creating an XCFramework instead of using xcodebuild.

I don't know if it works for your framework because our third-party framework only supported iOS, but this is the guide:

Let's start with what we had:

  1. Simulator framework (i386 and x86_64 architectures) - Inside an iOS folder
  2. iOS framework (armv7 and arm64 architectures) - Inside a Sim folder

So, by following the guide, we should change the Mach-O header to let it run on the arm64 for Simulator. If we try to just change it on the arm64 for iOS, while building the XCFramework by using xcodebuild we will get the binaries with multiple platforms are not supported.
An XCFramework is just a folder with inside a couple of folders (one for Simulator and one for iOS) and its plist.

The first step is removing the armv7 architecture inside the iOS executable. We can do the following by using lipo:
lipo -remove armv7 iOS/SDK.framework/SDK -output SDK
Next, convert the remaining arm64 architecture from LC_VERSION_MIN_IPHONEOS to IOSSIMULATOR:

xcrun vtool -arch arm64 \                             
-set-build-version 7 13.4 13.4 \
-replace \
-output iOS/SDK.framework/SDK.reworked \
iOS/SDK.framework/SDK

Delete the old SDK executable and replace it with the SDK.reworked one.

Now that we have the Simulator arm64 architecture, we should merge it with the other Simulator ones: i386 and x86_64:
lipo -create iOS/SDK.framework/SDK Sim/SDK.framework/SDK -output SDK
Replace the Sim/SDK.framework/SDK with the newly fat one.
Delete the iOS/SDK.framework/SDK without the armv7 architecture and get back the original one.

The final step is to manually create the XCFramework:

  1. Create a folder named SDK.xcframework
  2. Enter into that folder and create a couple of folders: ios-arm64_armv7 and ios-arm64_i386_x86_64-simulator
  3. Now copy-paste the framework inside the iOS folder into the ios-arm64_armv7 folder and the framework inside the Sim folder into the ios-arm64_i386_x86_64-simulator
  4. Create the Info.plist file: touch Info.plist
  5. Paste the following code inside the Info.plist file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>AvailableLibraries</key>
    	<array>
    		<dict>
    			<key>LibraryIdentifier</key>
    			<string>ios-arm64_armv7</string>
    			<key>LibraryPath</key>
    			<string>SDK.framework</string>
    			<key>SupportedArchitectures</key>
    			<array>
    				<string>arm64</string>
    				<string>armv7</string>
    			</array>
    			<key>SupportedPlatform</key>
    			<string>ios</string>
    		</dict>
    		<dict>
    			<key>LibraryIdentifier</key>
    			<string>ios-arm64_i386_x86_64-simulator</string>
    			<key>LibraryPath</key>
    			<string>SDK.framework</string>
    			<key>SupportedArchitectures</key>
    			<array>
    				<string>arm64</string>
    				<string>i386</string>
    				<string>x86_64</string>
    			</array>
    			<key>SupportedPlatform</key>
    			<string>ios</string>
    			<key>SupportedPlatformVariant</key>
    			<string>simulator</string>
    		</dict>
    	</array>
    	<key>CFBundlePackageType</key>
    	<string>XFWK</string>
    	<key>XCFrameworkFormatVersion</key>
    	<string>1.0</string>
    </dict>
    </plist>
    

Now you can use this XCFramework on both an iOS device and a Simulator on a Mac ARM 🎉

@allending
Copy link

@FabrizioBrancati you should note that the steps do not work for this framework.

@FabrizioBrancati
Copy link

FabrizioBrancati commented Mar 3, 2021

@FabrizioBrancati you should note that the steps do not work for this framework.

After writing this guide I tried with the GoogleMaps framework, but it is composed of 3 frameworks:

  1. GoogleMaps
  2. GoogleMapsBase
  3. GoogleMapsCore

The first one works by using the above method, for the other two don't work because they have negative available space.
I'm looking at how to add some empty space...

@allending
Copy link

@FabrizioBrancati I have run into the exact same issues. Unfortunately, I don't think this approach will work because there is simply no padding available in the header for the Base and Core frameworks.

@lluisgerard
Copy link

I just got an M1 machine and I could make it work by opening Xcode using Rosetta. It works against an iOS 14.4 simulator and Google Maps appear on the app correctly.
(Just posting it here, it wasn't clear this was the workaround for now when reading other comments).

@pj4533
Copy link

pj4533 commented Mar 11, 2021

I just got an M1 machine and I could make it work by opening Xcode using Rosetta. It works against an iOS 14.4 simulator and Google Maps appear on the app correctly.
(Just posting it here, it wasn't clear this was the workaround for now when reading other comments).

Yeah this is a workaround for general day to day work. However, our CI machine is a M1 MacMini, and I couldn't figure out how to get an Xcode bot to launch with Rosetta. Anyone have a trick for that?

@MujtabaFR
Copy link

MujtabaFR commented Mar 17, 2021

Running Xcode under Rossetta fixed the issue as a temporary workaround

1 - With Xcode closed (Important) Go to finder -> Applications
2 - Right Click on Xcode and select "Get Info"
3 - On the info panel check "Open using Rosetta"
4 - Double Click in the bottom large preview of the info panel.

** This will cause a decrease in speed and performance in Xcode and simulator

@ebellumat
Copy link

Can anyone explain, why this error appears on Mac OS with M1 chip if the iPhone is ARM too? For me, no makes sense build works fine for one ARM device and the other don't. GooglePlaces still in ARM 32bit?

@ebellumat
Copy link

Funny story: The Build Works if i choose to build on Mac.

image

@BrentMifsud
Copy link

BrentMifsud commented May 5, 2021

Funny story: The Build Works if i choose to build on Mac.

image

I think this is because it's not using a simulator. The m1 macs use the same architecture as an iPhone/iPad, whereas the simulator on M1 is a different architecture than the simulator on an Intel mac.

@ebellumat
Copy link

The build on iOS simulator and the build on the Mac, both is running on M1.

@LilaQ
Copy link

LilaQ commented May 7, 2021

Please, for the love of god, is there any update to this? It shouldn't take half a year to support arm64 arch.

@bogo
Copy link

bogo commented May 9, 2021

@FabrizioBrancati you should note that the steps do not work for this framework.

I was helping @mikina set up a project depending on Google Maps today and ran vtool without issues on all Google Maps SDK 3.1.0 and 4.2.0 constituent frameworks. After wrapping up individual frameworks in XCFrameworks, Xcode had no issues producing a functional Simulator build that depends on the Google Maps SDK.

I used the following vtool invocation:
vtool -arch arm64 -set-build-version 7 13.0 13.0 -replace -output $OBJECT_FILE_PATH $OBJECT_FILE_PATH

And here's a screenshot of running Google Maps SDK:

Screen Shot 2021-05-09 at 01 37 34

@arriolac
Copy link
Member

@shalinipk thanks for reporting these issues.

Since version 5.2.0, you should be able to opt-in to use the Metal rendering framework instead of OpenGLES. Currently using Metal is opt-in but this will be the default in a future version.

GMSServices.setMetalRendererEnabled(true)

As far as the crash that you linked, can you report that issue on the public issue tracker along with some repro steps? Thanks!

@dcacenabes
Copy link

@shalinipk thanks for reporting these issues.

Since version 5.2.0, you should be able to opt-in to use the Metal rendering framework instead of OpenGLES. Currently using Metal is opt-in but this will be the default in a future version.

GMSServices.setMetalRendererEnabled(true)

As far as the crash that you linked, can you report that issue on the public issue tracker along with some repro steps? Thanks!

In case you want to give a try to using Metal as the rendering framework, please be aware that it crashes in the iOS simulator!
https://issuetracker.google.com/issues/208593323
In phones it is working properly

@codeisjoy
Copy link

I still get a crash when trying to present street view for a given coordinate:

Google Maps SDK for iOS (M4B) version: 6.0.0.0
-[GMSx_GPSPhotoMetadata photoAnnotationArray]: unrecognized selector sent to instance 0x600000fe7840
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GMSx_GPSPhotoMetadata photoAnnotationArray]: unrecognized selector sent to instance 0x600000fe7840'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000011debdbb4 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x0000000118105be7 objc_exception_throw + 48
	2   CoreFoundation                      0x000000011decc821 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   CoreFoundation                      0x000000011dec20bc ___forwarding___ + 1433
	4   CoreFoundation                      0x000000011dec41e8 _CF_forwarding_prep_0 + 120

@drewcrawford
Copy link

Probably missing “-ObjC” in link flags.

@codeisjoy
Copy link

Nope.

@arriolac
Copy link
Member

arriolac commented Jan 4, 2022

@codeisjoy that issue should be addressed in version 6.0.1 (looks like you are still on 6.0.0). Give that a try instead.

@shalinipk
Copy link

shalinipk commented Jan 4, 2022

@shalinipk thanks for reporting these issues.

Since version 5.2.0, you should be able to opt-in to use the Metal rendering framework instead of OpenGLES. Currently using Metal is opt-in but this will be the default in a future version.

GMSServices.setMetalRendererEnabled(true)

As far as the crash that you linked, can you report that issue on the public issue tracker along with some repro steps? Thanks!

@shalinipk thanks for reporting these issues.
Since version 5.2.0, you should be able to opt-in to use the Metal rendering framework instead of OpenGLES. Currently using Metal is opt-in but this will be the default in a future version.

GMSServices.setMetalRendererEnabled(true)

As far as the crash that you linked, can you report that issue on the public issue tracker along with some repro steps? Thanks!

In case you want to give a try to using Metal as the rendering framework, please be aware that it crashes in the iOS simulator! https://issuetracker.google.com/issues/208593323 In phones it is working properly

Thanks @arriolac @dcacenabes This is useful info. In case apple decides to pull the plug on OpenGLES, now I know what to do :)

I will try to submit an issue sometime this week, also try getting rid of OpenGLES

@codeisjoy
Copy link

@codeisjoy that issue should be addressed in version 6.0.1 (looks like you are still on 6.0.0). Give that a try instead.

I confirm the issue is resolved on 6.0.1.

@dyegos
Copy link

dyegos commented Jan 18, 2022

Hello, I tried running the new SDK version 6.0.1, but I still get the error
building for iOS Simulator, but linking in object file built for iOS, file '/Path/Pods/GooglePlaces/Frameworks/GooglePlaces.framework/GooglePlaces' for architecture arm64

I am using Xcode 13.2.1, iOS 13.6 and M1 MacBook

Am I doing anything wrong?

@cristibaluta
Copy link

cristibaluta commented Jan 27, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?

building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64

Using the latest versions:
Installing GoogleMaps 6.0.1 (was 4.2.0)
Installing GooglePlaces 6.0.0 (was 4.2.0)

@shalinipk
Copy link

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?

building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64

Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

Opening XCode using Rosetta seems to resolve it for me - for now.

@mime29
Copy link

mime29 commented Jan 28, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?
building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

Opening XCode using Rosetta seems to resolve it for me - for now.

Solving this means being able to build on M1 without Rosetta.
Apparently the archive 6.0.1-beta supports M1 but beta means not ready for production.

@maclne
Copy link

maclne commented Jan 28, 2022

Confirmed I can only build with Rosetta. Not perfect, but definitely an improvement!

@erf
Copy link

erf commented Jan 28, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?

building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64

Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

I'm able to run to run GoogleMaps on my M1 on a simulator. Did you try to remove and re-install the CocoaPods the arm64? Maybe this answer might help.

@maclne
Copy link

maclne commented Jan 28, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?
building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

I'm able to run to run GoogleMaps on my M1 on a simulator. Did you try to remove and re-install the CocoaPods the arm64? Maybe this answer might help.

And you're sure you're not running Xcode with Rosetta? I tried the solutions at the link you shared and can still only build with Rosetta (which to me isn't the end of the world).

@erf
Copy link

erf commented Jan 28, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?
building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

I'm able to run to run GoogleMaps on my M1 on a simulator. Did you try to remove and re-install the CocoaPods the arm64? Maybe this answer might help.

And you're sure you're not running Xcode with Rosetta? I tried the solutions at the link you shared and can still only build with Rosetta (which to me isn't the end of the world).

I run from a native terminal (not rosetta). Did you install the pods from scratch? I tried it now and it worked, i just had to do a manual pod install inside the ios folder.

@maclne
Copy link

maclne commented Jan 28, 2022

How was this closed? It is definitely not working on my M1 Pro on simulator, seems there's a difference between arm64 for phone and for simulator?
building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
Using the latest versions: Installing GoogleMaps 6.0.1 (was 4.2.0) Installing GooglePlaces 6.0.0 (was 4.2.0)

I'm able to run to run GoogleMaps on my M1 on a simulator. Did you try to remove and re-install the CocoaPods the arm64? Maybe this answer might help.

And you're sure you're not running Xcode with Rosetta? I tried the solutions at the link you shared and can still only build with Rosetta (which to me isn't the end of the world).

I run from a native terminal (not rosetta). Did you install the pods from scratch? I tried it now and it worked, i just had to do a manual pod install inside the ios folder.

I tried:
pod deintegrate
pod cache clean --all
pod install
Cleared my build folder and rebuilt.

No luck with non-rosetta. But I'm content with running in Rosetta. I'm just pumped to be able to use the simulator again.

@erf
Copy link

erf commented Jan 28, 2022

I did the following:
Deleted Pods folder and Podfile.lock
flutter pub get
pod install
flutter run

Maybe you need to check that the rest of the toolchain is arm64 like Cocoapods, RubyGems etc. Not sure how all this works .. but if you are fine running on Rosetta 👍

@cristibaluta
Copy link

I actually managed to run it once in an empty project, but don't know what i did. As soon as i started to add more pods everything broke. The problem i'm seeing is that Pods_projectname.framework is not generated on M1

@nick3389
Copy link

Any news regarding running in XCode WITHOUT Rosetta???? I confirm that it runs only on Rosetta in XCode.

@cristibaluta
Copy link

I read more carefully the docs and it says that you need to add the .xcframework manually, using the pod will not work because it uses .framework
Didn't test it, since my project's git is limited to certain file sizes, and i wouldn't include the lib even if i was not limited.

@ccynn
Copy link

ccynn commented Feb 13, 2022

Any news regarding running in XCode WITHOUT Rosetta???? I confirm that it runs only on Rosetta in XCode.

also facing the same issue still. 🥲

@karatekid430
Copy link

I read more carefully the docs and it says that you need to add the .xcframework manually, using the pod will not work because it uses .framework Didn't test it, since my project's git is limited to certain file sizes, and i wouldn't include the lib even if i was not limited.

Can you please elaborate on how to do this? I have patched react-native-maps to use 6.0.1 but it is still not using xcframework. Thanks. :)

@magnett
Copy link

magnett commented Feb 14, 2022

Any news regarding running in XCode WITHOUT Rosetta???? I confirm that it runs only on Rosetta in XCode.

I did have the same issue using CocoaPods and I followed Google's suggestion to visit this StackOverflow thread. What resolved it for me was:
"Navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture."

@martinkrasnocka
Copy link

Can you please elaborate on how to do this? I have patched react-native-maps to use 6.0.1 but it is still not using xcframework. Thanks. :)

Here it is: https://developers.google.com/maps/documentation/ios-sdk/config
But to save you from another disappointment, it doesn't work well. I was able to compile it and run it under M1 without Rosetta, but the actual performance of google map in the simulator was utter garbage, like 1 frame per second. When I tried to switch it to metal renderer, it crashed immediately after launch. After all, this approach is marked as beta.
Use Rosetta and be happy while it's available. Sooner or later Apple will ditch it.

@mkurtipek
Copy link

This solved my issue react-native-maps/react-native-maps#3527 (comment)

@DagAgren
Copy link

DagAgren commented Mar 4, 2022

What an absolute clown show by Google.

The issue everyone is having is that Google did not actually put the fix into the CocoaPods release. You have to stop using CocoaPods and include the .xcframework manually.

@arriolac
Copy link
Member

arriolac commented Mar 7, 2022

Hi folks, it looks like there's some confusion on the status of M1 mac support for the Maps SDK. I want to clarify that here.

Getting the SDK to work on emulators on an M1 Mac

As of version 6.0.1 of the Maps SDK for iOS, the only way to get the SDK to compile and work on the iOS emulator, without using Rosetta, is to install the XCFramework version (i.e. 6.0.1-beta) of the SDK. You can install this either manually, or by using Carthage. For further instructions, see Install the XCFramework.

What about CocoaPods?

As of version 6.0.1, the version of the SDK available on CocoaPods does not support XCFrameworks. So, if you try to use CocoaPods, you will receive the same linking error. Note that there are workarounds (like Rosetta and deploying only to a device instead of an emulator) you can use that other folks have indicated here. Unfortunately, I do not have a timeline to share on when the CocoaPods distribution will support XCFrameworks.

Further issues?

If you have any further issues related to the Maps SDK for iOS, please view or open a new issue in the issue tracker for the Maps SDK for iOS. Otherwise, if you have an issue with the Maps SDK for iOS Utility Library, open an issue in this repository.

I'm going to lock this conversation so this message is visible to others when they land here.

@googlemaps googlemaps locked as resolved and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests