Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
Using Swift5.7, XCode14.0, iOS16.0,
I get very strange error messages and warnings in my XCode console, when trying to make a MapKit example to work.
Here is the log:
2022-11-01 17:26:51.756834+0100 myApp[3999:834036] Metal API Validation Enabled
2022-11-01 17:26:52.139973+0100 myApp[3999:834036] [PipelineLibrary] Mapping the pipeline data cache failed, errno 22
2022-11-01 17:26:52.192482+0100 myApp[3999:834036] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
2022-11-01 17:26:53.884031+0100 myApp[3999:834036] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2022-11-01 17:26:53.900265+0100 myApp[3999:834036] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
It seems that in SwiftUI, there has been a change in how Published variables in combination with Bindings are handeled.
The core issue, I think, is very nicely described here.
And I assume that Apple has not finished the transition to this new SwiftUI4 behaviour in their own API's themselves.
Or is there any way I can make the Publishing changes bla bla
warning going away ??
See my entire Code here below:
// MyView.swift
// myApp
import SwiftUI
import MapKit
struct MyView: View {
@State private var showMap = false
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(
latitude: 37.8879948,
longitude: 4.1237047
span: MKCoordinateSpan(
latitudeDelta: 0.05,
longitudeDelta: 0.05
@State private var locations: [Location] = [Location(name: "Test", description: "", latitude: 37.8879948, longitude: 4.1237047)]
@State private var isLoading = false
var body: some View {
Map(coordinateRegion: $region,
annotationItems: locations,
annotationContent: { location in
MapAnnotation(
coordinate: CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
VStack {
Image("THPin")
.resizable()
.scaledToFit()
.frame(width: 44, height: 44)
ZStack {
Text(location.name)
.padding(5)
.font(.subheadline)
.background(.white.opacity(0.5), in: Capsule())
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.