Post

Replies

Boosts

Views

Activity

XCode 15b4 compiler changed behaviour (possible bug) with weak properties being cleared prematurely
I've just spent a couple of hours zeroing in on a very weird bug. It seems that the Swift 5.9 compiler in XCode 15b4 is being overly-aggressive in clearing weak vars, compared to previous versions. I have a method that returns an SKAction?. In the debugger, I traced code and verified that the value it attempts to return is a some : <SKMove: 0x280422b40> However, the caller saves that value into a member which appears immediately after assignment nil I tried adding a local variable for the return value, as seen below. That worked but override func perform() -> Bool { if cachedSKA == nil { let xcodeBugWorkaround = gameAction.makeSKAction() // was assigning nil with xcode15b4 cachedSKA = xcodeBugWorkaround // cachedSKA now shows in the debugger as non-nil if let activeScene = tgTouchgram.mostRecentlyStartedPlaying?.activeSKScene, let foundNode = referredNode(on: activeScene) { cachedTarget = foundNode } } // BUG - still fails at this point - cachedSKA appears nil again guard let ska = cachedSKA, let targetNode = cachedTarget else { return true } targetNode.run(ska) return true } The problem appears to be because cachedSKA is a weak vars. I am fairly certain it is being set to nil incorrectly. Even though, within this method, the value is used, it is clearing the property as the sole holder of the object reference. A fussy walkthrough reveals the compiler's changed behaviour is probably legal but certainly unexpected. Working version, still keeping the property as weak: override func perform() -> Bool { var localSKA: SKAction? = cachedSKA if localSKA == nil { localSKA = gameAction.makeSKAction() cachedSKA = localSKA if let activeScene = tgTouchgram.mostRecentlyStartedPlaying?.activeSKScene, let foundNode = referredNode(on: activeScene) { cachedTarget = foundNode } } guard let ska = localSKA, let targetNode = cachedTarget else { return true } targetNode.run(ska) return true }
5
0
845
Jul ’23
Slack links fail for digital lounges
On the Digital lounges page there are links such as https://slack.com/app_redirect?channel=C03HCBT0N58 When I click one I end up on a random Slack channel I've been a member of for a long time, with a failure, eg: https://haiku-community.slack.com/app_redirect?channel=C03HCBT0N58 and message like this. There’s been a glitch… We’re not quite sure what went wrong. You can go back, or try looking on our Help Center if you need a hand.
1
0
1k
Jun ’22
iMessage and StoreKit - how to handle in app extension?
Most of the interaction in Touchgram occurs in the iMessage app extension. There is a full host app as well. I'm about to add a number of IAP for tool subscriptions as well as buying digital currency, to pay for assets. Can I use StoreKit inside the extension or does the workflow for handling purchases and receipt validation all have to happen inside my host app? Note Touchgram is probably the most complex iMessage app extension ever built (especially when I wrap v1.3) - it's effectively a full Keynote-level layout system plus gesture recognition plus exposing SpriteKit features such as shaders, animations & particles... all inside iMessage...to send interactive messages. There is a lot happening in that extension! What's currently in the live app on the store is a long way behind what's due to be released after WWDC.
0
0
739
Jun ’21