在Info.plist文件中,新建一个键值对Privacy - Camera Usage Description(或者NSCameraUsageDescription),值为申请描述说明,自定义的
然后在需要申请的文件中导入AVFoundation
import AVFoundation
然后进行申请即可:
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: {
finished in
print(finished.description)
})