This is a pretty broad question and I only dimly remember ever encountering this, but here I go:
I knew there was something specific about that and after a bit of digging I found it again. For connected devices to become visible you have to explicitly opt-in to them being considered sources for your app using CoreMediaIO. Basically somewhere in your app you have to include this snippet of code:
var prop = CMIOObjectPropertyAddress(
mSelector: CMIOObjectPropertySelector(kCMIOHardwarePropertyAllowScreenCaptureDevices),
mScope: CMIOObjectPropertyScope(kCMIOObjectPropertyScopeGlobal),
mElement: CMIOObjectPropertyElement(kCMIOObjectPropertyElementMain))
var allow: UInt32 = 1;
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &prop, 0, nil,
UInt32(MemoryLayout.size(ofValue: allow)), &allow)
You can then get a capture device using AVCaptureDevice.default(for: .muxed) (from the AVFoundation module) and use that to create an input for an AVCaptureSession using AVCaptureDeviceInput(device:).
I have only ever played around with this and never bothered with properly taking care about multiple connected devices and such, so I have no advice on how to best handle this.
Be aware that it takes a moment for the devices to show up after you execute the snippet above, so you might want to listen for AVCaptureSessionDidStartRunningNotification to wait before you create the device variable.
While jostling my memory I also stumbled upon this repo which seems to have a bare-bones (hopefully) running example, but it's not mine: https://github.com/mortenjust/Device-Recording-Bug-Demo (plus it seems to exist to illustrate some bug, but I don't know what that would be).
Post
Replies
Boosts
Views
Activity
I have the same issue, although for me it does not pose a problem as it is only affecting tests and those warnings don't actually result in errors down the line (i.e. the code is actually not relying on anything iOS 8.0 specific).
In short: You are correct in your assumption that the problem lies with a dependency further down the line. That means you cannot do much yourself, I believe, as the swift package manager has no means of manipulating that dependency and its settings. In cocoapods you can do that with a snippet similar to the one that utyyyreee posted (without any context... and a typo in lines 4 and 5, where it should say 9.0 and not 8.0... and that only if you want to set it arbitrarily to 9.0...).
That would go into your podfile to manage the project's pod dependencies. Sadly, since it happens in a dependency you yourself only include via the swift package manager, you cannot do it yourself but have to approach the owner of that dependency to make the necessary changes. Or you wait until the underlying dependencies get updated accordingly on their own.
See also this article here for an explanation (no idea why the forum won't let me properly link it, sorry):
https://www.jessesquires.com/blog/2020/07/20/xcode-12-drops-support-for-ios-8-fix-for-cocoapods/
Lastly, I assume the pod thing won't help you at all, as the swift package manager probably circumvents that completely (unless they do some weird shenanigans).
After all, the code is not included via pods, but packages.
I, for example, use Telegraph and that simply has the .iOS(.v8) platform defined in its Package.swift file. I will probably contact the author and/or fork the repo to get that to be updated. I don't know whether that then also incrementally updates any dependencies further down the line or whether they also have to be updated in their respective Package.swift files...
I was wondering about this, too, and would also be interested in how this could, in theory, be solved. I say "in theory", because in practice it is probably a bad idea to have reference types as properties inside value types in the first place.
My guess is that there's really no way as a struct does not provide a deinit method, is that right?
That being said, does the example as given compile in Swift 5.3? I didn't have the chance to set up a test environment for me yet (sorry), but under 5.2 (where I use an explicit self. of course) this throws a
Escaping closure captures mutating 'self' parameter for me anyway. I'm having a hard time constructing an example for such a retain cycle on the top of my head, what am I overlooking? Hm...