Post

Replies

Boosts

Views

Activity

Warning: Reference to captured var 'hashBag' in concurrently-executing code
I get many warnings like this when I build an old project. I asked AI chatbot which gave me several solutions, the recommended one is: var hashBag = [String: Int]() func updateHashBag() async { var tempHashBag = hashBag // make copy await withTaskGroup(of: Void.self) { group in group.addTask { tempHashBag["key1"] = 1 } group.addTask { tempHashBag["key2"] = 2 } } hashBag = tempHashBag // copy back? } My understanding is that in the task group, the concurrency engine ensures synchronized modifications on the temp copy in multiple tasks. I should not worry about this. My question is about performance. What if I want to put a lot of data into the bag? Does the compiler do some kind of magics to optimize low level memory allocations? For example, the temp copy actually is not a real copy, it is a special reference to the original hash bag; it is only grammar glue that I am modifying the copy.
4
0
91
Apr ’25
How include dSYM when I build my Framework project?
This question is related to this post (of mine). It seems default build settings do not include dSYM files needed when uploading embedding app package. But now Xcode issues new warnings about this. Now the question - how do I tell Xcode to create dSYM files for me, say when I build My.Framework? I asked AI chatbot which tells me that for release build I need to : set "Debug Information Format" to DWARF set "Strip Debug Symbols During Copy" to off I have item 1 turned on (which I believe is the default). But item 2 is on, maybe that's the reason I do not have dSYM files in final built My.Framework. Should I turn "Strip Debug Symbols During Copy" off?
3
0
65
Apr ’25
Piece of code in Playground that reliably crashes lldb server
Dare anyone try the following code in any Playground: // Define a model that conforms to Codable struct User: Codable { var name: String var age: Int var email: String? } // JSON data (as a string for demonstration) let jsonString = """ { "name": "John Doe", "age": 30, "email": "john@example.com" } """ // Convert the JSON string to Data if let jsonData = jsonString.data(using: .utf8) { do { // Parse the JSON data into the User model let user = try JSONDecoder().decode(User.self, from: jsonData) print("Name: \(user.name), Age: \(user.age), Email: \(user.email ?? "N/A")") } catch { print("Error decoding JSON: \(error)") } } I tested with Xcode 16.2 and latest 16.3, it reliably crashes the lldb server!
6
1
148
Apr ’25
self.window.isVisible = NO not working in windowDidLoad
The following code won't work: - (void)windowDidLoad { [super windowDidLoad]; self.window.isVisible = NO; } The only main window still shows on application startup (in a minimal newly created app). One of my published apps in App Store relies on this behavior which had been working for many years since I started Xcode development.
Topic: UI Frameworks SubTopic: AppKit
11
0
95
Mar ’25
Zombie Xcode problem
I have a weird problem with Xcode v15.4. For some unknown reasons, it sometimes becomes a zombie process - I cannot even quit it using CMD+Q, nor can I close open projects. I have to forcibly kill the process using Activity Monitor. The problem will mostly strike after a long time of idle time (hours or even days). Does anyone else have this same problem? Is there known workaround? BTW, when it becomes a zombie process, another related com.apple.dt.SKAgent process will begin consuming much CPU time forever.
2
0
479
Aug ’24
Need Objective-C translation of DispatchSource.makeFileSystemObjectSource
I came across a useful repo on GitHub: https://github.com/GianniCarlo/DirectoryWatcher/blob/master/Sources/DirectoryWatcher/DirectoryWatcher.swift self.queue = DispatchQueue.global() self.source = DispatchSource.makeFileSystemObjectSource(fileDescriptor: descriptor, eventMask: .write, queue: self.queue) self.source?.setEventHandler { [weak self] in self?.directoryDidChange() } self.source?.setCancelHandler() { close(descriptor) } self.source?.resume() How do I translate this to OC version? I have an app that was written in OC and I plan to incorporate this directory watcher into the project.
2
0
950
Jul ’24
How disable ~/Applications/asr auto creation
It's quite annoying (maybe it's only my personal interests). Some apps or the macOS system always create ~/Applications/asr directory and create some txt files in it. asr20240708_1638030_0.txt {"type":"asr","wp_version":"","easr_version":"e792c1d2b4b5055e56fb902dfefdb483802041cc_Thu_Dec_30_17:18:43_2021_+0800","spil_version":"","wpe_version":"","vad_version":"9db42b766a4bc4e853bfa3fd2f846bf931d6c05f_Wed_Mar_24_15:56:16_2021_+0800","header_type":0} It there any way to disable this 'useful' feature?
0
0
390
Jul ’24