Anthony Kong
Anthony Kong

Reputation: 40844

How to find out which version of API is available for a certain OSX version?

I want to retrieve some meta data of a photo asset in the Photo library. Basically the name, type and location of it. I want to implement it as a command line utility in Swift.

Here is the code I have come up with

var allPhotos : PHFetchResult<PHAsset>? = nil
let fetchOptions = PHFetchOptions()
allPhotos = PHAsset.fetchAssets(with: .image, options: fetchOptions)

But it fails to compile because of 'fetchAssets(with:options:)' is only available in macOS 10.15 or newer.

My app is targeted to run on 10.14 and my MBP is still running 10.14.

When I check the documentation page (https://developer.apple.com/documentation/photokit/phasset),

I can't find the os version information next to each API on the page.

enter image description here

What is the easiest way to find such information?

Also how can I make the code work for 10.14?

Upvotes: 1

Views: 149

Answers (1)

Ross Jacobs
Ross Jacobs

Reputation: 3186

macOS Version Requirements

What is the easiest way to find such information?

It says on the page that 10.15+ is required:


enter image description here

Alternatives

Also how can I make the code work for 10.14?

Use fetchAssets(in:options:) (min 10.13) instead of fetchAssets(with:options:) (min 10.15).

Upvotes: 2

Related Questions