RORK LABJP
BUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verifyBUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verify
Articles/Dev Tools
Dev Tools/2026-07-04Advanced

Your Rork Max App Loses the Photos a User Picked After Relaunch — The Trap of Holding Onto URLs Under Limited Photo Access

In a native Swift app generated by Rork Max, photos picked via PHPickerViewController become unreadable after relaunch — because holding onto a URL or PHAsset no longer works in the age of limited access. Here's a design that copies the actual bytes into your own storage the instant they're picked.

Rork Max233PHPickerViewControllerPhotoKit2limited accessSwift48iOS110

Premium Article

I was adding a feature to a Rork Max app that just uses a few user-picked photos for a collage. Photos chosen through PHPickerViewController displayed fine on the spot and edits worked. But relaunch the app, and the photos I'd just picked came back black or failed to load. Pick them again and it's fixed, but the state I thought I'd saved was broken — that's the shape of the reports. Nothing that looks like an error appears.

The cause was holding onto the temporary reference PHPicker returns, thinking "I'll just read it later." On today's iOS, where limited access is the norm, you have to design on the assumption that a URL or PHAsset identifier valid at selection time won't be readable next time. As an indie developer who's worked on photo apps for a long time, I've learned that missing this "valid only at the moment of selection" nature of limited access means data quietly goes missing in production. This walks through adding photo import to a Rork Max native app with the smallest diff: how to avoid the holding-on trap, and an import layer you can use as-is.

What PHPicker hands you instead of "not asking for permission"

The big advantage of PHPickerViewController is that it works without the photo-library permission dialog. Only the photos the user selects inside the system UI reach the app, so the app holds no access to the whole library. That's the decisive difference from the older UIImagePickerController.

What arrives is a spout, not the bytes

The NSItemProvider PHPicker returns isn't the photo itself — it's "a spout you can draw from right now." You can read it on the spot with loadFileRepresentation or loadDataRepresentation, but the temporary file URL you get back expires after the callback returns. Think "I'll save the URL and open it later" and you drop into an unreadable state on next launch.

A PHAsset identifier is no guarantee of persistence either

You can configure preferredAssetRepresentationMode on PHPickerConfiguration to reach a PHAsset, but under limited access there's no guarantee the asset the app could see then will be visible next time. If the user later changes their selection, the identifier remains but you can no longer resolve it to the bytes. Running photo apps, I've moved away from any design that leans on persisting asset identifiers.

The core of the fix: copy the bytes the moment they're picked

Stop trying to hold on. Inside the selection callback, copy the bytes fully into your own persistent area (like Application Support). Reference only that local file afterward. This is the straightforward design for the limited-access era. Pay the cost once at import, then treat it as your own file — and URL expiry and selection changes become irrelevant.

import PhotosUI
import UniformTypeIdentifiers
import os
 
let picLog = Logger(subsystem: "net.rorklab.sample", category: "photo")
 
enum PhotoImportError: Error { case noImageRep, copyFailed }
 
final class PhotoImporter {
    private let dir: URL = {
        let base = FileManager.default.urls(for: .applicationSupportDirectory,
                                            in: .userDomainMask)[0]
        let d = base.appendingPathComponent("imported", isDirectory: true)
        try? FileManager.default.createDirectory(at: d, withIntermediateDirectories: true)
        return d
    }()
 
    // Take PHPicker results, return an array of persistent paths
    func importItems(_ results: [PHPickerResult]) async -> [URL] {
        var saved: [URL] = []
        for result in results {
            do {
                let url = try await copyToLocal(result.itemProvider)
                saved.append(url)
                picLog.info("imported: \(url.lastPathComponent)")
            } catch {
                picLog.error("import failed: \(error.localizedDescription)")
            }
        }
        return saved
    }
}

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
You can isolate why PHPicker photos vanish after relaunch: limited access, temporary-URL expiry, or the non-persistence of PHAsset
You get an import layer that copies the bytes into the app's persistent area right after selection and references only local files afterward, ready to drop into Rork Max's generated code
You'll keep PHPicker's strength of not requesting library permission while getting the export, orientation, and size details right for production
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-07-13
Losing HealthKit Data on Incremental Sync — Designing HKQueryAnchor Persistence
When step or sleep data double-counts or goes missing on incremental HealthKit sync, the root cause is usually HKQueryAnchor persistence. Here is a working Swift design that handles newAnchor and deletedObjects correctly and stays consistent across reinstalls and background updates.
Dev Tools2026-07-11
Implementing App Clips with Rork Max — delivering the core of your app the moment someone scans a code
Building on the native Swift that Rork Max produces, this note walks through the 15 MB App Clip budget, receiving the launch URL, and handing state off to the full app.
Dev Tools2026-07-08
Working Around Rork Max's 20-Geofence Wall with Dynamic Re-registration
In a native Swift app generated by Rork Max, geofences you registered quietly stop firing past a certain count — and it's almost always iOS's silent limit of 20 monitored regions per app. Here's a dynamic re-registration design that keeps only the nearest 20 live, plus a Swift implementation you can drop in.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →