Add safe NSValue geometry wrappers#862
Conversation
🤖 Augment PR SummarySummary: This PR adds OpenSwiftUI-safe Changes:
Technical Notes: Runtime selector checks keep iOS/UIKit behavior aligned while still supporting macOS/Foundation differences in geometry boxing APIs. 🤖 Was this summary useful? React with 👍 or 👎 |
|
|
||
| @interface NSValue (OpenSwiftUI_UIGeometry) | ||
|
|
||
| + (NSValue *)valueWithCGPoint_openswiftui_safe_wrapper:(CGPoint)point OPENSWIFTUI_SWIFT_NAME(init(cgPoint:)); |
There was a problem hiding this comment.
valueWithCGPoint_openswiftui_safe_wrapper/valueWithCGSize_openswiftui_safe_wrapper/valueWithCGRect_openswiftui_safe_wrapper look like Swift-mapped initializers; consider returning instancetype instead of NSValue * so Swift imports them as returning Self (and it stays correct if NSValue is subclassed/class-clustered).
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #862 +/- ##
=======================================
Coverage 25.69% 25.70%
=======================================
Files 677 677
Lines 46905 46905
=======================================
+ Hits 12053 12056 +3
+ Misses 34852 34849 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Adds a UIFoundation shim for
NSValuegeometry boxing so OpenSwiftUICore can useCGPoint,CGSize, andCGRectinitializers without depending on UIKit.The new wrappers first call the platform implementation when selectors like
valueWithCGSize:are available, which should keep the UIKit/iOS path aligned with the system behavior. When those selectors are unavailable, such as on macOS where Foundation exposesNSValue(size:)instead ofNSValue(cgSize:), the wrappers fall back tovalueWithBytes:objCType:using the CoreGraphics encoding.Changes
UIGeometry.h/UIGeometry.munderOpenSwiftUI_SPI/Shims/UIFoundation.NSValue(cgPoint:),NSValue(cgSize:), andNSValue(cgRect:)through OpenSwiftUI-safe wrappers.cg*APIs viaUIFoundation_Private.Validation
swift package describe --type jsonOPENSWIFTUI_USE_LOCAL_DEPS=1 swift package describe --type jsonswift build --target OpenSwiftUICoreBuilds completed successfully with existing warnings only.