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

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

Open
karimhm opened this issue Jan 3, 2022 · 26 comments
Open

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

karimhm opened this issue Jan 3, 2022 · 26 comments
Assignees

Comments

@karimhm
Copy link
Contributor

karimhm commented Jan 3, 2022

No description provided.

@sdnsepehr
Copy link

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

@karimhm
Copy link
Contributor Author

karimhm commented Mar 23, 2022

@sdnsepehr

Rosetta

Try running Xcode with Rosetta enabled

@Fahrenberg
Copy link

Fahrenberg commented Oct 15, 2022

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

@karimhm
Copy link
Contributor Author

karimhm commented Oct 15, 2022

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.

@darrarski
Copy link

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 :-)

@karimhm
Copy link
Contributor Author

karimhm commented Oct 17, 2022

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.

@darrarski
Copy link

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.

@karimhm
Copy link
Contributor Author

karimhm commented Oct 17, 2022

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).

@darrarski
Copy link

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).

@rbsgn
Copy link

rbsgn commented Oct 20, 2022

@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 😕

@darrarski
Copy link

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.

@rbsgn
Copy link

rbsgn commented Oct 20, 2022

Thank you! I’ll try the same!

@rbsgn
Copy link

rbsgn commented Oct 20, 2022

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

@karimhm
Copy link
Contributor Author

karimhm commented Oct 20, 2022

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

What are you trying to achieve?

@rbsgn
Copy link

rbsgn commented Oct 20, 2022

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
Copy link

rbsgn commented Oct 21, 2022

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

@rbsgn
Copy link

rbsgn commented Oct 21, 2022

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

@marcocadei
Copy link

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

@bsrz
Copy link

bsrz commented Feb 21, 2023

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 🙌

@theedov
Copy link

theedov commented Apr 13, 2023

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...

@bsrz
Copy link

bsrz commented Apr 13, 2023

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

@svachmic
Copy link

@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.

@bsrz
Copy link

bsrz commented Jun 16, 2023

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

@svachmic
Copy link

svachmic commented Jun 16, 2023

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.

@bsrz
Copy link

bsrz commented Jun 19, 2023

@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?

@svachmic
Copy link

@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.

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

No branches or pull requests

9 participants