liveview-native / liveview-client-swiftui

MIT License
376 stars 37 forks source link

Fired up Mapkit on Xcode 15, and get a compile error #1106

Closed AZholtkevych closed 1 year ago

AZholtkevych commented 1 year ago

/Users/dbii/Library/Developer/Xcode/DerivedData/MBSQuoteline-fpnocmrhpgeuuwhdzxpmspvyaaho/SourcePackages/checkouts/liveview-native-swiftui-mapkit/Sources/LiveViewNativeMapKit/MapContent/Marker.swift:87:44 Cannot convert value of type 'String' to expected argument type 'Text' I checked MapKit and that appears to need to be a String, but in _MapKit_SwiftUI (whatever that is) it has it as Text /// - Parameters: /// - titleKey: The localized string key to lookup the title under. /// - monogram: Up to three characters to display on the marker's balloon. /// - coordinate: The coordinate to display the marker at. public init(_ titleKey: LocalizedStringKey, monogram: Text, coordinate: CLLocationCoordinate2D) where Label == Label<Text, Text>

/// Creates a marker at the given location with a monogram displayed as the
/// balloon's icon.
///
/// - Parameters:
///   - title: The title of the marker.
///   - monogram: Up to three characters to display on the marker's balloon.
///   - coordinate: The coordinate to display the marker at.
public init<S>(_ title: S, monogram: Text, coordinate: CLLocationCoordinate2D) where Label == Label<Text, Text>, S : StringProtocol

Screenshot 2023-08-16 at 8.43.48 PM.png

AZholtkevych commented 1 year ago

FYI @carson-katri @bcardarella

AZholtkevych commented 1 year ago

SLACK THREAD: https://dockyard.slack.com/archives/C02E1GA5THB/p1692236831728369

Carson Katri 7 hours ago Probably needs some updates for newer betas

David Bluestein II 13 minutes ago I see the problem, but not how to fix it. In Sources/LiveViewNativeMapKit/MapContent/Marker.swift there is: /// Use the value as a monogram instead of the default pin icon. @_documentation(visibility: public) let monogram: String? which is used at var body: some MapContent { if let monogram { MapKit.Marker(title, monogram: monogram, coordinate: coordinate) } else if let image { but the Apple docs now have two options which are identical except one has monogram as String (like above) and one as Text (hence the error Cannot convert value of type 'String' to expected argument type 'Text') init(LocalizedStringKey, monogram: String, coordinate: CLLocationCoordinate2D) Creates a marker at the given location with the provided localized title and a monogram the map displays as the balloon's icon. init(LocalizedStringKey, image: String, coordinate: CLLocationCoordinate2D) ... init(LocalizedStringKey, monogram: Text, coordinate: CLLocationCoordinate2D) Creates a marker at the given location with the provided title key and monogram. I would think if we had a String it would just call the first method. I can try to change Marker.swift to have it as Text and see if that works. Or maybe the shim code that links into MapKit only has the Text version (which my prior comment should fix). Or if you have another suggestion I can put it in and test it.

Carson Katri 9 minutes ago If passing in a Text type works, then we can go with that. The API could be extended to accept Text elements with template={...} so you can use text modifiers like foreground_style or bold (if Marker renders those).

carson-katri commented 1 year ago

This issue should be on the MapKit addon registry's repo.