Pre-built XCFramework for the Finegrain SDK which brings Finegrain's image editing models directly on-device — no cloud calls, no latency, and full privacy.
Important
This SDK is not ready for production use. Breaking changes may occur between minor versions.
- iOS 18.0+
- Xcode 16.0+
- Tested on A16 Bionic and newer devices (optimized for Neural Engine)
- Object Eraser: Remove unwanted objects from images
- Shadow Generator: Generate natural shadows for any object
Here is a sneak peek from the Finegrain iOS app: watch | try it
Setting up the Finegrain SDK involves the following steps:
- Generate a model encryption key and send it to Finegrain (more on this below)
- Receive your encrypted model.zip
- Install the SDK and model, then start coding
Note
The Finegrain SDK builds upon Apple's Core ML encryption. We will issue you a unique model that functions solely with your specific Team ID.
Since Apple's command-line tools do not currently support key generation, you must use the Xcode interface for this step. You will generate a Core ML encryption key tied to your Apple Developer Team ID.
Important
This key MUST be generated using the same Team ID you use to sign your app. If the IDs do not match, the model will not decrypt at runtime.
- Download a sample Core ML model (any model works - we recommend Apple's MNIST Classifier)
Note
Why a sample model? You just need to generate an encryption key tied to your Team ID. The specific model doesn't matter - you won't actually use MNIST in your app.
-
Double-click the downloaded
.mlmodelfile to open it in Xcode -
In the Utilities panel (right sidebar), click "Create Encryption Key"
-
Select your Team ID - This MUST match the Team ID you'll use to build and sign your app
-
Rename the generated key file
- Xcode creates
MNISTClassifier.mlmodelkeynext to the model file - Rename it to
finegrain.mlmodelkey
- Xcode creates
Note
What's in this file? It's an encryption key that Finegrain will use to encrypt your model package. Only apps signed with your Team ID can decrypt it.
- Send the
.mlmodelkeyfile to hello@finegrain.ai- Keep a copy for your records - we'll use this same key for future model updates
Once we receive your .mlmodelkey file, we'll encrypt the model specifically for your Team ID and send you a custom model.zip file.
Once you have your encrypted model.zip:
- Download
FinegrainCore.xcframework.zipfrom the latest release - Extract and add
FinegrainCore.xcframeworkto your Xcode project - Select Embed & Sign in
General -> Frameworks, Libraries and Embedded Content
- Add your
model.ziptoBuild Phases -> Copy Bundle Resources
import FinegrainCore
let modelsDirectory = URL.applicationSupportDirectory.appendingPathComponent("finegrain-models")
let loader = FG.PipelineLoader(bundledModelName: "model", modelsDirectory: modelsDirectory)
// Eraser: remove objects from an image using a mask
let eraserPipeline = try await loader.prepare(skill: .eraser)
let eraserResult = try await eraserPipeline.generate(inputImage: image, maskImage: mask)
// Shadow: generate a shadow for an RGBA cutout, i.e., from a pre-segmented object
let shadowPipeline = try await loader.prepare(skill: .shadow)
let shadowResult = try await shadowPipeline.generate(
cutoutImage: cutoutImage, // RGBA image with transparency
backgroundColor: (r: 255, g: 255, b: 255, a: 255)
)await loader.setOnStateChange { phase in
print("Loading: \(phase)")
}
await pipeline.setOnPreview { previewImage in
// Early preview during generation
}
await pipeline.setOnProgress { progress in
// progress.completion is 0.0 to 1.0
}await pipeline.cancel()FinegrainCore collects anonymous usage telemetry to understand which features are most valuable.
What we collect:
- Which skills are used (e.g., "shadow", "eraser")
- Framework version
- Platform (iOS/macOS)
- Host app bundle identifier (e.g., "com.example.myapp")
- OS version (e.g., "18.2.0")
- Device model identifier (e.g., "iPhone15,2")
What we DON'T collect:
- Device identifiers (IDFA, IDFV, etc.)
- User information or device names
- Image content
- Any personally identifiable information
Opt-out:
Telemetry is enabled by default. To disable it:
// Disable telemetry globally
FG.telemetryEnabled = falsePrivacy Manifest:
FinegrainCore includes a privacy manifest (PrivacyInfo.xcprivacy) that declares this data collection. This will be included in your app's privacy report when you submit to the App Store.
Join our Discord community for help and discussions.
Distributed under the Finegrain Terms & Conditions.
The Gist:
- Release Status: Usage is subject to the "Important" note above.
- No Model Extraction: Decoupling, distilling, or reverse-engineering the models is prohibited.
- No Competitive Training: Do not use the SDK or its outputs to train other AI models.
- Attribution: Retain all copyright and license notices.


