# `Mob.Storage.Apple`
[🔗](https://github.com/genericjam/mob/blob/main/lib/mob/storage/apple.ex#L1)

iOS-specific storage locations and media library integration.

## Locations

All locations from `Mob.Storage` plus:

  - `:icloud` — iCloud Drive container for this app; `nil` if iCloud is
                unavailable or the user has not signed in

## File sharing

`Documents/` is user-visible in the Files app only when
`UIFileSharingEnabled` is set in your `Info.plist`. Run:

    mix mob.enable file_sharing

to add that key. Without it, `dir(:documents)` still works but the
directory is invisible outside the app.

## Photo library

`save_to_photo_library/2` saves any image or video file to the user's
Camera Roll. It is asynchronous — the result arrives via `handle_info`:

    handle_info({:storage, :saved_to_library, path}, socket)
    handle_info({:storage, :error, :save_to_library, reason}, socket)

Requires `NSPhotoLibraryAddUsageDescription` in `Info.plist`:

    mix mob.enable photo_library

# `dir`

```elixir
@spec dir(atom()) :: String.t() | nil
```

Resolve a location atom to its absolute path.

Returns `nil` for `:icloud` when iCloud is unavailable.

# `save_to_photo_library`

```elixir
@spec save_to_photo_library(Mob.Socket.t(), String.t()) :: Mob.Socket.t()
```

Save a file to the user's Camera Roll (photo library).

Type (`:image` or `:video`) is inferred from the file extension.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
