0
votes

I'm attempting to use HEREMaps with SwiftUI via UIViewRepresentable and I'm getting the following crash when instantiating NMAMapView. Using HEREMaps version 3.13.3 pod.

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

import SwiftUI
import NMAKit

struct MapView: UIViewRepresentable {

    func makeUIView(context: Context) -> NMAMapView {
        let mapView = NMAMapView()
        return mapView
    }

    func updateUIView(_ uiView: NMAMapView, context: Context) {

    }
}

struct ContentView: View {
    var body: some View {
        MapView()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Also, no luck with adding NSLocationWhenInUseUsageDescription to my Inof.plist

2

2 Answers

0
votes

We have written down a sample code to initialise the NMAPView. Try with the following

import UIKit
import NMAKit

class ViewController: UIViewController {

    @IBOutlet weak var mapView: NMAMapView!

    private var gestureMarker: NMAMapMarker?

    override func viewDidLoad() {
        super.viewDidLoad()
        //set current controller to be delegate of map view's gesture
        mapView.gestureDelegate = self

        //add image icon to show current positon, which can shows map view motion when gestures were applied
        guard let image = UIImage(named: "indicator") else { return }
        let indicatorMarker = NMAMapMarker(geoCoordinates: mapView.geoCenter, image: image)
        mapView.add(mapObject: indicatorMarker)
    }
0
votes

This is HERE SDK issue. Unfortunately no workarounds found yet.

Fix will be included in next HERE SDK Release(3.15), which is planned on April 1, 2020.

Thanks for reporting!