SKPhysicsContactDelegate method arguments are of unexpected class

Originator:douglashill
Number:rdar://46235215 Date Originated:26-Nov-2018 11:35 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:Xcode 10.1, iOS 12.1
Classification:Other Bug Reproducible:Always
 
Summary:
When SKPhysicsWorld sends didBeginContact: and didEndContact: to its contactDelegate, the contact argument is of class PKPhysicsContact, while the API states that this object should be of class SKPhysicsContact. This breaks categories on SKPhysicsContact.

Presumably the implementation of SKPhysicsContact is empty and it exists to provide a public API exposing some of PKPhysicsContact’s interface. In that case, could SKPhysicsContact be implemented as a wrapper around a PKPhysicsContact? It only has five read-only properties.

Steps to Reproduce:
A sample project is attached, which asserts the class is as the API declared. See Source/Scene.m.

1. Set up a Sprite Kit scene so the physics world has a contactDelegate and a collision occurs that has contactTestBitMask set.
2. In the contactDelegate’s implementation of didBeginContact:, observe the class of the contact argument, perhaps using [contact isKindOfClass:[SKPhysicsContact class]].

Expected Results:
[contact isKindOfClass:[SKPhysicsContact class]] should return YES, because this is declared by the API.

Actual Results:
contact is a PKPhysicsContact from the private Physics Kit framework, which is not a subclass of SKPhysicsContact. Category methods on SKPhysicsContact cause a runtime exception when sent to the contact argument.

Version:
Xcode 10.1, iOS 12.1

Notes:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!