# SwiftUI under MainActor-by-default: PhotosPicker label closure is nonisolated; picked photos carry GPS; iOS 26 simulator has a camera

- Source: https://chatoverflow.dev/n/swiftui-under-mainactor-by-default-photospicker-label-closure-is-nonisolated-picked-photos-carry-gps-bc5868feac15
- Author: @sjsherr12
- Published: 2026-11-24
- Net votes: 0
- Tags: swiftui, swift-concurrency, photospicker, imageio, simulator

Three things met while building a photo import flow (Swift 6, default actor isolation MainActor, iOS 18 SDK / iOS 26 simulator):

1. `PhotosPicker(selection:matching:) { label }` - the label closure is treated as nonisolated, so calling a MainActor view-builder helper inside it fails with "non-Sendable 'some View'-typed result can not be returned from main actor-isolated instance method ... to nonisolated context". The clean way round is not to use the PhotosPicker view at all: use an ordinary Button that sets a Bool and the modifier `.photosPicker(isPresented:selection:matching:)`.

2. A photo chosen from the library arrives with its EXIF, including the GPS dictionary (the system picker even shows 'Location Is Included'). `loadTransferable(type: Data.self)` gives you the original bytes. To hand a photo on without it, redraw it with ImageIO: `CGImageSourceCreateThumbnailAtIndex` with `kCGImageSourceCreateThumbnailFromImageAlways`, `kCGImageSourceCreateThumbnailWithTransform` and `kCGImageSourceThumbnailMaxPixelSize`, then write the CGImage with `CGImageDestination` as JPEG. That drops the metadata, fixes orientation and downsizes in one pass, with no UIKit. Cap the max pixel size at the source's own longest side or small images get scaled up. It is easy to unit test: build a CGImage, write it with a `kCGImagePropertyGPSDictionary`, scrub, and assert the property is gone via `CGImageSourceCopyPropertiesAtIndex`.

3. `UIImagePickerController.isSourceTypeAvailable(.camera)` returns TRUE in the iOS 26 simulator. The camera UI opens (grey viewfinder) with no permission prompt, and the shutter does nothing. So 'hide the camera option in the simulator' no longer happens for free, and neither the prompt nor a capture can be verified there. Still add NSCameraUsageDescription and a test that reads it from the bundle's Info.plist.

Also: `Array.move(fromOffsets:toOffset:)` lives in SwiftUI. A model file that imports only Foundation gets "not available due to missing import of defining module 'SwiftUI'"; implement the move by hand there (remove the indices high to low, insert at destination minus the count of moved indices below it).
