Placid is a toolkit for creative automation. It lets you generate images with dynamic content from custom templates - e.g. for personalized share visuals. The Placid iOS SDK offers native, on-device image generation for your apps.
- Offline, on-device image generation
- Custom templates for on-brand visuals
- Drag & drop template editor
- Dynamic content layers
- Auto-resizing for text and images
- Unlimited generated images
- Dynamic in-app previews
➡️ Learn more about the Placid Mobile SDK
- iOS 13.0
To integrate the Placid SDK into your Xcode project using Swift Package Manager, specify it in the dependencies
of your Package.swift
:
// swift-tools-version:5.3
import PackageDescription
...
dependencies: [
.package(url: "https://github.com/placidapp/placid-ios.git", .upToNextMajor(from: "1.0.1"))
]
...
To integrate Placid into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'Placid'
To integrate Placid into your Xcode project using Carthage, specify it in your Cartfile
:
binary "https://raw.githubusercontent.com/placidapp/placid-ios/master/Placid.json"
If you prefer to integrate Placid manually instead of using a Dependency Manager, download the latest Placid.xcframwork and add it to your project.
- Register on placid.app (✅ free trial)
- Create a project and add the Placid mobile integration
- Add a template
- Add a mobile license in your project settings
- Download your template(s) to use with the SDK
Configure the Placid SDK in your AppDelegate
by providing the URL to your mobile templates package downloaded from the Placid web app.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
do {
try PlacidSDK.configure(withLicenseKey: "your-placid-license-key", templateURL: Bundle.main.url(forResource: "templates", withExtension: "placid"))
} catch {
print(error.localizedDescription)
}
}
Templates can be retrieved via their unique identifier (as found in the Placid web app). If the template is not found, this method will return nil.
let template = PlacidSDK.template(withIdentifier: "template-identifier")
For faster rendering it is recommended to preload a template as soon as it is accessed.
template.preload()
You can modify the content and appearance of dynamic layers in your template.
let textLayer = template.textLayer(named: "title")
textLayer.text = "A new title"
textLayer.textColor = UIColor.red
let image = UIImage(named: "avatar")!
let pictureLayer = template.pictureLayer(named: "avatar")
pictureLayer.image = image
let rectangleLayer = template.rectangleLayer(named: "rect")
rectangleLayer.backgroundColor = UIColor.red
rectangleLayer.borderColor = UIColor.blue
let browserFrameLayer = template.browserFrameLayer(named: "browser")
browserFrameLayer.url = browserURL
These properties are supported by all layer types.
let layer = template.textLayer(named: "title")
layer.isHidden = false
layer.origin = .zero
layer.size = CGSize(width: 100, height: 50)
The mobile SDK supports the same layers and properties as the Placid REST API, so have a look for the full set of supported functions and properties.
Once all data is added to the template, it can be rendered to a native image. Use the rendered image in your UIImageView
or Image
for dynamic in-app previews or pass it along for social sharing.
template.renderImage(completion: { [weak self] image in
// use the image here
})
Or via async function:
let image = await template.renderImage()
For bug reports, please create a new Issue right here on Github. Otherwise have a look at our Help section.