Skip to content

fix(example): add iOS Expo Media Library permissions to prevent crash #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Abdulrahman-YE
Copy link
Contributor

@Abdulrahman-YE Abdulrahman-YE commented Jun 9, 2025

Summary

This pull request adds the required iOS permission configurations for expo-media-library to the example app's app.json to fix a crash when accessing the photo gallery on iOS devices.

Describe your changes

  • Added the expo-media-library config plugin to example/app.json with photosPermission and savePhotosPermission keys.
  • Prevents the app from crashing due to missing NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription keys in the native iOS Info.plist.
  • No changes to the main library API or implementation.
  • Fixes the iOS crash in the GalleryExample screen and allows saving cropped images without freezing the UI.

Footage

No UI changes; fix affects native config only.

Pull Request Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other

Terms of service

@Abdulrahman-YE
Copy link
Contributor Author

Title: iOS crash in GalleryExample due to missing expo-media-library permissions


🐛 Bug Report

Description

The example app crashes on iOS when navigating to the GalleryExample screen. This is due to missing permissions required by expo-media-library, which attempts to access the user's photo library without declaring the appropriate usage descriptions in app.json.


✅ Expected Behavior

The GalleryExample screen should request access to the user's photo library and load images without crashing. Similarly, saving a cropped image via BasicCropZoom and SkiaCropZoom should complete successfully without an infinite loading spinner.


🧪 Reproduction Steps

  1. Clone the repo and install dependencies:

    git clone https://github.com/Glazzes/react-native-zoom-toolkit
    cd react-native-zoom-toolkit/example
    npx expo install
    npx expo run:ios
  2. Launch the app and open the drawer.

  3. Navigate to the GalleryExample screen.

  4. Observe that the app crashes immediately on iOS.

  5. Additionally, try saving a cropped image from BasicCropZoom or SkiaCropZoom and note the indefinite ActivityIndicator.


📄 Root Cause

expo-media-library requires permission declarations in app.json that translate to iOS Info.plist entries:

  • photosPermission → maps to NSPhotoLibraryUsageDescription
  • savePhotosPermission → maps to NSPhotoLibraryAddUsageDescription

These permissions are currently not set in the example app configuration.


✅ Suggested Fix

Update the example/app.json to include the necessary plugin configuration:

{
  "expo": {
    "plugins": [
      [
        "expo-media-library",
        {
          "photosPermission": "Allow $(PRODUCT_NAME) to access your photos.",
          "savePhotosPermission": "Allow $(PRODUCT_NAME) to save photos."
        }
      ]
    ]
  }
}

This allows the app to read and write from the user’s photo library without crashing or hanging.


📸 Screenshots

Gallery crash

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-09.at.22.15.12.mp4

Store cropped image

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-09.at.22.16.01.mp4

🔍 Relevant Logs

[TCC] This app has crashed because it attempted to access privacy-sensitive data without a
usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key
with a string value explaining to the user how the app uses this data.

🧠 Additional Context

  • The crash is specific to iOS and only occurs when using media-library APIs without the appropriate permission strings set at build time.
  • According to Apple documentation
    , Apple docs, these permissions are mandatory for any access to the photo library.

@Glazzes Glazzes merged commit b0166ab into Glazzes:main Jun 9, 2025
4 checks passed
@Glazzes
Copy link
Owner

Glazzes commented Jun 9, 2025

Thanks for the PR, as I don't have an iOS device right now I'm not aware of these naunces.

@Abdulrahman-YE Abdulrahman-YE deleted the fix/example-ios-crash-media-library-permissions branch June 9, 2025 21:01
@Abdulrahman-YE
Copy link
Contributor Author

Just wanted to say a genuine thank you for creating and maintaining this package 🙏. Always happy to support however I can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants