Share Image to Instagram Story is an advanced SwiftUI iOS project demonstrating not only basic image generation but also sharing these images directly to Instagram Stories, provided the Instagram app is installed on the device. This project builds upon the simple image generation by integrating social sharing capabilities, specifically targeting Instagram Stories.
- Image Generation: Generate random images with customizable properties.
- Save to Photos: Option to save the generated images to the device's Photos app.
- Share to Instagram Stories: Seamlessly share generated images to Instagram Stories, enhancing the app's social sharing capabilities.
- iOS 16.4+
- Xcode 13.0+
- Swift 5
To get started, clone the repository or download the project. Open share-image-to-instagram-story.xcodeproj
in Xcode. Ensure your development environment meets the project's requirements.
The main interface offers a "Make Image" button that, upon tapping, generates a random image displayed in a modal view. Users have the option to save the image to Photos or share it directly to Instagram Stories if the Instagram app is installed on their device.
- Generating an Image: Utilize the
ViewModel
class, which handles image generation usingUIGraphicsImageRenderer
. - Sharing to Instagram Stories: The
InstagramSharingUtils
struct provides functionality to share the generated image to Instagram Stories by writing the image to the pasteboard and then opening Instagram.
The app requires specific permissions to function correctly:
- Instagram App Check: To verify Instagram installation and enable sharing to Instagram Stories.
- Photos Access: Optional, for saving images to the Photos app.
Detailed instructions on configuring these permissions are available in the ViewModel.swift
file.
Ensure your Info.plist
is configured with:
LSApplicationQueriesSchemes
to include "instagram" and "instagram-stories" for app checks.NSPhotoLibraryUsageDescription
for Photos access, with a user-facing reason for the permission request.
This project is released under the MIT license.