Post

Replies

Boosts

Views

Activity

Reply to Making the macOS sidebar visible again
have you tried using NavigationSplitView. The code below puts a disclosure button in the toolbar area (on the right, close to the traffic light buttons), and a hide/show menu item in the menu bar, as appropriate. No need to mention the toolbar button explicitly. struct ContentView: View { var body: some View { NavigationSplitView { SidebarView() } detail: { DetailView() } } } struct SidebarView: View { var body: some View { Text("sidebar") } } struct DetailView: View { var body: some View { Text("detail") } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Reply to How to get realtime headphone levels in decibel unit
dB relative to what? If you're interested in the SPL the user experiences, that's going to depend on the headphone sensitivity. Even the delivered power isn't very helpful: https://developer.apple.com/documentation/avfoundation/avcaptureaudiochannel/1387368-averagepowerlevel says "averagePowerLevel The instantaneous average power level in decibels." How a measurement can be both average (implying a series of measurements over time) and instantaneous is baffling to me, while a measurement in decibels without a reference power level is also, let's just say non ideal.
Topic: Media Technologies SubTopic: Audio Tags:
Apr ’24
Reply to Animates wrongly at every switch of direction, animates right in same direction
SwiftUI remembers the "old" view in order to perform a transition to the "new" view. When you reverse direction, the outgoing view is still associated with a transition going in the (now) wrong direction. My fix is to immediately change the direction when you press the button. This causes body() to be re-invoked, but no transition is visible because the view ID of the question has not changed. Subsequently, a Task alters the view ID, which causes a transition from the old question (now associated with a removal transition in the new direction) to the new question. I think this solution smells a little, because it is imperatively driving the UI, and because I have no idea when the Task closures will actually be invoked. No doubt after the Button's action closure, but are they guaranteed to be invoked before any subsequent UI action? I don't know. I changed QuizView to ContentView to get it to compile in my test app. import SwiftUI struct Question { let id: Int let text: String } extension AnyTransition { static var slideRight: AnyTransition { let insertion = AnyTransition.move(edge: .trailing) let removal = AnyTransition.move(edge: .leading) return .asymmetric(insertion: insertion, removal: removal) } static var slideLeft: AnyTransition { let insertion = AnyTransition.move(edge: .leading) let removal = AnyTransition.move(edge: .trailing) return .asymmetric(insertion: insertion, removal: removal) } } struct ContentView: View { let questions = [ Question(id: 1, text: "11111111111"), Question(id: 2, text: "222222222222222222222222"), Question(id: 3, text: "3333333333333333333"), Question(id: 4, text: "444444444444444444444444"), Question(id: 5, text: "55555555555555555555"), Question(id: 6, text: "6666666666666666666666666") ] @State private var currentQuestionIndex = 0 @State private var navigationDirection: NavigationDirection = .forward var body: some View { VStack(spacing: 20) { Text(questions[currentQuestionIndex].text) .id(questions[currentQuestionIndex].id) // Important for transition .transition(navigationDirection == .forward ? .slideRight : .slideLeft) .frame(maxWidth: .infinity, maxHeight: .infinity) HStack { Button("Previous") { moveToPreviousQuestion() } .disabled(currentQuestionIndex == 0) Spacer() Button("Next") { moveToNextQuestion() } .disabled(currentQuestionIndex == questions.count - 1) } } .padding() .animation(.easeInOut(duration: 1.0), value: currentQuestionIndex) } private func moveToNextQuestion() { if currentQuestionIndex < questions.count - 1 { if navigationDirection == .backward { navigationDirection = .forward } Task { currentQuestionIndex += 1 } } } private func moveToPreviousQuestion() { if currentQuestionIndex > 0 { if navigationDirection == .forward { navigationDirection = .backward } Task { currentQuestionIndex -= 1 } } } } enum NavigationDirection { case forward, backward }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Reply to Can't receive notification from Camera Extension(Swift) to observer application (obj-c++)
I use CMIOObjectAddPropertyListener for this kind of communication (of state changes from the extension to an app). That said, I'm surprised at this line [mObserverClassInstance subscribe:@(notification.c_str())]; because I thought @ could only be used with string literals, so you could write [mObserverClassInstance subscribe:@"VirtualCamUsageChanged"]; I've never seen @ used with a run-time expression.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’24
Reply to USB HID Specifics for Mac OS?
how exactly do you determine that the joystick "does not work" on macOS? Joysticks are not directly supported by the OS, you need to have code that specifically looks for input from HID joysticks. Do you have such code? There's an old project on GitHub https://github.com/arsdraconis/HID-Explorer which needs a few changes to compile on modern macOS, but you may be able to use this to get more insights into how your device is treated by the OS. Also, see this post on Stack Overflow: https://stackoverflow.com/questions/41715074/simple-hid-osx-application, which refers to the open source parts of IOHIDFamily.
Topic: Graphics & Games SubTopic: GameKit Tags:
Mar ’24
Reply to Making the macOS sidebar visible again
have you tried using NavigationSplitView. The code below puts a disclosure button in the toolbar area (on the right, close to the traffic light buttons), and a hide/show menu item in the menu bar, as appropriate. No need to mention the toolbar button explicitly. struct ContentView: View { var body: some View { NavigationSplitView { SidebarView() } detail: { DetailView() } } } struct SidebarView: View { var body: some View { Text("sidebar") } } struct DetailView: View { var body: some View { Text("detail") } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Ambiguous "Apple Developer" certificate for macOS
and, of course after spending a day mired in awk, grep, sed and zsh minutiae, I find there's a EXPANDED_CODE_SIGN_IDENTITY and EXPANDED_CODE_SIGN_IDENTITY_NAME, which seems to be the SHA-1 hash and full name of the certificate which Xcode would choose, following its internal algorithm.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Select directory in SwiftUI file importer
Use .folder instead of .directory and your Open button will be there.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Select directory in SwiftUI file importer
Your code works as I'd expect on macOS. Are you running on a real device or a simulator?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to How to get realtime headphone levels in decibel unit
dB relative to what? If you're interested in the SPL the user experiences, that's going to depend on the headphone sensitivity. Even the delivered power isn't very helpful: https://developer.apple.com/documentation/avfoundation/avcaptureaudiochannel/1387368-averagepowerlevel says "averagePowerLevel The instantaneous average power level in decibels." How a measurement can be both average (implying a series of measurements over time) and instantaneous is baffling to me, while a measurement in decibels without a reference power level is also, let's just say non ideal.
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Responsive Design Mode - Devices
Hi. This forum is for developers to help other developers, it isn't a communication channel to Apple. If you've got an enhancement request, send it to Apple using Feedback Assistant. There's no guarantee that anyone from Apple will even see your post here.
Replies
Boosts
Views
Activity
Apr ’24
Reply to self created Macos app cannot open
https://support.apple.com/guide/security/app-code-signing-process-sec3ad8e6e53/web https://developer.apple.com/documentation/xcode/creating-distribution-signed-code-for-the-mac You need a paid Apple developer account to distribute software to someone other than yourself.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Animates wrongly at every switch of direction, animates right in same direction
SwiftUI remembers the "old" view in order to perform a transition to the "new" view. When you reverse direction, the outgoing view is still associated with a transition going in the (now) wrong direction. My fix is to immediately change the direction when you press the button. This causes body() to be re-invoked, but no transition is visible because the view ID of the question has not changed. Subsequently, a Task alters the view ID, which causes a transition from the old question (now associated with a removal transition in the new direction) to the new question. I think this solution smells a little, because it is imperatively driving the UI, and because I have no idea when the Task closures will actually be invoked. No doubt after the Button's action closure, but are they guaranteed to be invoked before any subsequent UI action? I don't know. I changed QuizView to ContentView to get it to compile in my test app. import SwiftUI struct Question { let id: Int let text: String } extension AnyTransition { static var slideRight: AnyTransition { let insertion = AnyTransition.move(edge: .trailing) let removal = AnyTransition.move(edge: .leading) return .asymmetric(insertion: insertion, removal: removal) } static var slideLeft: AnyTransition { let insertion = AnyTransition.move(edge: .leading) let removal = AnyTransition.move(edge: .trailing) return .asymmetric(insertion: insertion, removal: removal) } } struct ContentView: View { let questions = [ Question(id: 1, text: "11111111111"), Question(id: 2, text: "222222222222222222222222"), Question(id: 3, text: "3333333333333333333"), Question(id: 4, text: "444444444444444444444444"), Question(id: 5, text: "55555555555555555555"), Question(id: 6, text: "6666666666666666666666666") ] @State private var currentQuestionIndex = 0 @State private var navigationDirection: NavigationDirection = .forward var body: some View { VStack(spacing: 20) { Text(questions[currentQuestionIndex].text) .id(questions[currentQuestionIndex].id) // Important for transition .transition(navigationDirection == .forward ? .slideRight : .slideLeft) .frame(maxWidth: .infinity, maxHeight: .infinity) HStack { Button("Previous") { moveToPreviousQuestion() } .disabled(currentQuestionIndex == 0) Spacer() Button("Next") { moveToNextQuestion() } .disabled(currentQuestionIndex == questions.count - 1) } } .padding() .animation(.easeInOut(duration: 1.0), value: currentQuestionIndex) } private func moveToNextQuestion() { if currentQuestionIndex < questions.count - 1 { if navigationDirection == .backward { navigationDirection = .forward } Task { currentQuestionIndex += 1 } } } private func moveToPreviousQuestion() { if currentQuestionIndex > 0 { if navigationDirection == .forward { navigationDirection = .backward } Task { currentQuestionIndex -= 1 } } } } enum NavigationDirection { case forward, backward }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to wot WHAT is what? Unexpected CoreAudio get property errors/behaviors
I can reproduce your results on macOS 14.3.1 (on Apple Silicon). I don't know what 'WHAT' means either, can't find it in any headers. If I were you, I'd just file a bug and move on. Any error fetching a channel name means it doesn't have a name.
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to How do I see all the feedback entries submitted by myself?
in the Feedback Assistant app, there's a filter.
Replies
Boosts
Views
Activity
Mar ’24
Reply to How to send PTP commands to a camera like monitor+
It sounds like you want something like IOUSBLib, but for iOS/iPadOS. I want that too. You can write a camera extension, but only for cameras that you own (your company has the USB vendor ID). The dext will only load on devices with an M1 or M2 processor. If you would like something like IOUSBLib for iOS, please file a feature request.
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Can't receive notification from Camera Extension(Swift) to observer application (obj-c++)
I use CMIOObjectAddPropertyListener for this kind of communication (of state changes from the extension to an app). That said, I'm surprised at this line [mObserverClassInstance subscribe:@(notification.c_str())]; because I thought @ could only be used with string literals, so you could write [mObserverClassInstance subscribe:@"VirtualCamUsageChanged"]; I've never seen @ used with a run-time expression.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Xcode Managed Provisioning Profile
It is a provisioning profile for the app, not for the device the app runs on. The profile ends up embedded in your app (in the bundle, in a .embeddedprovisionprofile file).
Replies
Boosts
Views
Activity
Mar ’24
Reply to USB HID Specifics for Mac OS?
how exactly do you determine that the joystick "does not work" on macOS? Joysticks are not directly supported by the OS, you need to have code that specifically looks for input from HID joysticks. Do you have such code? There's an old project on GitHub https://github.com/arsdraconis/HID-Explorer which needs a few changes to compile on modern macOS, but you may be able to use this to get more insights into how your device is treated by the OS. Also, see this post on Stack Overflow: https://stackoverflow.com/questions/41715074/simple-hid-osx-application, which refers to the open source parts of IOHIDFamily.
Topic: Graphics & Games SubTopic: GameKit Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to I searched for MFi's authentication information, but did not specify the need to add an MFI chip to the USB-C interface. Have you resolved the communication issue between the APP and external USBC?
Could you rephrase your question? What communication issue are you referring to? How does MFi play into this (there is a separate section of the forum for MFi-related questions). What exactly do you need help with?
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Mar ’24