Posts

Post not yet marked as solved
14 Replies
3.3k Views
Hi, since the Xcode 13 beta 5 I am seeing crashes in _os_semaphore_dispose.cold.* when running in the iOS simulator. This happens in different apps under various conditions, so I can pin it down to something specific. Is anybody else having similar issues? Stack of the crashing thread looks like this: Disassembly looks like this: Thanks for any feedback. Cheers, Michael
Posted
by milutz.
Last updated
.
Post not yet marked as solved
1 Replies
3k Views
Hi, is there a way that an actor can have a @MainActor @Published annotated property which is then consumed by a SwiftUI View "as usual"? Currently this: @Published @MainActor public private(set) var state: State = .initial gives me the following error when trying to access it from with a SwiftUI View: "Actor-isolated property '$state' can only be referenced from inside the actor" I guess I understand where the error is coming from, but I wonder if there's a way to publish properties from actors and be able to make sure they are updated on the main thread by annotating them with @MainActor.
Posted
by milutz.
Last updated
.
Post not yet marked as solved
2 Replies
1.9k Views
Hi, when using URL session nested in a few async/await calls I get a crash in swift_getObjectType (sometimes in processDefaultActor). Any ideas what could be causing this or hints how to debug/where to look? For a (contrived - because it was extracted from a larger project) example please see below (see "crashes here" comment for the last call before the crash). Thanks for any hints in advance! Cheers, Michael // Crash on: Xcode Version 13.0 beta (13A5155e), macOS 11.4 (20F71), on iPhone Simulator import CoreData import SwiftUI struct ContentView: View { @StateObject var dataCoordinator: DataCoordinator = .init() var body: some View { Button { print("GO") async { try await dataCoordinator.api.getSomething() } } label: { Label("Go", systemImage: "figure.walk") } .buttonStyle(.bordered) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } // MARK: - Test coding - class DataCoordinator: ObservableObject { let api: API = .init() func refreshSomething() async throws { try await api.getSomething() } } // MARK: - class API { var session: URLSession = .init(configuration: .ephemeral) func getSomething() async throws { let url = URL(string: "https://www.heise.de")! let request = URLRequest(url: url) let (data, response) = try await _failsafe(request: request) print("\(response)") } private func _failsafe(request: URLRequest) async throws -> (Data, URLResponse) { do { var (data, response) = try await session.data(for: request) let httpResponse = response as! HTTPURLResponse var recovered = false if httpResponse.allHeaderFields["dsfsfsdsfds"] == nil { let login = LoginAsync() await login.login(session: session) recovered = true } if recovered { let req2 = URLRequest(url: URL(string: "https://www.heise.de")!) print("right before crash") try await session.data(for: req2) // crashes here with EXC_BAD_ACCESS print("right after crash ;-)") } return (data, response) } catch { print("\(error)") throw error } } } // MARK: - actor LoginAsync { func login(session: URLSession) async { let url = URL(string: "https://www.google.com")! let request = URLRequest(url: url) do { let (data, response) = try await session.data(for: request) } catch { print("\(error)") } } }
Posted
by milutz.
Last updated
.
Post not yet marked as solved
1 Replies
769 Views
I am getting a strange crash (see call stack in attached screenshot). I am looking for ideas/hints how to track down what the issue is?
Posted
by milutz.
Last updated
.
Post not yet marked as solved
2 Replies
1.9k Views
Hi, I have a very simple program (see below) with some Views in an HStack, which is within a ScrollView. This works fine on iOS, but on macOS nothing scrolls. Am I missing something? Shouldn't it just scroll? import SwiftUI struct ContentView: View { 	var body: some View { 		ScrollView(.horizontal, showsIndicators: true) { 			HStack { 				ItemView(n: 1) 				ItemView(n: 2) 				ItemView(n: 3) 				ItemView(n: 4) 				ItemView(n: 5) 			} 		} 		.frame(minWidth: 350, maxWidth: 800, minHeight: 250, maxHeight: 250, alignment: .center) 	} } struct ContentView_Previews: PreviewProvider { 	static var previews: some View { 		ContentView() 	} } struct ItemView: View { 	var n: Int 	 	var body: some View { 		Rectangle() 			.frame(width: 300, height: 200) 			.overlay(Text("\(n)").foregroundColor(.white)) 	} }
Posted
by milutz.
Last updated
.
Post not yet marked as solved
0 Replies
456 Views
Hi, I am trying to develop a "ui control", which should react on, for example, the cursor keys when in focus. I could not find anything in the docs regarding keyboard and focus handling. Has anybody any hints on how to achieve this or where to get information on that topic? Thank you! Cheers, Michael
Posted
by milutz.
Last updated
.
Post not yet marked as solved
5 Replies
1.1k Views
Hi, the documentation for @State says: You should only access a state property from inside the view’s body, or from methods called by it. Therefore I am wondering of this is an incorrect (as aValue is set/accessed outside of a "view's body") usage of @State which, while it works now, might break in the future: @main struct SwiftUIArrayUpdateTestApp: App { 	@State private var aValue = 5 	var body: some Scene { 		WindowGroup { 			ContentView(value: $aValue) 		} 	} }
Posted
by milutz.
Last updated
.
Post not yet marked as solved
0 Replies
510 Views
Hi, I want to have more than one MKAnnotation to be selected, but so far it seems that it is not possible, is that true? If yes are there any workarounds? MKMapView has the selectedAnnotations property, which is an Array and also set-able, but the documentation states: "Assigning a new array to this property selects only the first annotation in the array.". So I am wondering why this even is an Array and if there is in fact a way to have multiple annotations selected, that I am not aware of... Any help, hints highly appreciated :-). Cheers, Michael
Posted
by milutz.
Last updated
.
Post not yet marked as solved
0 Replies
360 Views
Hi, I am wondering if anybody who is facing issues with @State not working properly in iOS 14 has received any update on that from Apple? Since having working @State properly is quite essential to have a working SwiftUI implementation I am a bit puzzled to not have gotten any update at all on the issue from Apples side. That's the issue I am encountering: https://developer.apple.com/forums/thread/660976 Here are a few other threads from the forum which at least seem to be related to this issue: https://developer.apple.com/forums/thread/652080 https://developer.apple.com/forums/thread/652258 https://developer.apple.com/forums/thread/661818 https://developer.apple.com/forums/thread/660927 https://developer.apple.com/forums/thread/661777 https://developer.apple.com/forums/thread/659660 https://developer.apple.com/forums/thread/661754
Posted
by milutz.
Last updated
.
Post marked as solved
2 Replies
3.2k Views
Hi, is it possible to have access to NSApplicationDelegate methods like application(_ sender: NSApplication, openFiles filenames: [String]) when using the Swift UI App Life Cycle? With "access" I mean equivalent functionality. I know there is support for a document based app using the Swift UI App Life Cycle, which would seem to resolve the issue for that particular openFiles delegate method, but for various reasons I can't use the document based app life cycle. Thank you! Cheers, Michael
Posted
by milutz.
Last updated
.
Post marked as solved
9 Replies
8.6k Views
Hello,I recently see sometimes crashing errors with statements like "precondition failure: attribute failed to set an initial value: 103" logged to the console. The numbers at the end vary. Has anybody found a good way (or any way besides blindly trying to change things ;-) to track down those errors?Cheers, Michael
Posted
by milutz.
Last updated
.
Post not yet marked as solved
6 Replies
544 Views
Hi,does anyone know the reason why a mounted volume might not ave a `URLResourceValues.volumeUUIDString`?I have two mostly identical SD Cards (same size, formatted in the same camera). One has a volumeUUIDString when mounted and the other has none.The documentation for volumeUUIDString only says:"The volume's persistent `UUID` as a string, or nil if a persistent `UUID` is not available for the volume.". So no real explanation given why there might be no volumeUUIDString. Or what might be another option for uniquely identifying a volume.Any hints, info highly appreciated.Cheers, Michael
Posted
by milutz.
Last updated
.
Post marked as solved
3 Replies
1.8k Views
Hi,when using an ForEach within an ScrollView the UI does not get updated if the ObservedObject, which is used in ForEach, changes. If the ForEach is not embedded in a ScrollView the update works.IMHO the ForEach within the ScrollView should work, or am I wrong?To illustrate the issue here's some example coding to paste in an (iOS) Playground.import PlaygroundSupport import SwiftUI struct User: Hashable { var name: String } typealias Users = [User] let usersData = [ User(name: "Alpha"), User(name: "Beta"), User(name: "Gamma"), ] class UserViewModel: ObservableObject { @Published var users: Users = [] func get() { DispatchQueue.main.asyncAfter(deadline: .now() + 1) { print("Update") self.users = usersData } } } // If the ScrollView is present nothing is shown after the model is updated. // If a screen refresh is triggered (for example when running this on device and switch // from portrait to landscape the UI shows up. struct ContentView: View { @ObservedObject var user = UserViewModel() var body: some View { ScrollView { // comment scrollview out and it works ForEach(user.users, id: \.self) { user in Text("\(user.name)") } } .onAppear { self.user.get() // to simulate model update } } } PlaygroundPage.current.liveView = UIHostingController(rootView: ContentView())Thanks for your Feeback!Cheers, Michael
Posted
by milutz.
Last updated
.