I'm having some issues with the GoogleMaps SDK in SwiftUI.
I manually installed the SDK, because cocoa pods don't work on my Mac.
But now I have building issues:
Showing Recent Messages
Ignoring file /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMapsCore.framework/GoogleMapsCore, file is universal (arm64) but does not contain the x86_64 architecture: /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMapsCore.framework/GoogleMapsCore
Ignoring file /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMapsBase.framework/GoogleMapsBase, file is universal (arm64) but does not contain the x86_64 architecture: /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMapsBase.framework/GoogleMapsBase
Ignoring file /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMaps.framework/GoogleMaps, file is universal (arm64) but does not contain the x86_64 architecture: /Users/f4mdev/AndroidStudioProjects/fabTraceability/iosApp/iosApp/GoogleMaps.framework/GoogleMaps
Undefined symbol: _OBJC_CLASS_$_GMSCameraPosition
Undefined symbol: _OBJC_CLASS_$_GMSMapView
Undefined symbol: _OBJC_CLASS_$_GMSServices
This is my Code I tried:
import UIKit
import GoogleMaps
import SwiftUI
struct GoogleMapsView: UIViewRepresentable {
private let zoom: Float = 15.0
func makeUIView(context: Self.Context) -> GMSMapView {
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
return mapView
}
And here are the "OTHER LINKER FLAGS"
Google Maps package doesn't support Apple Silicon. Running the app on an actual device or running xcode in rosetta should work.
Related
I was attempting to test an app on the Xcode 11 simulator that used CoreLocation. I wanted to use the "Freeway Drive" location option in the simulator under Debug > Location to test the MapKit polyline overlay.
Unfortunately, no line was placed on the map and "Compiler error: Invalid library file" was printed numerous times in the log.
It does not seem to be a code problem but more of an Xcode problem. Is there any way around this? It is very difficult to test with a physical device because movement in a confined space doesn't really pick up with CoreLocation.
Thanks!
just define the polyline and "push" it into your mapView:
let polyline = MKPolyline(coordinates: locations, count: locations.count)
mapView.addOverlays([polyline])
and declare the mkMapViewDelegate's function:
//MKMapViewDelegate
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) ->
MKOverlayRenderer
{
if let mapPolyline = overlay as? MKPolyline {
let polyLineRenderer = MKPolylineRenderer(polyline: mapPolyline)
polyLineRenderer.strokeColor = .darkGray
polyLineRenderer.lineWidth = 4.0
return polyLineRenderer
}
fatalError("Polyline Renderer could not be initialized" )
}
It should show the polyline on the mapView.
I have the compiler error too and try to fix it.
Best
Dragan
I'm trying to have toggle with native style for iOS (switch) and macOS (checkbox) in my universal app. This code does not work:
#if targetEnvironment(macCatalyst)
private let toggleStyle = CheckboxToggleStyle()
#else
private let toggleStyle = SwitchToggleStyle()
#endif
'CheckboxToggleStyle' is unavailable in iOS
Was thinking that macros should compile correct path for each target.
CheckboxToggleStyle is for macOS only... see below API declaration. macCatalyst is actually environment simulating iOS on macOS, but from API perspective it is iOS
/// A `ToggleStyle` represented by a leading checkbox.
#available(OSX 10.15, *)
#available(iOS, unavailable)
#available(tvOS, unavailable)
#available(watchOS, unavailable)
public struct CheckboxToggleStyle : ToggleStyle {
The following piece of code returns false on iPhone XR even-though it person segmentation is working on XR.
ARConfiguration.supportsFrameSemantics(.personSegmentation)
I want to know if it does officially supports person segmentation and person segmentation with depth on XR. Just to point out I have got iOS 13.1.2 on the XR.
Try this variation:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let config = ARWorldTrackingConfiguration()
if ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) {
config.frameSemantics = .personSegmentationWithDepth
}
arView.session.run(config)
}
And make sure that your Xcode version is 11.2.1 and iOS version is 13.2.3.
Unable to add more than three UILabels to a UIViewController’s view in the IPad Playgrounds app. Is it me or the system?
Simplified code to show the issue. Hardware is a 2018 iPad Pro running iOS 12.3.1 Playgrounds app 3.0. Using UIViews up to five can be added successfully.
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
let square50 = CGSize(width: 50, height: 50)
override func viewDidLoad() {
var myFrame = CGRect(origin: .zero, size: square50)
for index in 0...4 {
view.addSubview(UIView(frame: myFrame)) // fails at 6th!
(view.subviews[index] as! UIView).backgroundColor = .red
myFrame.origin.y += 80
}
}
}
PlaygroundPage.current.liveView = MyViewController()
With the index range set as shown the code worked as expected, displaying the set number of coloured rectangles. With the range increased to 0...5 the runtime stopped with the message “There was a problem encountered while running this playground. Check your code for mistakes”.
Just been able to test the code on Xcode 10.3 under OS X 10.16.6 on my iMac Retina 5k 27" late 2015. There is NO problem with the code and there is no short-range limit on the number of sub-views that can be created.
The problem rests with iOS Swift Playgrounds 3.0 running on an iPad Pro 12.9 inch 3rd-gen using iOS 12.3.1. This is therefore a bug!
I'm coding an app in Swift3. I'm using the google maps sdk. I've implemented a GMSMapView. I'm trying to ascertain what lat long that the user tapped in the GMSMapView.
Below is the reference for the android development version of what I think would help. But I can't find the equivalent for iOS.
https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapClickListener
edit: The "possible duplicate" didn't solve my problem.
I found the solution at: https://developers.google.com/maps/documentation/ios-sdk/events
by googling for didTapAtCoordinate, which I somehow knew was part of the SDK.
The most important line for me was: mapView.delegate = self. It's possible that some other solutions I tried would have worked had I used mapView.delegate = self, but nothing else had mentioned it. Also, the func mapView is of course important so I can use the coordinates of where the user tapped.
import UIKit
import GoogleMaps
override func loadView() {
let camera = GMSCameraPosition.camera(withLatitude: 1.285,
longitude: 103.848,
zoom: 12)
let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
mapView.delegate = self
self.view = mapView
}
// MARK: GMSMapViewDelegate
class DemoViewController: UIViewController, GMSMapViewDelegate {
}
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
}//end func