(Other) build error with C++ interop enabled

I'm wanting to update some of my old ObjC code which uses Apple's Game Controller Framework to Swift, but am running into build errors only when C++ interop is enabled. I've distilled this down to a simple repro case below and have tested with current production Xcode (15.0 15A240d) as well as the 15.0.1 RC and 15.1 beta.


  • In Xcode, create a new template project (I did 'Multiplatform game' but I think anything will work)
  • For the Mac target, under 'Signing & Capabilities', add 'Game Controllers' and check 'Extended Gamepad' box.
  • In the Mac AppDelegate.swift, import GameController and add the following line of code in applicationDidFinishLaunching: NotificationCenter.default.addObserver(forName: .GCControllerDidConnect, object: nil, queue: .main) { note in print("Controller Connected!") }
  • This should build successfully. If desired, run the app and connect a controller and the print should fire.
  • Now, under ‘Build Settings’ for the Mac target, change ‘C++ and Objective-C Interoperability’ from ‘C / Objective-C’ to ‘C++ / Objective-C++’.
  • Attempt to build again.
  • The build will now fail with an error “Type ‘NSNotification.Name?’ has no member ‘GCControllerDidConnect’”

Would this be a bug? I can work around this by plugging in the raw string value NSNotification.Name("GCControllerDidConnectNotification") instead of .GCControllerDidConnect, but thought I'd ask about it. I've also reported this in Feedback Assistant as FB13283431. Please let me know if there's somewhere else I should go with it.

1 Like

Thank you for filing the feedback assistant. This looks to be a C++ interop related issue, and we'll look into fixing it.

1 Like

FWIW, I'm still seeing this behavior in Xcode 15.2 (15C500b)