First cut at refactoring for high level api support

This commit is contained in:
matt Sullivan
2021-04-29 18:26:12 -07:00
parent f725f1e9bb
commit 336244e45a
24 changed files with 331 additions and 72 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -7,23 +7,18 @@
objects = {
/* Begin PBXBuildFile section */
C9696B1224FC704A0041502A /* juice.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9696B1124FC704A0041502A /* juice.riv */; };
C99E2FE3251E8DB4009227CA /* van.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE0251E8DB4009227CA /* van.riv */; };
C99E2FE8251E8E35009227CA /* bird.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE6251E8E35009227CA /* bird.riv */; };
C99E2FE9251E8E35009227CA /* funtime.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE7251E8E35009227CA /* funtime.riv */; };
C9A7D7F52523C1D900AFB875 /* sheep.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9A7D7F22523C1D900AFB875 /* sheep.riv */; };
C9BD3926263B5FC700696C37 /* truck_v7.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9BD3925263B5FC700696C37 /* truck_v7.riv */; };
C9C1DF7F252BA5EF00B0A444 /* MyRiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C1DF7E252BA5EF00B0A444 /* MyRiveView.swift */; };
C9C1DF83252BA62800B0A444 /* MyRiveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C1DF82252BA62800B0A444 /* MyRiveViewController.swift */; };
C9C1DF7F252BA5EF00B0A444 /* CustomRiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C1DF7E252BA5EF00B0A444 /* CustomRiveView.swift */; };
C9C1DF83252BA62800B0A444 /* CustomRiveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C1DF82252BA62800B0A444 /* CustomRiveViewController.swift */; };
C9C73E9824FC471E00EF9516 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9724FC471E00EF9516 /* AppDelegate.swift */; };
C9C73E9A24FC471E00EF9516 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */; };
C9C73E9C24FC471E00EF9516 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9B24FC471E00EF9516 /* ContentView.swift */; };
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9C73E9D24FC471E00EF9516 /* Assets.xcassets */; };
C9C73EA124FC471E00EF9516 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9C73EA024FC471E00EF9516 /* Preview Assets.xcassets */; };
C9C73EA424FC471E00EF9516 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9C73EA224FC471E00EF9516 /* LaunchScreen.storyboard */; };
C9CE8266263B90E000F98DDB /* juice_v7.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9CE8265263B90E000F98DDB /* juice_v7.riv */; };
C9E1AA45251E957F00BD52EC /* RiveRuntime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */; };
C9E1AA46251E957F00BD52EC /* RiveRuntime.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C9EEA13125268E48001BB768 /* teeny.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9EEA12E25268E48001BB768 /* teeny.riv */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -58,14 +53,9 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
C9696B1124FC704A0041502A /* juice.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = juice.riv; sourceTree = "<group>"; };
C99E2FE0251E8DB4009227CA /* van.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = van.riv; sourceTree = "<group>"; };
C99E2FE6251E8E35009227CA /* bird.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = bird.riv; sourceTree = "<group>"; };
C99E2FE7251E8E35009227CA /* funtime.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = funtime.riv; sourceTree = "<group>"; };
C9A7D7F22523C1D900AFB875 /* sheep.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep.riv; sourceTree = "<group>"; };
C9BD3925263B5FC700696C37 /* truck_v7.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = truck_v7.riv; sourceTree = "<group>"; };
C9C1DF7E252BA5EF00B0A444 /* MyRiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyRiveView.swift; sourceTree = "<group>"; };
C9C1DF82252BA62800B0A444 /* MyRiveViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyRiveViewController.swift; sourceTree = "<group>"; };
C9C1DF7E252BA5EF00B0A444 /* CustomRiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRiveView.swift; sourceTree = "<group>"; };
C9C1DF82252BA62800B0A444 /* CustomRiveViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRiveViewController.swift; sourceTree = "<group>"; };
C9C73E9424FC471E00EF9516 /* RiveExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RiveExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
C9C73E9724FC471E00EF9516 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -74,8 +64,8 @@
C9C73EA024FC471E00EF9516 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
C9C73EA324FC471E00EF9516 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
C9C73EA524FC471E00EF9516 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C9CE8265263B90E000F98DDB /* juice_v7.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = juice_v7.riv; sourceTree = "<group>"; };
C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RiveRuntime.xcodeproj; path = ../RiveRuntime.xcodeproj; sourceTree = "<group>"; };
C9EEA12E25268E48001BB768 /* teeny.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = teeny.riv; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -93,13 +83,8 @@
C9696B0E24FC6FD10041502A /* Assets */ = {
isa = PBXGroup;
children = (
C9CE8265263B90E000F98DDB /* juice_v7.riv */,
C9BD3925263B5FC700696C37 /* truck_v7.riv */,
C9EEA12E25268E48001BB768 /* teeny.riv */,
C9A7D7F22523C1D900AFB875 /* sheep.riv */,
C99E2FE6251E8E35009227CA /* bird.riv */,
C99E2FE7251E8E35009227CA /* funtime.riv */,
C99E2FE0251E8DB4009227CA /* van.riv */,
C9696B1124FC704A0041502A /* juice.riv */,
);
path = Assets;
sourceTree = "<group>";
@@ -126,9 +111,8 @@
C9C73E9624FC471E00EF9516 /* Source */ = {
isa = PBXGroup;
children = (
C9C73E9B24FC471E00EF9516 /* ContentView.swift */,
C9C1DF7E252BA5EF00B0A444 /* MyRiveView.swift */,
C9C1DF82252BA62800B0A444 /* MyRiveViewController.swift */,
C9CE8261263B7F2E00F98DDB /* SwiftUI */,
C9CE8259263B796D00F98DDB /* CustomRenderer */,
C9C73E9724FC471E00EF9516 /* AppDelegate.swift */,
C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */,
C9C73EA224FC471E00EF9516 /* LaunchScreen.storyboard */,
@@ -154,6 +138,23 @@
name = Frameworks;
sourceTree = "<group>";
};
C9CE8259263B796D00F98DDB /* CustomRenderer */ = {
isa = PBXGroup;
children = (
C9C1DF7E252BA5EF00B0A444 /* CustomRiveView.swift */,
C9C1DF82252BA62800B0A444 /* CustomRiveViewController.swift */,
);
path = CustomRenderer;
sourceTree = "<group>";
};
C9CE8261263B7F2E00F98DDB /* SwiftUI */ = {
isa = PBXGroup;
children = (
C9C73E9B24FC471E00EF9516 /* ContentView.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
};
C9E1AA39251E94CC00BD52EC /* Products */ = {
isa = PBXGroup;
children = (
@@ -246,15 +247,10 @@
buildActionMask = 2147483647;
files = (
C9BD3926263B5FC700696C37 /* truck_v7.riv in Resources */,
C99E2FE9251E8E35009227CA /* funtime.riv in Resources */,
C9696B1224FC704A0041502A /* juice.riv in Resources */,
C9CE8266263B90E000F98DDB /* juice_v7.riv in Resources */,
C9C73EA424FC471E00EF9516 /* LaunchScreen.storyboard in Resources */,
C99E2FE3251E8DB4009227CA /* van.riv in Resources */,
C9EEA13125268E48001BB768 /* teeny.riv in Resources */,
C99E2FE8251E8E35009227CA /* bird.riv in Resources */,
C9C73EA124FC471E00EF9516 /* Preview Assets.xcassets in Resources */,
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */,
C9A7D7F52523C1D900AFB875 /* sheep.riv in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -267,8 +263,8 @@
files = (
C9C73E9824FC471E00EF9516 /* AppDelegate.swift in Sources */,
C9C73E9A24FC471E00EF9516 /* SceneDelegate.swift in Sources */,
C9C1DF7F252BA5EF00B0A444 /* MyRiveView.swift in Sources */,
C9C1DF83252BA62800B0A444 /* MyRiveViewController.swift in Sources */,
C9C1DF7F252BA5EF00B0A444 /* CustomRiveView.swift in Sources */,
C9C1DF83252BA62800B0A444 /* CustomRiveViewController.swift in Sources */,
C9C73E9C24FC471E00EF9516 /* ContentView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@@ -11,8 +11,6 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
@@ -31,7 +29,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}

View File

@@ -1,24 +0,0 @@
//
// ContentView.swift
// RiveExample
//
// Created by Matt Sullivan on 8/30/20.
// Copyright © 2020 Rive. All rights reserved.
//
import SwiftUI
import RiveRuntime
struct ContentView: View {
var body: some View {
MyRive()
}
}
struct MyRive: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> MyRiveViewController {
return MyRiveViewController(withResource: "truck_v7", withExtension: "riv")
}
func updateUIViewController(_ uiViewController: MyRiveViewController, context: Context) {}
}

View File

@@ -1,5 +1,5 @@
//
// MyViewView.swift
// CustomViewView.swift
// RiveExample
//
// Created by Matt Sullivan on 10/5/20.
@@ -9,7 +9,7 @@
import UIKit
import RiveRuntime
class MyRiveView: UIView {
class CustomRiveView: UIView {
var artboard: RiveArtboard?;

View File

@@ -1,5 +1,5 @@
//
// MyRiveViewController.swift
// CustomRiveViewController.swift
// RiveExample
//
// Created by Matt Sullivan on 10/5/20.
@@ -9,7 +9,7 @@
import UIKit
import RiveRuntime
class MyRiveViewController: UIViewController {
class CustomRiveViewController: UIViewController {
var resourceName: String?
var resourceExt: String?
@@ -35,8 +35,8 @@ class MyRiveViewController: UIViewController {
}
override func loadView() {
// Wire up an instance of MyRiveView to the controller
let view = MyRiveView()
// Wire up an instance of CustomRiveView to the controller
let view = CustomRiveView()
view.backgroundColor = UIColor.blue
self.view = view
}
@@ -69,7 +69,7 @@ class MyRiveViewController: UIViewController {
self.artboard = artboard
// update the artboard in the view
(self.view as! MyRiveView).updateArtboard(artboard)
(self.view as! CustomRiveView).updateArtboard(artboard)
if (artboard.animationCount() == 0) {
fatalError("No animations in the file.")

View File

@@ -0,0 +1,18 @@
//
// ContentView.swift
// RiveExample
//
// Created by Matt Sullivan on 8/30/20.
// Copyright © 2020 Rive. All rights reserved.
//
import SwiftUI
import RiveRuntime
struct ContentView: View {
var body: some View {
UIRiveView(
fromResource: "juice_v7"
)
}
}

View File

@@ -282,6 +282,13 @@
C9C741EB24FC4F0500EF9516 /* transform_component.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C9C7413624FC4F0500EF9516 /* transform_component.hpp */; };
C9C741F424FC510200EF9516 /* Rive.h in Headers */ = {isa = PBXBuildFile; fileRef = C9C741F224FC510200EF9516 /* Rive.h */; settings = {ATTRIBUTES = (Public, ); }; };
C9C741F524FC510200EF9516 /* Rive.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9C741F324FC510200EF9516 /* Rive.mm */; };
C9CE8250263B6F9600F98DDB /* RiveView.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9CE824F263B6F9600F98DDB /* RiveView.mm */; };
C9CE8253263B716F00F98DDB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9CE8252263B716F00F98DDB /* UIKit.framework */; };
C9CE8255263B724900F98DDB /* RiveViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9CE8254263B724900F98DDB /* RiveViewController.mm */; };
C9CE8257263B771700F98DDB /* RiveView.h in Headers */ = {isa = PBXBuildFile; fileRef = C9CE8251263B6FA700F98DDB /* RiveView.h */; settings = {ATTRIBUTES = (Public, ); }; };
C9CE8258263B776600F98DDB /* RiveViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C9CE8256263B725600F98DDB /* RiveViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
C9CE8260263B7CC200F98DDB /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9CE825F263B7CC200F98DDB /* SwiftUI.framework */; };
C9CE8263263B806200F98DDB /* UIRiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CE8262263B806200F98DDB /* UIRiveView.swift */; };
C9D60DAA2512B01600AAA3A6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9D60DA92512B01600AAA3A6 /* CoreGraphics.framework */; };
C9D60DAC2512B04B00AAA3A6 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9D60DAB2512B04B00AAA3A6 /* QuartzCore.framework */; };
/* End PBXBuildFile section */
@@ -640,6 +647,13 @@
C9C7413624FC4F0500EF9516 /* transform_component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = transform_component.hpp; sourceTree = "<group>"; };
C9C741F224FC510200EF9516 /* Rive.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Rive.h; sourceTree = "<group>"; };
C9C741F324FC510200EF9516 /* Rive.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Rive.mm; sourceTree = "<group>"; };
C9CE824F263B6F9600F98DDB /* RiveView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RiveView.mm; sourceTree = "<group>"; };
C9CE8251263B6FA700F98DDB /* RiveView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RiveView.h; sourceTree = "<group>"; };
C9CE8252263B716F00F98DDB /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
C9CE8254263B724900F98DDB /* RiveViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RiveViewController.mm; sourceTree = "<group>"; };
C9CE8256263B725600F98DDB /* RiveViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RiveViewController.h; sourceTree = "<group>"; };
C9CE825F263B7CC200F98DDB /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/iOSSupport/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; };
C9CE8262263B806200F98DDB /* UIRiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIRiveView.swift; sourceTree = "<group>"; };
C9D60DA92512B01600AAA3A6 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
C9D60DAB2512B04B00AAA3A6 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */
@@ -649,7 +663,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C9CE8260263B7CC200F98DDB /* SwiftUI.framework in Frameworks */,
C9D60DAC2512B04B00AAA3A6 /* QuartzCore.framework in Frameworks */,
C9CE8253263B716F00F98DDB /* UIKit.framework in Frameworks */,
C9D60DAA2512B01600AAA3A6 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -797,6 +813,29 @@
path = importers;
sourceTree = "<group>";
};
C9BD3927263B64B100696C37 /* Renderer */ = {
isa = PBXGroup;
children = (
C9C741F224FC510200EF9516 /* Rive.h */,
C9C741F324FC510200EF9516 /* Rive.mm */,
C9601F29250C25830032AA07 /* RiveRenderer.hpp */,
C9601F2A250C25930032AA07 /* RiveRenderer.mm */,
);
path = Renderer;
sourceTree = "<group>";
};
C9BD3928263B65B100696C37 /* Views */ = {
isa = PBXGroup;
children = (
C9CE824F263B6F9600F98DDB /* RiveView.mm */,
C9CE8251263B6FA700F98DDB /* RiveView.h */,
C9CE8254263B724900F98DDB /* RiveViewController.mm */,
C9CE8256263B725600F98DDB /* RiveViewController.h */,
C9CE8262263B806200F98DDB /* UIRiveView.swift */,
);
path = Views;
sourceTree = "<group>";
};
C9C73EC724FC478800EF9516 = {
isa = PBXGroup;
children = (
@@ -820,11 +859,9 @@
C9C73ED324FC478800EF9516 /* Source */ = {
isa = PBXGroup;
children = (
C9C741F224FC510200EF9516 /* Rive.h */,
C9C741F324FC510200EF9516 /* Rive.mm */,
C9601F29250C25830032AA07 /* RiveRenderer.hpp */,
C9601F2A250C25930032AA07 /* RiveRenderer.mm */,
C9C73ED424FC478800EF9516 /* RiveRuntime.h */,
C9BD3928263B65B100696C37 /* Views */,
C9BD3927263B64B100696C37 /* Renderer */,
C9C73ED524FC478800EF9516 /* Info.plist */,
);
path = Source;
@@ -1277,6 +1314,8 @@
C9D60DA62512AFE900AAA3A6 /* Frameworks */ = {
isa = PBXGroup;
children = (
C9CE825F263B7CC200F98DDB /* SwiftUI.framework */,
C9CE8252263B716F00F98DDB /* UIKit.framework */,
C9D60DAB2512B04B00AAA3A6 /* QuartzCore.framework */,
C9D60DA92512B01600AAA3A6 /* CoreGraphics.framework */,
);
@@ -1290,6 +1329,8 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
C9CE8258263B776600F98DDB /* RiveViewController.h in Headers */,
C9CE8257263B771700F98DDB /* RiveView.h in Headers */,
C9601F6C251004780032AA07 /* color.hpp in Headers */,
C9BD38F5263B5E4000696C37 /* transition_number_condition.hpp in Headers */,
C9BD38ED263B5E4000696C37 /* state_machine.hpp in Headers */,
@@ -1532,6 +1573,7 @@
TargetAttributes = {
C9C73ED024FC478800EF9516 = {
CreatedOnToolsVersion = 11.6;
LastSwiftMigration = 1250;
};
C9C73ED924FC478900EF9516 = {
CreatedOnToolsVersion = 11.6;
@@ -1591,6 +1633,7 @@
C9C7414624FC4F0500EF9516 /* keyframe.cpp in Sources */,
C9BD3918263B5E9000696C37 /* state_machine_input_instance.cpp in Sources */,
C9C7413B24FC4F0500EF9516 /* core_color_type.cpp in Sources */,
C9CE8263263B806200F98DDB /* UIRiveView.swift in Sources */,
C9C7416924FC4F0500EF9516 /* root_bone.cpp in Sources */,
C9C7413E24FC4F0500EF9516 /* component.cpp in Sources */,
C9BD3904263B5E7600696C37 /* state_machine_importer.cpp in Sources */,
@@ -1631,6 +1674,7 @@
C9C7416A24FC4F0500EF9516 /* bone.cpp in Sources */,
C9C7415824FC4F0500EF9516 /* shape.cpp in Sources */,
C9601FB0251004950032AA07 /* metrics_path.cpp in Sources */,
C9CE8250263B6F9600F98DDB /* RiveView.mm in Sources */,
C98F29832513FAC30076E802 /* draw_target.cpp in Sources */,
C9C7414524FC4F0500EF9516 /* keyframe_double.cpp in Sources */,
C9C7415C24FC4F0500EF9516 /* rectangle.cpp in Sources */,
@@ -1655,6 +1699,7 @@
C9C7416024FC4F0500EF9516 /* cubic_mirrored_vertex.cpp in Sources */,
C9AEB7EF25C8904E00AE9C43 /* polygon.cpp in Sources */,
C9C7415424FC4F0500EF9516 /* points_path.cpp in Sources */,
C9CE8255263B724900F98DDB /* RiveViewController.mm in Sources */,
C9C7416324FC4F0500EF9516 /* aabb.cpp in Sources */,
C9C7414724FC4F0500EF9516 /* cubic_interpolator.cpp in Sources */,
C9C7415A24FC4F0500EF9516 /* parametric_path.cpp in Sources */,
@@ -1813,7 +1858,9 @@
C9C73EE624FC478900EF9516 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1833,6 +1880,8 @@
PRODUCT_BUNDLE_IDENTIFIER = rive.app.ios.runtime.RiveRuntime;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -1840,7 +1889,9 @@
C9C73EE724FC478900EF9516 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1860,6 +1911,7 @@
PRODUCT_BUNDLE_IDENTIFIER = rive.app.ios.runtime.RiveRuntime;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -1867,6 +1919,7 @@
C9C73EE924FC478900EF9516 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
@@ -1883,6 +1936,7 @@
C9C73EEA24FC478900EF9516 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (

View File

@@ -16,3 +16,5 @@ FOUNDATION_EXPORT const unsigned char RiveRuntimeVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RiveRuntime/PublicHeader.h>
#import <RiveRuntime/Rive.h>
#import <RiveRuntime/RiveView.h>
#import <RiveRuntime/RiveViewController.h>

25
Source/Views/RiveView.h Normal file
View File

@@ -0,0 +1,25 @@
//
// RiveView.h
// RiveRuntime
//
// Created by Matt Sullivan on 4/29/21.
// Copyright © 2021 Rive. All rights reserved.
//
#ifndef RiveView_h
#define RiveView_h
#import "Rive.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface RiveView : UIView
- (void)updateArtboard:(RiveArtboard*)artboard;
@end
NS_ASSUME_NONNULL_END
#endif /* RiveView_h */

30
Source/Views/RiveView.mm Normal file
View File

@@ -0,0 +1,30 @@
//
// RiveView.m
// RiveRuntime
//
// Created by Matt Sullivan on 4/29/21.
// Copyright © 2021 Rive. All rights reserved.
//
#import "RiveView.h"
#import "RiveRenderer.hpp"
@interface RiveView()
@end
@implementation RiveView
RiveArtboard *riveArtboard;
- (void)drawRect:(CGRect)rect {
RiveRenderer *renderer = [[RiveRenderer alloc] initWithContext:UIGraphicsGetCurrentContext()];
[renderer alignWithRect:rect withContentRect:[riveArtboard bounds] withAlignment:Alignment::Center withFit:Fit::Contain];
[riveArtboard draw:renderer];
}
- (void)updateArtboard:(RiveArtboard *)artboard {
riveArtboard = artboard;
}
@end

View File

@@ -0,0 +1,24 @@
//
// RiveViewController.h
// RiveRuntime
//
// Created by Matt Sullivan on 4/29/21.
// Copyright © 2021 Rive. All rights reserved.
//
#ifndef RiveViewController_h
#define RiveViewController_h
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface RiveViewController : UIViewController
-(instancetype)initWithResource:(NSString *)resource withExtension:(NSString *)extension;
@end
NS_ASSUME_NONNULL_END
#endif /* RiveViewController_h */

View File

@@ -0,0 +1,114 @@
//
// RiveViewController.m
// RiveRuntime
//
// Created by Matt Sullivan on 4/29/21.
// Copyright © 2021 Rive. All rights reserved.
//
#import "Rive.h"
#import "RiveViewController.h"
#import "RiveView.h"
@implementation RiveViewController
NSString *_resource;
NSString *_extension;
RiveArtboard *artboard;
RiveLinearAnimationInstance *_instance;
CADisplayLink *displayLink = NULL;
CFTimeInterval lastTime = .0;
- (instancetype) initWithResource:(NSString *) resource withExtension:(NSString *)extension {
if (self = [super init]) {
_resource = resource;
_extension = extension;
return self;
} else {
return nil;
}
}
- (void) viewDidLoad {
[super viewDidLoad];
[self forResource:_resource withExtension:_extension];
}
- (void) loadView {
RiveView *riveView = [[RiveView alloc] init];
// [riveView setBackgroundColor:[UIColor blueColor]];
self.view = riveView;
}
- (void) forResource: (NSString *) resource withExtension: (NSString *) extension {
// load the Rive data
NSString *filepath = [[NSBundle mainBundle] pathForResource:resource ofType:extension];
NSError *error;
NSData* data = [NSData dataWithContentsOfFile:filepath options:NSDataReadingUncached error:&error];
// initialize the Rive file
UInt8 *bytes = (UInt8 *) data.bytes;
RiveFile* riveFile = [[RiveFile alloc] initWithBytes:bytes byteLength:data.length];
if (riveFile == NULL) {
NSLog(@"Unable to import file: %@", resource);
return;
}
artboard = [riveFile artboard];
// update the artboard in the view
[(RiveView *)self.view updateArtboard: artboard];
NSInteger animationCount = [artboard animationCount];
// NSLog(@"Animation count: %d", (uint)animationcount);
if (animationCount > 0) {
RiveLinearAnimation *animation = [artboard animationAt: 0];
// NSLog(@"Animation name: %@", [animation name]);
_instance = [animation instance];
[_instance advanceBy:.0]; // advance the animation
[_instance applyTo:artboard]; // apply to the artboard
[artboard advanceBy:.0]; // advance the artboard
[self runTimer];
}
}
-(void) runTimer {
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
-(void) stopTimer {
if (displayLink != NULL) {
[displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
}
-(void) tick {
if (displayLink == NULL) {
// Something's gone wrong, clean up and bug out
[self stopTimer];
}
double timestamp = [displayLink timestamp];
// Last time needs to be set on the first tick
if (lastTime == 0) {
lastTime = timestamp;
}
// Calculate the time elapsed between ticks
double elapsedTime = timestamp - lastTime;
lastTime = timestamp;
// NSLog(@"Timestamp: %.1f, elapsed time: %.5f, framerate %.1f", [displayLink timestamp], elapsedTime, 1. / elapsedTime);
[_instance advanceBy:elapsedTime]; // advance the animation
[_instance applyTo:artboard]; // apply to the artboard
[artboard advanceBy:elapsedTime]; // advance the artboard
[self.view setNeedsDisplay];
}
@end

View File

@@ -0,0 +1,24 @@
//
// UIRiveView.swift
// RiveRuntime
//
// Created by Matt Sullivan on 4/29/21.
// Copyright © 2021 Rive. All rights reserved.
//
import SwiftUI
public struct UIRiveView: UIViewControllerRepresentable {
let resource: String
// This is needed to expose the view outside the framework
public init(fromResource resource: String) {
self.resource = resource
}
public func makeUIViewController(context: Context) -> RiveViewController {
return RiveViewController(resource: resource, withExtension: "riv")
}
public func updateUIViewController(_ uiViewController: RiveViewController, context: Context) {}
}