Skip to content

Conversation

@jrflat
Copy link
Contributor

@jrflat jrflat commented May 19, 2025

Some C APIs take in a const void * that is expected to be a CFURLRef * in certain cases. When a Swift API is generated for these functions, they instead take an UnsafeRawPointer.

Code passing an implicit raw pointer to a struct URL using &var notation can cause issues if the C function assumes the address of a URL points to a NSURL * or CFURLRef. This used to work because an NSURL was the first member of struct URL, but now that memory location contains the _SwiftURL class.

This PR allows us to restore the old behavior in very rare cases on Darwin where it's needed for compatibility by making _BridgedURL an NSObject and forwarding the ObjC messages it receives to the wrapped NSURL.

@jrflat
Copy link
Contributor Author

jrflat commented May 19, 2025

@swift-ci please test

@jrflat jrflat requested review from itingliu and parkera May 19, 2025 18:03
@jrflat jrflat merged commit ea9e9e2 into swiftlang:main May 19, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants