Post

Replies

Boosts

Views

Activity

Swift Macros: Rewrite block to add weak capture?
Hi, I thought I'd ask as this sounds like the perfect use for Swift Macros and I'm betting other people ran into the same issue :) I'm currently trying to simplify [weak self] captures in some of my code. For example: // Usual syntax someAlert.addTextField { [weak self] textField in guard let self else { return } textField.text = somethingInSelf() } Adding a macro seems to trade one kind of wordiness for another: // Using a macro works, but is wordy because it requires non-trailing syntax someAlert.addTextField(configurationHandler: #weakSelf { textField in textField.text = somethingInSelf() }) Ideally I imagine there must be a way to do something like the code below: // Using the same macro fails when applied to a trailing closure someAlert.addTextField #weakSelf { textField in textField.text = somethingInSelf() } Does anyone have any suggestions? I feel this is probably a known/solved problem and I'm being a bit slow on the uptake :D
0
0
503
Sep ’23
Apps running in Xcode 13 beta 5 iOS simulator crash shortly after a DispatchSemaphore is released by the system
Filed as FB9486500 Once a local DispatchSemaphore is released by the system, the app crashes in the Xcode 13 beta 5 simulator, but works correctly on the device running iOS 15 beta 5. This is very simple to reproduce. E.g. adding this on a boilerplate Xcode beta 5 project's VC: override func viewDidAppear(_ animated: Bool) {     super.viewDidAppear(animated)     let semaphore = DispatchSemaphore(value: 0)     // If this was a strong instance property the crash does not occur     DispatchQueue.main.asyncAfter(deadline: .now() + 2) {         semaphore.signal()     }     DispatchQueue.global().async {         print("Waiting on semaphore...")         semaphore.wait()         print("Semaphore has been signalled, iOS sim will crash about 10 seconds after this message, device will be fine.")     } } This issue occurs only on the sim, not a device, on iOS 15 beta 5. In case it's relevant, running on an M1 Mac. The most critical API affected by this so far is NSFileCoordinator, which totally breaks in the sim when it internally tries to handle semaphores.
2
0
1.8k
Aug ’21
Xcode 13 beta 5 cannot submit TF builds
The usual problem, has to happen at least once each summer I suppose :) Could the person responsible take a moment and update the relevant records please? It's been days now, thanks! ERROR ITMS-90744: "Unsupported Xcode or SDK Version. Your app was built with a version of Xcode or SDK that is not yet supported for upload to App Store Connect. For more information about supported versions of Xcode and SDK for Testflight or App Store submissions, view the App Store Connect What's New page (https://developer.apple.com/app-store-connect/whats-new/)."
6
0
2.1k
Aug ’21