GoogleMaps-SP icon indicating copy to clipboard operation
GoogleMaps-SP copied to clipboard

Add support for Apple Silicon (arm64) to iOS Simulator builds

Open karimhm opened this issue 3 years ago • 26 comments

karimhm avatar Jan 03 '22 10:01 karimhm

I have the same issue. Has anyone found a workaround?

sdnsepehr avatar Mar 23 '22 10:03 sdnsepehr

@sdnsepehr

Rosetta

Try running Xcode with Rosetta enabled

karimhm avatar Mar 23 '22 13:03 karimhm

Is there a way to change the settings to build for arm_64 simulator?

Fahrenberg avatar Oct 15 '22 06:10 Fahrenberg

Is there a way to change the settings to build for arm_64 simulator?

Not if you link any binary that does not have an ARM64 slice for the simulator.

karimhm avatar Oct 15 '22 07:10 karimhm

Google provides two versions of the SDK now:

  • v7.1.0 in form of legacy fat frameworks (without support for ARM64-simulator)
  • v7.1.0-beta in form of XCFrameworks (with ARM64-simulator support)

There are two problems:

  • This project is using v7.1.0 (so, no ARM64-simulator support)
  • v7.1.0-beta does have ARM64-simulator support, but for some reason can't be used as a Swift Package dependency (it builds but app fails to start)

Here is my (experimental) solution: https://github.com/darrarski/GoogleMaps-SP

It can be used as a dependency of Swift Package and provides ARM64-simulator support (without running through Rosetta).

Enjoy, I hope it helps :-)

darrarski avatar Oct 17 '22 18:10 darrarski

Google provides two versions of the SDK now:

  • v7.1.0 in form of legacy fat frameworks (without support for ARM64-simulator)
  • v7.1.0-beta in form of XCFrameworks (with ARM64-simulator support)

There are two problems:

  • This project is using v7.1.0 (so, no ARM64-simulator support)
  • v7.1.0-beta does have ARM64-simulator support, but for some reason can't be used as a Swift Package dependency (it builds but app fails to start)

Here is my (experimental) solution: https://github.com/darrarski/GoogleMaps-SP

It can be used as a dependency of Swift Package and provides ARM64-simulator support (without running through Rosetta).

Enjoy, I hope it helps :-)

The problems with Google's XCFrameworks are:

  • They don't contain an Info.plist file.
  • They binary inside is a static library rather than a dynamic library.

karimhm avatar Oct 17 '22 19:10 karimhm

The problems with Google's XCFrameworks are:

  • They don't contain an Info.plist file.

  • They binary inside is a static library rather than a dynamic library.

That's true. I think there's no other way around than to use them if we need ARM64 simulator support at the moment.

My approach is to rebuild the XCFrameworks using (slightly modified) script from this repo and thin frameworks contained inside Google's official XCFrameworks. A bit hacky, but works for me (in simulator on M1 and on a physical device).

Hopefully Google will fix their frameworks, so we can use them directly.

darrarski avatar Oct 17 '22 20:10 darrarski

The problems with Google's XCFrameworks are:

  • They don't contain an Info.plist file.
  • They binary inside is a static library rather than a dynamic library.

That's true. I think there's no other way around than to use them if we need ARM64 simulator support at the moment.

My approach is to rebuild the XCFrameworks using (slightly modified) script from this repo and thin frameworks contained inside Google's official XCFrameworks. A bit hacky, but works for me (in simulator on M1 and on a physical device).

Hopefully Google will fix their frameworks, so we can use them directly.

