Thanks Quinn! I'll get back to the interop soon. The bridging header feels like cheating, but it's interesting that Xcode allowed you to include a C++ header there. Mine only contain ObjC and C. But with that new Interoperability setting, that does seem to change things.
Post
Replies
Boosts
Views
Activity
As I stated already, that doesn’t work with setting valid arch to one platform. So really need multi arch to work.
Now you also have 2 .o files, so then two libs, and then two more exe that have to be lipo-ed together. And now 2 targets. So it’s a bad cascade.
I also found this setting in Xcode, so set that for C++/Obj-C++ itnerop. That seems to change the errors that I get about ObjC. Will have more time to revisit this later.
SWIFT_OBJC_INTEROP_MODE = objcxx
Also wondering how to interop one C++ lib with another via clang modules. This document says there is no syntax for that, and that only ObjC has the "@import module" syntax. Given that it's over 4 years since C++20, and still no C++ 20 module support, I've resigned to just use clang modules. But it's unclear what they do or don't support. The docs below state that C++ is possible, and just need the "requires cplusplus" designator, but see above errrors.
https://prereleases.llvm.org/18.1.0/rc3/tools/clang/docs/Modules.html
I’m presuming that last bit was meant to be “Swift Xcode projects”.
Yes, it's all Xcode. In a workspace, with separate swift and C++ code. The C++ is vector math and a texture encoder/decoder. The Swift is visionOS stuff, a build profiler, etc. Mostly forced into Swift use by Swift-only frameworks like SwiftUI and RealityKit.
I'd like to move code off Swift and onto C++. This would primarily be Swift calling C++, and avoiding writing a bridging header.
So I think I have modules for C++ building, but then get errors trying to import them into Swift.
c++
module vectormath234 {
// All headers are pulled in by this.
requires cplusplus20
// This defaults to namespace simdk
header "vectormath234.h"
}
Swift
import vectormath234
module.modulemap:1:8 Module 'vectormath234' requires feature 'cplusplus20'
MathHelpers.swift:6:8 Could not build Objective-C module 'vectormath234'
I have -fmodules and -fcxx-modules set on the compile line.
Thanks Quinn if you have time to address this. I really appreciate your great dev support.
I have a profiler names alecazam/kram kram-profile. It's a SwiftUI app that does build analysis. It's not doing anything exotic with the List. The List was just broken.
I finally got that app ported from Swift 5 to Swift 6, and that seems to have fixed the VStack { List } case. I can't port the other app to Swift 6 due to so many concurrency warnings.
Not sure if this link will send, but this is the usage. But it's working now. I didn't change any code, just ported to Swift 6. But the tagged build isn't yet updated.
https://github.com/alecazam/kram/blob/main/kram-profile/kram-profile/kram_profileApp.swift
Looks like the GC calls do work for mouse/keyboard. I just need the shorter notification names.
notifications.addObserver(forName: .GCKeyboardDidConnect, object: nil, queue: .main) { [weak self] note in
if let controller = note.object as? GCKeyboard {
self?.addKeyboard(controller)
}
}
Also when I have Swift 5 set in Xcode 16, is that 5.xx (f.e. 5.9 has interop) or 5.0?
I have C++ Xcode projects and Swift projects. These only work right now with a c-style bridging header. Apple doesn’t have any sample apps that build clang modules sinice they were released many years ago. Watched the WWDC on explicit modules, but then read these don’t work with Swift interop.
Have a modulemap file, -fmodules defined, but Swift still can’t see the C++ sources. one of the strengths of Apple development was ease of interop between ObjC++ and C++. Have had to wait until Swift 5/6 for something not under a C-wrapper. My code is on Swift 5 if that matters. But switching to Swift 6 is a concurrency warning flood.
Already followed all that and it doesn’t work.
https://feedbackassistant.apple.com/feedback/15675361
I only have tried this controller, but it's not specific to the controller. The simulator needs to forward the notifications to the app, so that it knows the contoller is connnected/disconected.
https://feedbackassistant.apple.com/feedback/15673127
Note that the device is working fine on the actual hardware. So it's like the simulator isn't firing off the notification.
Xcode has never run on iOS or by extension Vision Pro. You lose the Xcode connect once in immersive mode. So if stuck at a breakpoint, then you don't know about it. And the display isn't high enough res to read the laptop, but the virtual display is sided up enough that it works.
Note that clickthrough to errors/warnings in .cpp files are fine. The clickthrough breaks when the error/warning is found in a header file.