/Flare-Swift

Swift runtime for Flare.

Primary LanguageSwiftMIT LicenseMIT

Flare

Flare is a powerful design and animation tool for app and game designers alike. The primary goal of Flare is to allow designers to work directly with assets that run in their final product, eliminating the need to redo that work in code.

Flare-Swift

Swift runtime for Flare: export files from Flare and run them on iOS!

Only Binary format is supported right now, but JSON support is in the works.

Problems

If you encounter any problems report them in the issue tracker and, if applicable, include your Flare file.

Contents

The repository contains an XCode Project structured as follows:

  • FlareSwift - Swift Framework for loading and drawing Flare files
    • FlareCore is the bottommost layer of the Framework: this is where Flare file contents are read, loaded and built in-memory
    • FlareSkia handles the drawing operations in an OpenGL context. It relies on libskia, which is built with a custom script (see Usage)

This project contains multiple targets:

  • FlareSwift - builds the Framework that runs on physical devices.
  • FlareSwiftDev - builds the Framework that runs on Simulators.
  • Example - A simple example demonstrating how to add a FlareSkViewController in a Single View App ViewController. It draws inside the FlareSkView associated with the FlareSkViewController.
  • ExampleController - Demonstrates how to create a CustomController that is an extension of FlareSkViewController. This class takes advantage of the available APIs by overriding advanceControls(), using a custom callback for swapping animations on completed (i.e. onCompleted()), and adding a play() function that plays a new animation allowing the user to specify the interpolation mix and time.

Using the Framework

  • Clone the repository:
git clone git@github.com:2d-inc/Flare-Swift.git
  • Open FlareSwift.xcodeproj
  • In the XCode window, select the scheme for the device you want to run on:
    • Use FlareSwift to build the Framework for a physical device
    • Use FlareSwiftDev to build the Framework for a Simulator

N.B: first time building the Framework takes a while, as it is initializing and building all the dependencies. Use the Report Navigator to have an overview of what's happening.

  • Build the Framework (⌘ + B)

The Framework can be found in the Products folder.
Access the Products folder from XCode by right clicking on it > Show in Finder.

In Your Project:

  • Drag-and-drop the .framework file into the XCode window.
    • In the import dialog, select "Copy items if needed" and the target in "Add to Targets"
  • Add the Framework to the Build Phases:
    • Select the Project in the Project Navigator
    • Select your Target
    • Build Phases
    • Add the Framework to the Embed Frameworks phase.

Running the Examples

The examples are configured to be run on a Simulator.

If you want to run them on a physical device, follow these steps:

  • Select the example project in the Project Navigator
  • Select the project target from the target list
  • Under the Framework, Libraries and Embedded Content menu:
    • Select FlareSwiftDev.framework and press the minus (-) button to remove it
    • Use the plus (+) button to add FlareSwift.framework
  • Run the example N.B. if the Framework needs to run a clean build for the device, this process might take a while. Use the Report Navigator to look at what's happening.

License

See the LICENSE file for license rights and limitations (MIT).

The Bezier folder is a port of bezier.dart, and is complying with their LICENSE.txt (BSD 2-Clause License).