Overview
With Play to Xcode, your Play project is no longer just a prototype. You can use Play’s SDK (software development kit) to export your project’s styles, assets, components, pages, and variables directly into Xcode as a Swift package. Everything will look and behave 1:1 with how you designed it in Play.
You can add the Swift package to a new or existing project in Xcode, and you can always update the package based on new changes in Play. We’re making it easy to keep your design tool and code base in sync.
To begin using Play’s SDK, click the Publish button in the top right corner of the macOS app. The Play to Xcode popup will appear.
Publishing to a New Xcode Project
Starting from scratch? Create a new Xcode project starting with Play's SDK.
Step 1: Configure Your Package
Export As
Select "New Xcode Project".
Project Type
Choose if the Swift package should be SwiftUI or UIKit.
Include Assets in Your Module
Choose to include font, image, and/or video type assets from the Play project. You can choose specific assets later. Note: Rive, JSON, and Audio assets can not be exported at this time.
Module Name
Enter a name for the module. It cannot be the same as the project name. Implement the module in Xcode with the following syntax:
import SwiftUI
import ModuleName
Step 2: Review Names and Implementation
Review the standardized names of your styles, components, and pages to ensure compatibility for seamless use in Xcode. The names chosen here will be used exactly in Xcode.
If any names don’t work for you, you can rename them by double clicking on each pink name. Renaming something will not change its name in your Play project.
Renaming Best Practices
Class Names should start with an uppercase letter. They cannot start with a number, so we’ve added an underscore (_) when necessary.
Style and Variable Names should start with a lowercase letter and follow camelCase.
Slashes (/) cause conflicts, so they should be removed or replaced with an underscore (_).
Periods (•), Hyphens (-) and Spaces should be removed to simplify naming.
When any style, asset, component, page, or variable is selected, we show how to call it in Xcode. See example syntax in our Implementing Play's SDK in Xcode article.
Step 3: Export to Xcode
When you’re ready, click “Export to Xcode” to begin the export. You’ll see the download status at the bottom of the macOS app.
Give the project a name and choose its save location. Open the .xcodeproj file.
Once you've exported your Play project to Xcode, you can continuously update the package with new changes made to your design in Play. Learn more in our Updating Play's SDK article.
Publishing to an Existing Xcode Project
Already have a code base in Xcode? Add Play's SDK to your existing Xcode project.
Step 1: Configure Your Package
Export As
Select "Add to Existing Xcode Project".
Include Assets in Your Module
Choose to include font, image, and/or video type assets from the Play project. You can choose specific assets later. Note: Rive, JSON, and Audio assets can not be exported at this time.
Module Name
Enter a name for the module. It cannot be the same as the project name. Implement the module in Xcode with the following syntax:
import SwiftUI
import ModuleName
The package will inherit the Project Type (SwiftUI or UIKit) from the existing project.
Step 2: Review Names and Implementation
Review the standardized names of your styles, components, and pages to ensure compatibility for seamless use in Xcode. The names chosen here will be used exactly in Xcode.
If any names don’t work for you, you can rename them by double clicking on each pink name. Renaming something will not change its name in your Play project.
Renaming Best Practices
Class Names should start with an uppercase letter. They cannot start with a number, so we’ve added an underscore (_) when necessary.
Style and Variable Names should start with a lowercase letter and follow camelCase.
Slashes (/) cause conflicts, so they should be removed or replaced with an underscore (_).
Periods (•), Hyphens (-) and Spaces should be removed to simplify naming.
When any style, asset, component, page, or variable is selected, we show how to call it in Xcode. See example syntax in our Implementing Play's SDK in Xcode article.
Step 3: Export to Xcode
When you’re ready, click “Export to Xcode” to begin the export. You’ll see the download status at the bottom of the macOS app.
Select the existing .xcodeproj file to replace. Inside Xcode, update the project the latest package versions from the top menu (File > Packages > Update to Latest Package Versions).
Once you've exported your Play project to Xcode, you can continuously update the package with new changes made to your design in Play. Learn more in our Updating Play's SDK article.