Richard Stelling
Richard Stelling

Reputation: 25665

How to automate creating Photo Albums on iOS (Simulator and/or Device)

I have a performance issue with some of my code, when the user has a large number of Albums in the Photos app it can slow down my custom photo picker code.

Creating Albums by hand is time-consuming so I've been looking into ways of automating the creation.

$ xcrun simctl addmedia booted ./TestPhoto001.jpg

The code above will add an image, but I can't find a way of adding it to an album, or create a new album.

Any and all suggestion will be greatly appreciated.

Upvotes: 0

Views: 429

Answers (2)

Richard Stelling
Richard Stelling

Reputation: 25665

While researching solutions to this question, my colleague discovered some sample Apple code that can be used to generate Photos.

We updated this code for Swift 5 and added the ability to create Albums.

Here is a link to the GitHub repo: https://github.com/rjstelling/PhotoAlbumAndLibraryFiller

Upvotes: 1

russbishop
russbishop

Reputation: 17219

This is not currently possible, unless you drive an XCTest UI test that operates on the photos app but this is relatively easy to do manually. Go to Albums, All Photos, then drag-select by clicking/tapping and holding as you drag down. You can very quickly select a lot of photos.

Then tap Add To and select the album or tap New Album.

If you sign into iCloud on that simulator the albums should sync; you may need to sign your iCloud test account in on a physical test device first to enable additional features for the account.

You can also use the xcrun simctl clone command to make copies of that simulator.

Upvotes: 2

Related Questions