Hello,
on Mac OS, is it possible to see a virtual Camera, such as OBS (https://obsproject.com) as a CaptureDevice?
I see that, for example, Google Chrome can use this camera, but using AVCaptureDevice.DiscoverySession I am unable to see it.
Am I doing wrong?
var deviceTypes: [AVCaptureDevice.DeviceType] = [.builtInMicrophone, .builtInWideAngleCamera]
#if os(OSX)
deviceTypes.append(.externalUnknown)
#else
deviceTypes.append(contentsOf: [.builtInDualCamera, .builtInDualWideCamera, .builtInTelephotoCamera, .builtInTripleCamera, .builtInTrueDepthCamera, .builtInUltraWideCamera])
#endif
let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: deviceTypes,
mediaType: nil, position: .unspecified)
result = discoverySession.devices.map { device in
device.localizedName
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Building my app with Xcode 13, a dependency threw an error related to the changes in CoreBluetooth: Some properties are now returned as optionals in iOS 15.
Wanting to fix that, I would like to make sure that the library will run on both iOS 15 and SDKs prior to that, but the current availability markers will not help me:
func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) {
let peripheral: CBPeripheral
// So what I would like is something like this
// But this does not work :(
if #available(iOS 15, *) {
guard let nonOptional = service.peripheral else {
return
}
peripheral = nonOptional
} else {
peripheral = service.peripheral
}
let result: CBPeripheral = peripheral
print ("\(result)")
}```
This code will cause the compiler to throw an error both on Xcode 13 and Xcode 12.
Is there any good way to solve this?
I would like to declare an @EnvironmentObject as a protocol, namely as
protocol AccessTokenProvider: Authenticator {
func accessToken() - AccessTokenPublisher
}
where Authenticator is
public class Authenticator: NSObject, ObservableObject
However, when I add this to the environment as
var authenticator: AccessTokenProvider = MyAuthenticator()
[…]
ContentView().environmentObject(authenticator)
the compiler throws an error at:
struct ContentView: View {
// error: property type 'AccessTokenProvider' does not match that of the 'wrappedValue' property of its wrapper type 'EnvironmentObject'
@EnvironmentObject var authenticator: AccessTokenProvider
^
Is this even a good idea? If so, what am I doing wrong?
^
Context: Authorized Network requests.
I have a process (a publisher, to be precise), which will give me a fresh access token for a request.
To do that, I may need user interaction, i.e. show a View, Alert, or something like that.
How can I do that in SwiftUI? Can I just (modally) display something, without explicitly being in a View body? Should I have to pass in a "superview" to do this, or do you have other ideas?
Thanks
Alex