I tried embedding Google's XCFrameworks inside this repo XCFrameworks and it was a success, one problem was The framework name need to be different than Google's framework names to prevent linking collisions i.e renaming GoogleMaps.framework to GoogleMaps_.framework (either Google's one or this repo one).

karimhm avatar Oct 17 '22 20:10 karimhm

I tried embedding Google's _XCFramework_s inside this repo _XCFrameworks and it was a success, one problem was The framework name need to be different than Google's framework names to prevent linking collisions i.e renaming GoogleMaps.framework to **GoogleMaps.framework** (either Google's one or this repo one).

Not sure I understand the name collision issue. You can store GoogleMaps.framework for the device and GoogleMaps.framework for the simulator in separate directories... or just use GoogleMaps.xcframework from Google, which contains both (as I did).

darrarski avatar Oct 18 '22 08:10 darrarski

@darrarski Thank you so much for sharing the code! I've been trying to reverse engineer the whole process (creation of Xcode projects, setting up dependencies). Could you please share how you setup linking between GoogleMaps & GoogleMapsBase & GoogleMapsCore? I'm now stuck at Undefined symbols for architecture arm64 😕

rbsgn avatar Oct 20 '22 18:10 rbsgn

I didn't do anything special here. Started by forking this repository and duplicating the Xcode project to have two of them. One is using ".framework" files for physical devices and second for simulators. I've got these frameworks from official XCFramework file downloaded from Google (ver. 7.1.0-beta). That's it.

darrarski avatar Oct 20 '22 18:10 darrarski

Thank you! I’ll try the same!

rbsgn avatar Oct 20 '22 19:10 rbsgn

@karimhm perhaps you can shed some light on dependencies setup?

rbsgn avatar Oct 20 '22 19:10 rbsgn

@karimhm perhaps you can shed some light on dependencies setup?

What are you trying to achieve?

karimhm avatar Oct 20 '22 19:10 karimhm

I would like to know how GoogleMaps.xcodeproj is created. This'll help me re-create it by myself so that I know how to update it in a future.

As far as I can see you:

  • started with empty project
  • created 5 library targets
  • added GoogleMaps, GoogleMapsBase etc. folders with "create groups" option enabled
  • made headers public and setup resource bundle copying
  • did not yet known to me linking setup

rbsgn avatar Oct 20 '22 21:10 rbsgn

@karimhm Zipped xcarchives produced by ./make_xcframework.sh -x are unusually small. Binaries from Google's framework are stripped.

rbsgn avatar Oct 21 '22 07:10 rbsgn

I figured out how to re-create GoogleMaps.xcodeproj from ground up 🎉 Thank you, @karimhm, for working reference!

rbsgn avatar Oct 21 '22 14:10 rbsgn

Any news on this? Building for arm64 still gives errors even with 7.2.0 version.

marcocadei avatar Jan 11 '23 22:01 marcocadei

Is there an update on this? Xcode 14.3's release notes clearly state that it doesn't support Rosetta anymore. Updating this repo to support the latest version of Maps would be incredible 🙌

bsrz avatar Feb 21 '23 05:02 bsrz

Is there an update on this? Xcode 14.3's release notes clearly state that it doesn't support Rosetta anymore. Updating this repo to support the latest version of Maps would be incredible 🙌

That's really a Google question. I don't get why it takes them so long to update one of their most used libraries...

theedov avatar Apr 13 '23 01:04 theedov

fwiw, I found this one https://github.com/gomore/GoogleMaps-SPM which has 7.3.0

bsrz avatar Apr 13 '23 03:04 bsrz

@bsrz did you manage to get that one working? It claims to be working with M1, but even on a fresh project I get errors.

svachmic avatar Jun 16 '23 19:06 svachmic

@svachmic yes, it's working for us, we're all on M1 and our CI machines are on Intel, everything works.

bsrz avatar Jun 16 '23 20:06 bsrz

Thanks @bsrz for a quick reply!

I don't know what I'm doing wrong - I add it to my project simply by adding another SwiftPM dependency using Xcode's UI, I select all the packages (GoogleMaps, GoogleMapsCore and the third one that escapes me now), the code compiles but when I want to run it in the simulator or on an iPhone, I get an error that an Info.plist is missing in the GoogleMaps package.

Am I missing a step? Am I supposed to run the shell script in the repo or add some build phase? I am seeing this same behavior both in my project which used to have Google Maps installed via cocoapods and in a fresh new Xcode project.

svachmic avatar Jun 16 '23 21:06 svachmic

@svachmic We're not using Xcode's UI for this, I'm using it in a local package for modularization. We don't have any build phases for this either.

We're supporting iOS 14+ not sure if this has an impact for you?

bsrz avatar Jun 19 '23 15:06 bsrz

@bsrz thanks for your env description. It was actually more trivial than that. The newest version (8.0.0) is simply buggy. When I used the version below (7.3.0) it works just fine.

svachmic avatar Jun 19 '23 18:06 svachmic