[google_maps_flutter] Convert top-level classes to Swift in _sdk* packages - #12307
[google_maps_flutter] Convert top-level classes to Swift in _sdk* packages#12307stuartmorgan-g wants to merge 19 commits into
_sdk* packages#12307Conversation
There was a problem hiding this comment.
Code Review
This pull request converts parts of the iOS Google Maps implementation to Swift across the SDK 9, SDK 10, and shared code packages, replacing several Objective-C controllers and plugins. The build configurations, synchronization tools, and tests are updated to support the new Swift files. Feedback on these changes includes correcting a regular expression typo in the utility script, addressing typos in documentation and comments, avoiding unsafe force-unwrapping and force-casting in the map factory, and resolving an inconsistency in how uninitialized map views are handled.
|
We'll want to hold off on landing this until 3.47 reaches stable, since that's when nobody on stable will have an actual need to keep using @vashworth per offline discussion, this punts on the question of whether we switch the endorsed implementation to For review, it may be helpful to look at some of the individual commits. 5a27e87 in particular, which is where I reworked the initialization. |
| #expect(mapView.frameObserverCount == 0) | ||
| } | ||
|
|
||
| @Test func mapsServiceSync() { |
There was a problem hiding this comment.
This is removed because in the Swift version, all the custom logic for calling this exactly once was replaced by us being able to use Swift's lazy static handling, and since that's a core language behavior rather than custom logic, there's no value in testing it.
| ) | ||
| } | ||
|
|
||
| @Test func frameObserverRemovedOnDeinitIfNeverFired() { |
There was a problem hiding this comment.
Added to cover an issue found by Gemini in local review of the conversion.
| #expect(mapView.frameObserverCount == 0) | ||
| } | ||
|
|
||
| @Test func styleErrorPersistsAcrossConfigUpdates() { |
There was a problem hiding this comment.
Added to cover a case I accidentally regressed when reworking init, also found by Gemini in a local review.
This converts GoogleMapsPlugin, GoogleMapFactory, and GoogleMapController to Swift, and restructures the source code to typical migration state of having the Swift code be the primary target, depending on a new
*_objctarget that contains the unmigrated code. Becausegoogle_maps_flutter_ioscannot adopt Swift (see discussion in linked issue), this removes that package from the code sharing. Going forward, development will be limited to the_sdk*packages.For reasons explained here, the Pigeon API layer is still Objective-C for now, which does lead to some temporary non-ideal code in GoogleMapController. That will be cleaned up in the last step when we are able to switch to Swift Pigeon generation.
The remaining Obj-C code will be migrated in a series of follow-up PRs to keep the scope of each PR reasonable for review.
The conversion process was:
The last step was more extensive than usual because the init method had longstanding design issues (flutter/flutter#104121) that became hard errors under Swift. There was some refactoring of helper methods and reordering of initialization steps to make the code work with the strict two-phase init process.
Part of flutter/flutter#119108
Fixes flutter/flutter#104121
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2