Unity iOS Save Media Plugin
iOS Swift Unity plugin to save media into the photo library, at a specific Album.
Motivation
I was looking for an up to date plugin based in Swift/Swift UI, but I did not found it, so that I decided to create one. I hope this can help other people.
Reference
This plugin is a result of some questions from this stackoverflow thread, especially this answer
Specs
- Xcode 14.0
- Swift 5.7
π» Supported platform
This plugin is available only for Unity iOS and Swift UI. If you can help developing an Android version, it will be appreciated.
π Ho to install
Extract and place the content of the latest release into Unity Plugins/iOS folder.
Plugins folder:
Assets/Plugins/iOS
β How to use
Call the following code in any script you want.
To save an image:
SaveImage(string imageNameWithExtension, string albumName, OnSuccess onSuccess, OnError onError)
To save a video:
SaveVideo(string videoNameWithExtension, string albumName, OnSuccess onSuccess, OnError onError)
If you have any doubt, refer to this sample project
Troubleshooting
Disable bitcode and make a new build in order to sove this problem:
error build: '.../Save Media Plugin/Frameworks/Plugins/iOS/SaveMediaToGallery.framework/SaveMediaToGallery' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '.../Save Media Plugin/Frameworks/Plugins/iOS/SaveMediaToGallery.framework/SaveMediaToGallery' for architecture arm64
π« Contrubuting with an Android version
If you are interested in contributing to this project, follow the steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>. - Commit your changes:
git commit -m '<commit_message>' - Push them:
git push origin <project_name> / <local> - Criate a pull request.
Check out the GitHub Pull Request at how to create a pull request.
π License
This project is licensed under: you can do whatever you want.
