Add Media to Simulator
simctl-addmediaAdd images or videos to an iOS simulator's photo library for testing photo pickers, PHPhotoLibrary access, and media playback.
Instructions
simctl-addmedia
Add media files (photos and videos) to a simulator's photo library for testing.
What it does
Adds image or video files to the simulator's Photos app, making them available for apps to access via PHPhotoLibrary or UIImagePickerController APIs.
Parameters
udid (string, required): Simulator UDID (from simctl-list)
mediaPath (string, required): Path to image or video file
Supported Formats
Images: jpg, jpeg, png, heic, gif, bmp Videos: mp4, mov, avi, mkv
Returns
JSON response with:
Media addition status
Media type and format detected
Guidance for viewing in Photos app and adding more media
Examples
Add image to photo library
await simctlAddmediaTool({
udid: 'device-123',
mediaPath: '/path/to/photo.jpg'
})Add video to photo library
await simctlAddmediaTool({
udid: 'device-123',
mediaPath: '/path/to/video.mp4'
})Common Use Cases
Photo picker testing: Add test images for UIImagePickerController testing
PHPhotoLibrary testing: Populate library for photo access API testing
Image processing: Add images to test filters, crops, and transformations
Video playback: Add videos to test AVPlayer integration
Camera roll simulation: Populate library to simulate real user photo collection
Important Notes
File must exist: Validates file exists before attempting to add
Format validation: Only supported image/video formats are accepted
Simulator state: Works on both booted and shutdown simulators
Photos app: Media appears in simulator's Photos app immediately
Metadata: Original file metadata (EXIF, date, etc.) is preserved
Error Handling
File not found: Error if media file path doesn't exist
Unsupported format: Error if file extension is not in supported list
Simulator not found: Validates simulator exists in cache
Addition failure: Reports simctl errors if media cannot be added
Next Steps After Adding Media
View in Photos app:
simctl-launch <udid> com.apple.mobileslideshowTest photo picker: Launch your app and open UIImagePickerController
Add more media: Repeat with different images/videos
Test PHPhotoLibrary: Use PHPhotoLibrary.requestAuthorization() in your app
Testing Workflow
Grant photo permissions:
simctl-privacy <udid> <bundleId> grant photosAdd test media:
simctl-addmedia <udid> /path/to/photo.jpgLaunch app:
simctl-launch <udid> <bundleId>Test photo access: Verify app can read from photo library
Take screenshot:
simctl-io <udid> screenshotto verify UI
Tips
Test image formats: Add different image formats (JPEG, PNG, HEIC) to test compatibility
Test video formats: Add various video formats (MP4, MOV) to test playback
Large files: Be aware that adding large video files may take time
Batch addition: Add multiple files to simulate realistic photo library
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | Yes | ||
| mediaPath | Yes |