Closed tcollins590 closed 4 months ago
cc @egorzhdan
Thanks, this is tracked internally as rdar://115424525, and we're working to fix this in https://github.com/apple/swift/pull/69776
@egorzhdan Thanks for the update. I've found several other pieces of swift code that break when enabling interop such as pieces of ARKit. Would you like those as separate issues?
@tcollins590 yes, please! The issues with NSNotification.Name
are all caused by the same underlying problem, so there's no need to report them, but other cases of source breakage caused by C++ interop are definitely worth reporting separately.
Is there a workaround for this issue?
@knielsen-foreflight sorry for the delay in response. As a temporary workaround I implemented a polling based solution for the specific use case. In my case I needed to see if an external camera was attached. To achieve this I poll the camera configuration to see if there is one attached. This is not an optimal fix but allowed me to solve the issue while I wait for a future fix in swift.
I have the same issue for our app, do we have an ETA for when this fix will be released?
@knielsen-foreflight sorry for the delay in response. As a temporary workaround I implemented a polling based solution for the specific use case. In my case I needed to see if an external camera was attached. To achieve this I poll the camera configuration to see if there is one attached. This is not an optimal fix but allowed me to solve the issue while I wait for a future fix in swift.
There is a workaround, based in "init raw value". Swift code:
NotificationCenter.default.addObserver(forName: Notification.Name.GCControllerDidConnect, object: nil, queue: nil, using: connectMFIController)
Is equivalent to
NotificationCenter.default.addObserver(forName: Notification.Name.init(rawValue: "GCControllerDidConnectNotification"), object: nil, queue: nil, using: connectMFIController)
Find the string name is possible with "print" (swift):
print(Notification.Name.GCControllerDidConnect)
Output this:
NSNotificationName(_rawValue: GCControllerDidConnectNotification)
(Of course you must set interop to "C / Objective C" firstly).
This just hit me and I spent way too long trying to understand what caused it. Is there an ETA? I see the fix is merged but it's unavailable to me as of Xcode 15.4 and the macOS 14 SDK
Is there an ETA?
Apparently this was not nominated for 5.10, so it will ship with 6.0, the next release.
Description I have a swift package that I am trying to add c++ interop to. The package compiles until I add
swiftSettings: [.interoperabilityMode(.Cxx)]
. I'm then presented with a few errors in my existing swift codeThe code
The error
Type 'NSNotification.Name' has no member 'AVCaptureDeviceWasConnected
Type 'NSNotification.Name' has no member 'AVCaptureDeviceWasDisconnected
Steps to reproduce Add an observer to the NotificationCenter to observe
NSNotification.Name.AVCaptureDeviceWasDisconnected
. Compile without swift interop and then attempt to compile with swift interopExpected behavior I expect this to compile with swift interop just as it does without interop enabled
Environment
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) Target: arm64-apple-macosx14.0
Xcode 15.0 Build version 15A240d