init(coordinates: GeoCoordinates, image: UIImage) {
let pngData = image.pngData()
let mapImage = MapImage(pixelData: pngData!, imageFormat: ImageFormat.png)
print("i did print")
self.mapMarker = MapMarker(at: coordinates, image: mapImage)
}
This is the error message -
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/usr/lib/libMTLCapture.dylib terminating with uncaught exception of type std::runtime_error: SDK engine is null. Please provide a valid object.
pngData isn't a nil value when the MapImage constructor is called, I checked it by printing. What does this error mean and how can I fix it?
I figured this out myself. The crux of the issue is that before creating the MapImage instance the HereSDK engine needs to be initialized which can be done in 2 ways-
Initialize the MapView which in turn initializes the HereSDK engine but in my case this initialization was happening after the MapImage instance initialization statement.
Initialize the engine explicitly before the MapImage instance initialization statement.
do { try SDKInitializer.initializeIfNecessary() } catch { fatalError("Failed to initialize HERE SDK. Cause: (error)") }
This can be done in the AppDelegate file as well.