Skip to content

Translation into Swift Concurrency model #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: xcode-12-2-beta-3
Choose a base branch
from
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions iOS/ARKit/ARConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,7 @@ class ARGeoTrackingConfiguration : ARConfiguration {
var maximumNumberOfTrackedImages: Int
var detectionObjects: Set<ARReferenceObject>
class func checkAvailability(completionHandler: @escaping (Bool, Error?) -> Void)
class func checkAvailability() async throws -> Bool
class func checkAvailability(at coordinate: CLLocationCoordinate2D, completionHandler: @escaping (Bool, Error?) -> Void)
class func checkAvailability(at coordinate: CLLocationCoordinate2D) async throws -> Bool
}
2 changes: 2 additions & 0 deletions iOS/ARKit/ARReferenceImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class ARReferenceImage : NSObject {
var resourceGroupName: String? { get }
@available(iOS 13.0, *)
func validate(completionHandler: @escaping (Error?) -> Void)
@available(iOS 13.0, *)
func validate() async throws
init(_ image: CGImage, orientation: CGImagePropertyOrientation, physicalWidth: CGFloat)
init(_ pixelBuffer: CVPixelBuffer, orientation: CGImagePropertyOrientation, physicalWidth: CGFloat)
class func referenceImages(inGroupNamed name: String, bundle: Bundle?) -> Set<ARReferenceImage>?
Expand Down
6 changes: 6 additions & 0 deletions iOS/ARKit/ARSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class ARSession : NSObject {
@available(iOS 12.0, *)
func getCurrentWorldMap(completionHandler: @escaping (ARWorldMap?, Error?) -> Void)
@available(iOS 12.0, *)
func currentWorldMap() async throws -> ARWorldMap
@available(iOS 12.0, *)
func createReferenceObject(transform: simd_float4x4, center: simd_float3, extent: simd_float3, completionHandler: @escaping (ARReferenceObject?, Error?) -> Void)
@available(iOS 12.0, *)
func createReferenceObject(transform: simd_float4x4, center: simd_float3, extent: simd_float3) async throws -> ARReferenceObject
@available(iOS 13.0, *)
func raycast(_ query: ARRaycastQuery) -> [ARRaycastResult]
@available(iOS 13.0, *)
Expand All @@ -36,6 +40,8 @@ class ARSession : NSObject {
func update(with collaborationData: ARSession.CollaborationData)
@available(iOS 14.0, *)
func getGeoLocation(forPoint position: simd_float3, completionHandler: @escaping (CLLocationCoordinate2D, CLLocationDistance, Error?) -> Void)
@available(iOS 14.0, *)
func geoLocation(forPoint position: simd_float3) async throws -> (CLLocationCoordinate2D, CLLocationDistance)
}
@available(iOS 11.0, *)
protocol ARSessionObserver : NSObjectProtocol {
Expand Down
9 changes: 9 additions & 0 deletions iOS/AVFoundation/AVAssetExportSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AVAssetExportSession : NSObject {
var status: AVAssetExportSession.Status { get }
var error: Error? { get }
func exportAsynchronously(completionHandler handler: @escaping () -> Void)
func export() async
var progress: Float { get }
func cancelExport()
}
Expand All @@ -63,11 +64,15 @@ extension AVAssetExportSession {
class func exportPresets(compatibleWith asset: AVAsset) -> [String]
@available(iOS 6.0, *)
class func determineCompatibility(ofExportPreset presetName: String, with asset: AVAsset, outputFileType: AVFileType?, completionHandler handler: @escaping (Bool) -> Void)
@available(iOS 6.0, *)
class func determineCompatibility(ofExportPreset presetName: String, with asset: AVAsset, outputFileType: AVFileType?) async -> Bool
}
extension AVAssetExportSession {
var supportedFileTypes: [AVFileType] { get }
@available(iOS 6.0, *)
func determineCompatibleFileTypes(completionHandler handler: @escaping ([AVFileType]) -> Void)
@available(iOS 6.0, *)
func determineCompatibleFileTypes() async -> [AVFileType]
}
extension AVAssetExportSession {
var timeRange: CMTimeRange
Expand All @@ -80,7 +85,11 @@ extension AVAssetExportSession {
@available(iOS 13.0, *)
func estimateMaximumDuration(completionHandler handler: @escaping (CMTime, Error?) -> Void)
@available(iOS 13.0, *)
func estimateMaximumDuration() async throws -> CMTime
@available(iOS 13.0, *)
func estimateOutputFileLength(completionHandler handler: @escaping (Int64, Error?) -> Void)
@available(iOS 13.0, *)
func estimateOutputFileLength() async throws -> Int64
}
extension AVAssetExportSession {
var metadata: [AVMetadataItem]?
Expand Down
1 change: 1 addition & 0 deletions iOS/AVFoundation/AVAssetImageGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AVAssetImageGenerator : NSObject {
init(asset: AVAsset)
func copyCGImage(at requestedTime: CMTime, actualTime: UnsafeMutablePointer<CMTime>?) throws -> CGImage
func generateCGImagesAsynchronously(forTimes requestedTimes: [NSValue], completionHandler handler: @escaping AVAssetImageGeneratorCompletionHandler)
func generateCGImages(forTimes requestedTimes: [NSValue]) async throws -> (CMTime, CGImage, CMTime, AVAssetImageGenerator.Result)
func cancelAllCGImageGeneration()
}
typealias AVAssetImageGeneratorCompletionHandler = (CMTime, CGImage?, CMTime, AVAssetImageGenerator.Result, Error?) -> Void
2 changes: 2 additions & 0 deletions iOS/AVFoundation/AVAssetWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AVAssetWriter : NSObject {
func cancelWriting()
@available(iOS 6.0, *)
func finishWriting(completionHandler handler: @escaping () -> Void)
@available(iOS 6.0, *)
func finishWriting() async
}
extension AVAssetWriter {
var movieFragmentInterval: CMTime
Expand Down
1 change: 1 addition & 0 deletions iOS/AVFoundation/AVAsynchronousKeyValueLoading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ enum AVKeyValueStatus : Int {
protocol AVAsynchronousKeyValueLoading {
func statusOfValue(forKey key: String, error outError: NSErrorPointer) -> AVKeyValueStatus
func loadValuesAsynchronously(forKeys keys: [String], completionHandler handler: (() -> Void)? = nil)
func loadValues(forKeys keys: [String]) async
}
10 changes: 10 additions & 0 deletions iOS/AVFoundation/AVCaptureDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ extension AVCaptureDevice {
var lensPosition: Float { get }
@available(iOS 8.0, *)
func setFocusModeLocked(lensPosition: Float, completionHandler handler: ((CMTime) -> Void)? = nil)
@available(iOS 8.0, *)
func setFocusModeLocked(lensPosition: Float) async -> CMTime
}
extension AVCaptureDevice {
func isExposureModeSupported(_ exposureMode: AVCaptureDevice.ExposureMode) -> Bool
Expand All @@ -288,6 +290,8 @@ extension AVCaptureDevice {
@available(iOS 8.0, *)
func setExposureModeCustom(duration: CMTime, iso ISO: Float, completionHandler handler: ((CMTime) -> Void)? = nil)
@available(iOS 8.0, *)
func setExposureModeCustom(duration: CMTime, iso ISO: Float) async -> CMTime
@available(iOS 8.0, *)
var exposureTargetOffset: Float { get }
@available(iOS 8.0, *)
var exposureTargetBias: Float { get }
Expand All @@ -297,6 +301,8 @@ extension AVCaptureDevice {
var maxExposureTargetBias: Float { get }
@available(iOS 8.0, *)
func setExposureTargetBias(_ bias: Float, completionHandler handler: ((CMTime) -> Void)? = nil)
@available(iOS 8.0, *)
func setExposureTargetBias(_ bias: Float) async -> CMTime
}
extension AVCaptureDevice {
@available(iOS 13.0, *)
Expand All @@ -317,6 +323,8 @@ extension AVCaptureDevice {
@available(iOS 8.0, *)
func setWhiteBalanceModeLocked(with whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains, completionHandler handler: ((CMTime) -> Void)? = nil)
@available(iOS 8.0, *)
func setWhiteBalanceModeLocked(with whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains) async -> CMTime
@available(iOS 8.0, *)
func chromaticityValues(for whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains) -> AVCaptureDevice.WhiteBalanceChromaticityValues
@available(iOS 8.0, *)
func deviceWhiteBalanceGains(for chromaticityValues: AVCaptureDevice.WhiteBalanceChromaticityValues) -> AVCaptureDevice.WhiteBalanceGains
Expand Down Expand Up @@ -363,6 +371,8 @@ extension AVCaptureDevice {
class func authorizationStatus(for mediaType: AVMediaType) -> AVAuthorizationStatus
@available(iOS 7.0, *)
class func requestAccess(for mediaType: AVMediaType, completionHandler handler: @escaping (Bool) -> Void)
@available(iOS 7.0, *)
class func requestAccess(for mediaType: AVMediaType) async -> Bool
}
extension AVCaptureDevice {
}
Expand Down
1 change: 1 addition & 0 deletions iOS/AVFoundation/AVCapturePhotoOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class AVCapturePhotoOutput : AVCaptureOutput {
func capturePhoto(with settings: AVCapturePhotoSettings, delegate: AVCapturePhotoCaptureDelegate)
var preparedPhotoSettingsArray: [AVCapturePhotoSettings] { get }
func setPreparedPhotoSettingsArray(_ preparedPhotoSettingsArray: [AVCapturePhotoSettings], completionHandler: ((Bool, Error?) -> Void)? = nil)
func setPreparedPhotoSettingsArray(_ preparedPhotoSettingsArray: [AVCapturePhotoSettings]) async throws -> Bool
var __availablePhotoPixelFormatTypes: [NSNumber] { get }
var availablePhotoCodecTypes: [AVVideoCodecType] { get }
var __availableRawPhotoPixelFormatTypes: [NSNumber] { get }
Expand Down
5 changes: 5 additions & 0 deletions iOS/AVFoundation/AVCaptureStillImageOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AVCaptureStillImageOutput : AVCaptureOutput {
@available(iOS 5.0, *)
var isCapturingStillImage: Bool { get }
func captureStillImageAsynchronously(from connection: AVCaptureConnection, completionHandler handler: @escaping (CMSampleBuffer?, Error?) -> Void)
func captureStillImage(from connection: AVCaptureConnection) async throws -> CMSampleBuffer
class func jpegStillImageNSDataRepresentation(_ jpegSampleBuffer: CMSampleBuffer) -> Data?
}
@available(iOS 8.0, *)
Expand All @@ -40,6 +41,10 @@ extension AVCaptureStillImageOutput {
var isLensStabilizationDuringBracketedCaptureEnabled: Bool
@available(iOS, introduced: 8.0, deprecated: 10.0, message: "Use AVCapturePhotoOutput setPreparedPhotoSettingsArray:completionHandler: instead.")
func prepareToCaptureStillImageBracket(from connection: AVCaptureConnection, withSettingsArray settings: [AVCaptureBracketedStillImageSettings], completionHandler handler: @escaping (Bool, Error?) -> Void)
@available(iOS, introduced: 8.0, deprecated: 10.0, message: "Use AVCapturePhotoOutput setPreparedPhotoSettingsArray:completionHandler: instead.")
func prepareToCaptureStillImageBracket(from connection: AVCaptureConnection, withSettingsArray settings: [AVCaptureBracketedStillImageSettings]) async throws -> Bool
@available(iOS, introduced: 8.0, deprecated: 10.0, message: "Use AVCapturePhotoOutput capturePhotoWithSettings:delegate: instead.")
func captureStillImageBracketAsynchronously(from connection: AVCaptureConnection, withSettingsArray settings: [AVCaptureBracketedStillImageSettings], completionHandler handler: @escaping (CMSampleBuffer?, AVCaptureBracketedStillImageSettings?, Error?) -> Void)
@available(iOS, introduced: 8.0, deprecated: 10.0, message: "Use AVCapturePhotoOutput capturePhotoWithSettings:delegate: instead.")
func captureStillImageBracket(from connection: AVCaptureConnection, withSettingsArray settings: [AVCaptureBracketedStillImageSettings]) async throws -> (CMSampleBuffer, AVCaptureBracketedStillImageSettings)
}
7 changes: 7 additions & 0 deletions iOS/AVFoundation/AVContentKeySession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ class AVContentKeySession : NSObject {
func renewExpiringResponseData(for contentKeyRequest: AVContentKeyRequest)
@available(iOS 11.0, *)
func makeSecureTokenForExpirationDate(ofPersistableContentKey persistableContentKeyData: Data, completionHandler handler: @escaping (Data?, Error?) -> Void)
@available(iOS 11.0, *)
func makeSecureTokenForExpirationDate(ofPersistableContentKey persistableContentKeyData: Data) async throws -> Data
@available(iOS 12.2, *)
func invalidatePersistableContentKey(_ persistableContentKeyData: Data, options: [AVContentKeySessionServerPlaybackContextOption : Any]? = nil, completionHandler handler: @escaping (Data?, Error?) -> Void)
@available(iOS 12.2, *)
func invalidatePersistableContentKey(_ persistableContentKeyData: Data, options: [AVContentKeySessionServerPlaybackContextOption : Any]? = nil) async throws -> Data
@available(iOS 12.2, *)
func invalidateAllPersistableContentKeys(forApp appIdentifier: Data, options: [AVContentKeySessionServerPlaybackContextOption : Any]? = nil, completionHandler handler: @escaping (Data?, Error?) -> Void)
@available(iOS 12.2, *)
func invalidateAllPersistableContentKeys(forApp appIdentifier: Data, options: [AVContentKeySessionServerPlaybackContextOption : Any]? = nil) async throws -> Data
}
struct AVContentKeySessionServerPlaybackContextOption : _ObjectiveCBridgeable, Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable {
init(rawValue: String)
Expand Down Expand Up @@ -106,6 +112,7 @@ class AVContentKeyRequest : NSObject {
var options: [String : Any] { get }
var canProvidePersistableContentKey: Bool { get }
func makeStreamingContentKeyRequestData(forApp appIdentifier: Data, contentIdentifier: Data?, options: [String : Any]? = nil, completionHandler handler: @escaping (Data?, Error?) -> Void)
func makeStreamingContentKeyRequestData(forApp appIdentifier: Data, contentIdentifier: Data?, options: [String : Any]? = nil) async throws -> Data
func processContentKeyResponse(_ keyResponse: AVContentKeyResponse)
func processContentKeyResponseError(_ error: Error)
@available(iOS, introduced: 10.3, deprecated: 11.2, message: "Use respondByRequestingPersistableContentKeyRequestAndReturnError: instead.")
Expand Down
8 changes: 8 additions & 0 deletions iOS/AVFoundation/AVPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ extension AVPlayer {
func seek(to date: Date)
@available(iOS 5.0, *)
func seek(to date: Date, completionHandler: @escaping (Bool) -> Void)
@available(iOS 5.0, *)
func seek(to date: Date) async -> Bool
func seek(to time: CMTime)
func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)
@available(iOS 5.0, *)
func seek(to time: CMTime, completionHandler: @escaping (Bool) -> Void)
@available(iOS 5.0, *)
func seek(to time: CMTime) async -> Bool
@available(iOS 5.0, *)
func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: @escaping (Bool) -> Void)
@available(iOS 5.0, *)
func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime) async -> Bool
}
extension AVPlayer {
@available(iOS 10.0, *)
Expand All @@ -89,6 +95,8 @@ extension AVPlayer {
@available(iOS 6.0, *)
func preroll(atRate rate: Float, completionHandler: ((Bool) -> Void)? = nil)
@available(iOS 6.0, *)
func preroll(atRate rate: Float) async -> Bool
@available(iOS 6.0, *)
func cancelPendingPrerolls()
@available(iOS 6.0, *)
var masterClock: CMClock?
Expand Down
4 changes: 4 additions & 0 deletions iOS/AVFoundation/AVPlayerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ extension AVPlayerItem {
@available(iOS 5.0, *)
func seek(to time: CMTime, completionHandler: ((Bool) -> Void)? = nil)
@available(iOS 5.0, *)
func seek(to time: CMTime) async -> Bool
@available(iOS 5.0, *)
func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: ((Bool) -> Void)? = nil)
@available(iOS 5.0, *)
func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime) async -> Bool
@available(iOS 5.0, *)
func cancelPendingSeeks()
func currentDate() -> Date?
@available(iOS 6.0, *)
Expand Down
1 change: 1 addition & 0 deletions iOS/AVFoundation/AVSampleBufferAudioRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension AVSampleBufferAudioRenderer {
}
extension AVSampleBufferAudioRenderer {
func flush(fromSourceTime time: CMTime, completionHandler: @escaping (Bool) -> Void)
func flush(fromSourceTime time: CMTime) async -> Bool
}
extension NSNotification.Name {
@available(iOS 11.0, *)
Expand Down
1 change: 1 addition & 0 deletions iOS/AVFoundation/AVSampleBufferRenderSynchronizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extension AVSampleBufferRenderSynchronizer {
var renderers: [AVQueuedSampleBufferRendering] { get }
func addRenderer(_ renderer: AVQueuedSampleBufferRendering)
func removeRenderer(_ renderer: AVQueuedSampleBufferRendering, at time: CMTime, completionHandler: ((Bool) -> Void)? = nil)
func removeRenderer(_ renderer: AVQueuedSampleBufferRendering, at time: CMTime) async -> Bool
}
extension AVSampleBufferRenderSynchronizer {
func addPeriodicTimeObserver(forInterval interval: CMTime, queue: DispatchQueue?, using block: @escaping (CMTime) -> Void) -> Any
Expand Down
1 change: 1 addition & 0 deletions iOS/AVKit/AVPictureInPictureController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ protocol AVPictureInPictureControllerDelegate : NSObjectProtocol {
optional func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
optional func pictureInPictureControllerDidStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController)
optional func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void)
optional func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController) async -> Bool
}
1 change: 1 addition & 0 deletions iOS/AVKit/AVPlaybackRouteSelecting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ extension AVAudioSession {
@available(iOS 13.0, *)
extension AVAudioSession {
func prepareRouteSelectionForPlayback(completionHandler: @escaping (Bool, AVAudioSession.RouteSelection) -> Void)
func prepareRouteSelectionForPlayback() async -> (Bool, AVAudioSession.RouteSelection)
}
2 changes: 2 additions & 0 deletions iOS/AVKit/AVPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ protocol AVPlayerViewControllerDelegate : NSObjectProtocol {
optional func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(_ playerViewController: AVPlayerViewController) -> Bool
@available(iOS 8.0, *)
optional func playerViewController(_ playerViewController: AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void)
@available(iOS 8.0, *)
optional func playerViewControllerRestoreUserInterfaceForPictureInPictureStop(_ playerViewController: AVPlayerViewController) async -> Bool
}
4 changes: 4 additions & 0 deletions iOS/Accounts/ACAccountStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ class ACAccountStore : NSObject {
func accountType(withAccountTypeIdentifier typeIdentifier: String!) -> ACAccountType!
func accounts(with accountType: ACAccountType!) -> [Any]!
func saveAccount(_ account: ACAccount!, withCompletionHandler completionHandler: ACAccountStoreSaveCompletionHandler!)
func saveAccount(_ account: ACAccount!) async throws -> Bool
func requestAccessToAccounts(with accountType: ACAccountType!, options: [AnyHashable : Any]! = [:], completion: ACAccountStoreRequestAccessCompletionHandler!)
func requestAccessToAccounts(with accountType: ACAccountType!, options: [AnyHashable : Any]! = [:]) async throws -> Bool
func renewCredentials(for account: ACAccount!, completion completionHandler: ACAccountStoreCredentialRenewalHandler!)
func renewCredentials(for account: ACAccount!) async throws -> ACAccountCredentialRenewResult
func removeAccount(_ account: ACAccount!, withCompletionHandler completionHandler: ACAccountStoreRemoveCompletionHandler!)
func removeAccount(_ account: ACAccount!) async throws -> Bool
}
extension NSNotification.Name {
@available(iOS, introduced: 5.0, deprecated: 14.0, message: "Public notification deprecated. Internal clients, see private header for replacement")
Expand Down
1 change: 1 addition & 0 deletions iOS/AppTrackingTransparency/AppTrackingTransparency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ extension ATTrackingManager {
class ATTrackingManager : NSObject {
class var trackingAuthorizationStatus: ATTrackingManager.AuthorizationStatus { get }
class func requestTrackingAuthorization(completionHandler completion: @escaping (ATTrackingManager.AuthorizationStatus) -> Void)
class func requestTrackingAuthorization() async -> ATTrackingManager.AuthorizationStatus
}
var AppTrackingTransparencyVersionNumber: Double
Loading