Post

Replies

Boosts

Views

Created

SwiftUI .fileImporter and custom UTType
Hi, I want to import GPX files into my iOS App. It works fine in the simulator using: .fileImporter(isPresented: $showFileImporter, allowedContentTypes: [UTType(filenameExtension: "gpx")!, UTType(filenameExtension: "GPX")!], allowsMultipleSelection: true) But running the app on an actual device (iOS 15 Beta 6), I am not allowed to select any of the GPX files. The strange thing is, that if I am using "jpg" instead of "gpx" I can select "jpg" files just fine. So it seems, that it has to do something with the "GPX" type being 'custom'. Any idea/hint what I am missing? Thank you! Michael
2
0
3.2k
Aug ’21
Crashes in _os_semaphore_dispose.cold since Xcode 13 beta 5
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
17
0
3.9k
Aug ’21
Crash in swift_getObjectType or processDefaultActor when using (nested) async/await with URLSession
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)") } } }
2
0
2.5k
Jun ’21
actors, SwiftUI and @Published
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.
1
0
4.0k
Jun ’21
ScrollView not working properly on macOS?
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)) 	} }
2
0
2.4k
Oct ’20
Curious sheet behaviour
Hi, I have a strange case involving sheets, which I think it's a bug, but then again I might be missing something. Using the following code: import SwiftUI enum WhichSheet: String { 	case one, two, three, none } struct ContentView: View { 	@State private var _showSheet = false 	@State private var _whichSheet: WhichSheet = .none 		var body: some View { 			VStack(spacing: 8) { 					Button("One Sheet", action: { self._whichSheet = .one; self._showSheet = true}) 					Button("Two Sheet", action: { self._whichSheet = .two; self._showSheet = true}) 					Button("Three Sheet", action: { self._whichSheet = .three; self._showSheet = true}) 			} 				.sheet(isPresented: $_showSheet, content: { 				Text("whichSheet = \(_whichSheet.rawValue)") 			}) 		} } struct ContentView_Previews: PreviewProvider { 		static var previews: some View { 			ContentView() 		} } I would assume that, depending on which button is pressed, I would say a sheet with the text "whichSheet = one" or "whichSheet = two" etc. But no matter which button is pressed first the text on the sheet is always "whichSheet = none". Only if you choose a different button the second (or third, or ...) time the correct text is being displayed. Bug or am I missing something really obvious? (Test using an iOS 14 / 14.2 project with Xcode 12 / 12.2 beta) Cheers, Michael
4
0
1.8k
Sep ’20