Post

Replies

Boosts

Views

Activity

New initializer for ASWebAuthenticationSession
I have noticed that there is a new initializer for ASWebAuthenticationSession in macOS 14.4. The standard initializer has been deprecated without further info. The new initializer looks as follows: init(url: URL, callback: ASWebAuthenticationSession.Callback, completionHandler: ASWebAuthenticationSession.CompletionHandler) This initializer takes a callback object for class ASWebAuthenticationSession.Callback. But this class cannot be initialized and also not be subclassed. When you try to do this there will be the following error in Xcode 'init()' is unavailable The documentation also does not give any hint on how to use it, it just defines 2 class methods and a method called func matchesURL(URL) -> Bool which could mean that by using this method you could match any arbitrary URL to continue the process. Has anyone figured out what to do with this?
1
0
906
Mar ’24
No permission to read file when chosen with .fileImporter
I have a sandboxed application that opens a file that has been chosen by the NSOpenPanel (or .fileImporter as it is a SwiftUI). The permissions are set properly with for the sandbox (see screenshot) After recompiling with Xcode 15.3 (and also with 15.2) the permission is not granted anymore and I cannot open the file anymore. An exception is thrown with The file “someFile.csv” couldn’t be opened because you don’t have permission to view it.. Is there something new, that needs to be done, so that this works again? If I turn off the sandbox the file opens without any problem. It is even reproducible with a completely new application with the following simple code: import SwiftUI import UniformTypeIdentifiers @main struct IFinanceCleanerApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { @State private var url: URL? @State private var showErrorDialog = false @State private var showImporter = false @State private var lastError: Error? var body: some View { Button("Show") { showImporter = true } .fileImporter(isPresented: $showImporter, allowedContentTypes: [.commaSeparatedText]) { result in switch result { case .success(let openUrl): url = openUrl do { let strings = try String(contentsOf: openUrl) } catch { showErrorDialog = true lastError = error } case .failure(let error): print("Open Panel failed: \(error.localizedDescription)") } } .alert("Opening File failed", isPresented: $showErrorDialog) { Button("OK") {} } message: { Text(lastError?.localizedDescription ?? "") } } }
2
0
958
Mar ’24
Mulitple Targets with shared Localizable file. Cannot convert to String Catalog
In my project I have 3 targets. A macOS target, a target for iPhone and a target for iPad. The macOS App has an own Localizable file and I have been able to convert this to string catalog without any issues. I like this catalog! But when I try to convert the Localizable file that is shared between 2 targets, then targets fail to compile afterwards with the following error message: ...mul.lproj/Localizable.xcstrings:1:1 Localizable.xcstrings cannot co-exist with other .strings or .stringsdict tables with the same name. Does anybody have an idea how I can resolve this? Do I need to keep individual copies of the Localizable file for these 2 targets?
1
0
1.8k
Jun ’23
ImageResource properties name and bundle as public getters
Hi, I love the idea of the ImageResource struct and it is a great error reduction to automatically provide an ImageResource for every Image in the asset catalog. I immediately started to adopt it. But I have a case where I would still need to have access to the name of the Image and the bundle. So I would suggest that you provide change the struct for ImageResource to have name and bundle as public getters. With this, there is still a safe way in the code to access the resource and still be able to use the name of the resource. So instead of generating: struct ImageResource: Hashable { /// An asset catalog image resource name. fileprivate let name: String /// An asset catalog image resource bundle. fileprivate let bundle: Bundle /// Initialize an `ImageResource` with `name` and `bundle`. init(name: String, bundle: Bundle) { self.name = name self.bundle = bundle } } Just generate it as: struct ImageResource: Hashable { /// An asset catalog image resource name. let name: String /// An asset catalog image resource bundle. let bundle: Bundle /// Initialize an `ImageResource` with `name` and `bundle`. init(name: String, bundle: Bundle) { self.name = name self.bundle = bundle } } The same applies to ColorResource as well. I have posted a feedback on this, but I am curious what others think about this? Am I the only one who still needs to have access to the name and the bundle of the ressource?
3
1
1.8k
Jun ’23
Xcode 13.2 Beta: Can only own code use the async/await in macos < 12.0
With Xcode 13.2 it is now possible to use async/await also in code prior to macos 12.0 (iOS....). As I like this new pattern i have started to migrate existing code to this pattern and I have found out, that although you can use async/await in your own code, you cannot (yet?) call system libraries that adopt this pattern. I have for example tried to replace URLSessions dataTask(with:completionHandler:) with the async version data(from, delegate) async throws -> (Data, URLResponse) but this fails with the error, that this function is only available on macos 12.0. Am I missing something or is Apple planning to also add backward compatibility for older OS versions? Like this it is just half that funny.
2
0
1.1k
Oct ’21