A tool for quickly converting Adobe Illustrator shapes into SwiftUI code.
A tool for quickly converting Adobe Illustrator shapes into SwiftUI code.
This tool utilizes the built-in scripting of Adobe Illustrator ("AI") to convert shapes drawn with AI into swift code. The included javascript iterates over each point of an AI shape and converts the shape into a series of CGPaths that are wrapped in a SwiftUI view for easy implementation into your XCode project.
Just grab a copy of this repo.
In this example, we'll be converting the SwiftyIllustrator icon (drawn using AI) into a SwiftUI view.
Description | Examples Images |
---|---|
To begin, open the included AI file, which has the SwiftyIllustrator icon already drawn on the lone artboard | |
Select all of the logo elements (e.g., using the Group Selection Tool) | |
Navigate to AI's built in scripting dialog via File -> Scripts -> Other Script... | |
Select the included javascript file and run it | |
Choose a name and destination for the script's output (e.g., "ShapeView.swift") | |
If successful, you should see the provided alert | |
Then, add the new .swift file to your XCode project | |
Open XCode's canvas to preview the new SwiftUI view. You should see a wireframe of the SwiftyIllustrator icon | |
In the new .swift file, you'll notice a single SwiftUI view comprising the 7 elements of the SwiftyIllustrator icon | |
Here, in the SwiftUI View, you can change the appearance of the individual shape elements (e.g., adding fills, strokes etc.) as you please, as well as adding animations to the individual elements, to create compelling, dynamic content in pure Swift code! |
This project was tested using:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
SwiftyIllustrator is available under the MIT license. See the LICENSE file for more info.