I made CameraExtension and installed by OSSystemExtensionRequest.
I got success callback. I did uninstall old version of my CameraExtension and install new version of my CameraExtension.
"systemextensionsctl list" command shows "[activated enabled]" on my new version.
But no daemon process with my CameraExtension is not running. I need to reboot OS to start the daemon process. This issue is new at macOS Sonoma 14.5. I did not see this issue on 14.4.x
Post
Replies
Boosts
Views
Activity
I am working on ScreenCaptureKit sample with SCContentSharingPickerObserver.
My Target is SwiftUI based and calling Objective-C class method. I added [MyTarget]-Bridging.h and [MyTarget]-Swift.h
I got compile error of unknown class name SCContentSharingPickerObserver in [MyTarget]-Swift.h. But I do not know how to fix this error since [MyTarget]-Swift.h is Xcode generated file.
I set macOS target is 14.0, swift language ver is 5
Anyone know how to fix this error or waiting for Xcode update?
I have old ScreenCaptureKit sample downloaded on Oct 2022.
That sample worked on Oct 2022. But it does not work on Apr 2024 on Sonoma 14.4.1 M1 MacBook. It only shows black screen.
I also download updated ScreenCaptureKit sample and test it. It works on Sonoma 14.4.1 M1 MacBook. I noticed latest sample have SCContentSharingPicker and other changes.
I have my screen capture application based on old ScreenCaptureKit sample. My app only shows black screen.
Do I have to add SCContentSharingPicker and SCContentSharingPickerObserver on my application for capturing screen on Sonoma?
Old way of screen capture without SCContentSharingPicker is not supported anymore on Sonoma?
If I do these tasks on random order, CMIO CameraExtension go into unstable condition.
Copy MyApp.app under /Applications or /Applications/MyAppGroup/
Install by MyApp sending OSSystemExtensionRequest.activationRequest
Check install condition by command : "systemextensionsctl list"
uninstall by MyApp sending OSSystemExtensionRequest.deactivationRequest
Remove /Applications/MyAppGroup/ by command line and Finder
Remove /Applications/MyApp.app by command line and Finder
Kill MyApp.app during activationRequest.
Once my CMIO CameraExtension go into unstable condition, it is impossible to remove on normal way.
"systemextensionsctl list" shows my extension is activated.
Remove by API failed with code=4.
Removing file of MyApp.app does not remove CameraExtension
Only way to remove CameraExtension is "Boot macOS as recovery mode", disable SIP, "systemextensionsctl uninstall"
Audio HAL extension is file based and ATOMIC. I can check file existence by "ls" command and remove by "rm -rf" command. I never met unstable condition.
When my macOS app try to deactivate CameraExtension, my app's didFailWithError is called with this error.
Error Domain=OSSystemExtensionErrorDomain Code=4 "(null)"
I cannot search for error code=4 with that domain.
MyApp calls OSSystemExtensionManager.shared.submitRequest with OSSystemExtensionRequest.deactivationRequest
I did implement these tasks.
BundleID, MyApp: com.myapp,
BundleID, CameraExtension: com.myapp.camera
Added entitlement and App Groups for app and extension
MyApp has SystemExtension capability on Xcode and provision
MyApp is installed on /Applications/MyAppGroup/MyApp.app
MyApp is executed by Finder
macOS is Sonoma 14.2.1 (23C71) on M1 MacBook
I need to write macOS App, CameraExtension(CMIO) and Uninstaller app.
Bundle ID is like this
App : com.my.app
CameraExtension : com.my.app.cameraex
Uninstaller app : com.my.app.unisntaller
My App can activate CameraExtension by OSSystemExtensionRequest.activationRequest.
But Uninstaller cannot deactivate CameraExtension.
I got error : Error Domain=OSSystemExtensionErrorDomain Code=4 "Extension not found in App bundle: perhaps App is not validly structured"
I set AppGroup and add SystemExtension feature and provision for uninstaller.
I guess "com.my.app.unisntaller" cannot deactivate "com.my.app.cameraex".
What kind of Bundle ID should I use for my uninstaller?
Writing App and Uninstaller is correct way for CameraExtension?
My manager ask to provide easy method for removing all modules.
I got code of CMIO CameraExtension by Xcode target and it is running with FaceTime. I guess this kind of Extension has lots of security limitation.
I like to run command like "netstat" in Extension. Is that possible to call Process.run()? I got keep getting error like "The file zsh doesn’t exist". Same code with Process.run() worked in macOS app.
I like to run DistributedNotificationCenter and send text from App to CameraExtension. Is that possible? I do not receive any message on CameraExtension.
If there is any other IPC method between macOS app and CameraExtension, please let me know.
I made s target of "Camera Extension" on Xcode macOS Swift app.
I got Swift code with CMIOExtensionDeviceSource.
I add NSLog() and String.write() to file under FileManager.default.temporaryDirectory.
My camera extension installaion was success and running with FaceTime.
But I cannot see NSLog output or debug output temp file on Xcode or Console.
How can I see debug output from my Camera Extension?
I had 2 crash report from our customer. Both crash point is same but there is no my code on crash stack trace. How to fix this kind of crash problem.
Thread 1 Crashed:: Dispatch queue: com.apple.root.background-qos
0 libsystem_kernel.dylib 0x7ff81b84922a __pthread_kill + 10
1 libsystem_pthread.dylib 0x7ff81b880f7b pthread_kill + 263
2 libsystem_c.dylib 0x7ff81b7caca5 abort + 123
3 libc++abi.dylib 0x7ff81b83b082 abort_message + 241
4 libc++abi.dylib 0x7ff81b82c23d demangling_terminate_handler() + 266
5 libobjc.A.dylib 0x7ff81b529023 _objc_terminate() + 96
6 libc++abi.dylib 0x7ff81b83a4a5 std::__terminate(void (*)()) + 8
7 libc++abi.dylib 0x7ff81b83a456 std::terminate() + 54
8 libdispatch.dylib 0x7ff81b701a58 _dispatch_client_callout + 28
9 libdispatch.dylib 0x7ff81b704500 _dispatch_continuation_pop + 463
10 libdispatch.dylib 0x7ff81b715dff _dispatch_source_invoke + 2184
11 libdispatch.dylib 0x7ff81b7116a2 _dispatch_root_queue_drain + 343
12 libdispatch.dylib 0x7ff81b711e4d _dispatch_worker_thread2 + 160
13 libsystem_pthread.dylib 0x7ff81b87dc9d _pthread_wqthread + 256
14 libsystem_pthread.dylib 0x7ff81b87cc67 start_wqthread + 15
This crash point is exactly same with this post. I do not throw C++ exception.
https://developer.apple.com/forums/thread/725197
I like to know NullAudio.c is official SDK sample or not.
And the reason of enum and UID is defined in NullAudio.c, not defined in SDK header files.
I try to use kObjectID_Mute_Output_Master, but it defined different values on each 3rd party plugin.
kObjectID_Mute_Output_Master = 10 // NullAudio.c
kObjectID_Mute_Output_Master = 9 // https://github.com/ExistentialAudio/BlackHole
kObjectID_Mute_Output_Master = 6 // https://github.com/q-p/SoundPusher
I can build BlackHole and SoundPusher, these plugin worked.
This enum should be defined SDK header and keep same value on each SDK version.
I like to know why 3rd party defined different value.
If you know the history of NullAudio.c, please let me know.
I write macOS menu app with TextField by SwiftUI on Japanese Input mode. On some conditions, the TextFiled lost focus, no key input, no mouse click. User cannot do anything.
Setup
MacOS Ventura 13.3.1 (a)
Install Japanese Romaji Input source by System Preferences -> Keyboard
Set input mode as "Romaji"
Build test source code
On Xcode 14.3, create new macOS app project "FocusTest" with SwiftUI, Swift.
Replace FocusTestApp.swift with attached code.
Build on Xcode
Steps
Set input mode as "Romaji"
Run FocusTestApp
Click T square icon on top menu
Small windows with globe appear
Click Desktop background area
Click T square icon on top menu
Click PIN
T with PIN textField View appear
That textField lost focus, click inside of textField
Key or click is not accepted.
With US keyboard mode, key input become possible on Step 10. But Focused blue square is missing.
Code of FocusTestApp.swift
import SwiftUI
@main
struct focusTestApp: App {
var body: some Scene {
MenuBarExtra("Test", systemImage: "t.square") {
MainView()
}.menuBarExtraStyle(.window)
}
}
struct MainView: View {
@State private var showingPIN: Bool = false
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Button("PIN") {
print("clicked")
showingPIN = true
}
}
.padding()
.sheet(isPresented: $showingPIN) {
PinView()
}
}
}
struct PinView: View {
@Environment(\.presentationMode) var presentationMode
@State private var pin: String = ""
@FocusState private var pinIsFocused: Bool
var body: some View {
VStack {
Image(systemName: "t.square")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 64.0, height: 64.0)
.foregroundColor(.accentColor)
Text("Enter PIN code")
HStack {
TextField("", text: $pin)
.font(Font.system(size: 28, design: .default))
.frame(width:4*28.0, height:28.0)
.focusable()
.focused($pinIsFocused)
}
.onAppear(){
pinIsFocused = true
}
}
.padding()
}
}
I need to develop Emergency communication app. This app is not used frequently but it need to start immediately when user need to make emergency communication.
If this app is not used for a month, it uninstalled by "Offload unused apps" feature. Is there way to put a flag into app to prevent uninstall?
If application's Info.plist has setting like "Preventing offloading unused apps", it would be great to me.
I use VideoToolbox HW h.264 encoder with M1 MacBook for screen mirroring. I need run encoder with minimal delay mode.
I use these values as encoderSpecification
kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder:true
kVTCompressionPropertyKey_ProfileLevel:kVTProfileLevel_H264_Baseline_AutoLevel
kVTCompressionPropertyKey_RealTime:true
kVTCompressionPropertyKey_AllowFrameReordering:false
I set presentation timestamp with current time.
In compressed callback, I got encoded frame with wrong order.
[13.930533]encode pts=...13.930511
[13.997633]encode pts=...13.997617
[14.013678]compress callback with pts=...13.997617 dts=...13.930511
[14.023443]compress callback with pts=...13.930511 dts=...13.997617
in[]:log time,
pts:presentation timestamp,
dts:decode timestamp
AllowFrameReordering is not working as I expected.
If I need to set other property, please let me know.
I also does not like buffering 2 video frames. If you know settings for no buffering frame, please let me know.
I try to get AVCaptureDevice instance of a virtual audio plugin, like blackhole.
I need to call AVCaptureDevice.DiscoverySession, because old method (AVCaptureDevice.devicesWithMediaType) is deprecated.
First, I cannot find enum for virtual audio plugin. I try .externalUnknown or .builtInMicrophone. Both result is empty.
I like to know how to list virtual microphone and get AVCaptureDevice instance.
let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(
deviceTypes: [ .externalUnknown ],
mediaType: .audio,
position: .unspecified
)
let devs = deviceDiscoverySession.devices
print("devices=\(devs)") // empty list
I try to run ScreenCaptureKit sample code.
That sample require macOS 13.0 for audio capture.
When I run, the app shows with "No screen recording permission".
I grant Screen Recording permission on System Settings -> Privacy & Security.
But same error happens. I cannot find a way to grant the permission.
I tried restart app, restart Xcode, reboot macOS and
rm -rf ~/Library/Developer/Xcode/DerivedData/CaptureSample-...
This sample app worked after comment out "streamConfig.capturesAudio" and related code on Monterey. This permission issue did not happen on Monterey.
Env:
macOS Ventura 13.0,
Xcode 14.1(14B47b)
Sample code URL : https://developer.apple.com/documentation/screencapturekit/capturing_screen_content_in_macos?language=objc