diff --git a/runtimes/apple/apple.mdx b/runtimes/apple/apple.mdx index 1f4fbe39..0ac1b0b0 100644 --- a/runtimes/apple/apple.mdx +++ b/runtimes/apple/apple.mdx @@ -11,10 +11,6 @@ import { Apple } from "/snippets/constants.mdx" - - A new runtime is available as part of the existing Apple runtime package. The new runtime is experimental and may be subject to breaking changes. The legacy runtime is still supported and will continue to be supported in the near future, but is now considered to be in maintenance mode. It is recommended to begin using the new API in new projects and provide feedback, and to investigate migrating existing projects to the new API when feasible. - - ## Overview This guide documents how to get started using the Apple runtime library. Rive runtime libraries are open-source. The source is available in its [GitHub repository](https://github.com/rive-app/rive-ios). @@ -67,10 +63,10 @@ Follow the steps below for a quick start on integrating Rive into your Apple app ``` - The new API types are behind the `RiveExperimental` SPI, so the standard runtime import must be prefixed with `@_spi(RiveExperimental)`. + The new Apple runtime is available in the same Swift package and CocoaPods pod as the legacy runtime. Both runtime APIs are available in the same package, so you can import the runtime using the same import statement. ```swift - @_spi(RiveExperimental) import RiveRuntime + import RiveRuntime ``` @@ -81,8 +77,6 @@ Follow the steps below for a quick start on integrating Rive into your Apple app ```swift // In an async context let worker = try await Worker() - // In a sync context - let worker = try Worker() ``` For more information on threading, see [Threading](#threading). @@ -97,24 +91,19 @@ Follow the steps below for a quick start on integrating Rive into your Apple app ```swift Local File let worker = try await Worker() - // In a sync context - let worker = try Worker() - let file = File(source: .local("my_file", Bundle.main), worker: worker) + let file = try await File(source: .local("my_file", Bundle.main), worker: worker) ``` ```swift Remote URL let worker = try await Worker() - // In a sync context - let worker = try Worker() - let file = File(source: .url(URL(string: "https://example.com/my_file.riv")!, worker: worker)) + let url: URL = URL(string: "https://example.com/my_file.riv")! + let file = try await File(source: .url(url), worker: worker) ``` ```swift Data let worker = try await Worker() - // In a sync context - let worker = try Worker() let data: Data = ... - let file = File(source: .data(data), worker: worker) + let file = try await File(source: .data(data), worker: worker) ``` @@ -127,9 +116,7 @@ Follow the steps below for a quick start on integrating Rive into your Apple app ```swift UIKit let riveView = RiveUIView({ let worker = try await Worker() - // In a sync context - let worker = try Worker() - let file = File(source: .local("my_file", Bundle.main)) + let file = try await File(source: .local("my_file", Bundle.main), worker: worker) return try await Rive(file: file) }) view.addSubview(riveView) @@ -146,7 +133,7 @@ Follow the steps below for a quick start on integrating Rive into your Apple app // After having created a `Rive` object, you can initialize your view. AsyncRiveUIViewRepresentable { let worker = try await Worker() - let file = File(source: .local("my_file", Bundle.main)) + let file = try await File(source: .local("my_file", Bundle.main), worker: worker) return try await Rive(file: file) } } @@ -227,11 +214,11 @@ Follow the steps below for a quick start on integrating Rive into your Apple app - For basic usage, see the [Marty](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Experimental/MartyView.swift) example in our Example app. + For basic usage, see the [Marty](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Concurrency/MartyView.swift) example in our Example app. - For a more complete example, see the [Quick Start](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Experimental/QuickStartView.swift) example in our Example app, which demonstrates how to use data binding. + For a more complete example, see the [Quick Start](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Concurrency/QuickStartView.swift) example in our Example app, which demonstrates how to use data binding. - For examples on how to pause and resume animations, as well as set frame rate, see the [Player](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Experimental/PlayerView.swift) example in our Example app. + For examples on how to pause and resume animations, as well as set frame rate, see the [Player](https://github.com/rive-app/rive-ios/blob/main/Example-iOS/Source/Examples/Concurrency/PlayerView.swift) example in our Example app. @@ -421,8 +408,6 @@ Follow the steps below for a quick start on integrating Rive into your Apple app ```swift // In an async context let worker = try await Worker() - // In a sync context - let worker = try Worker() let file = try await File(source: ..., worker: worker) ``` diff --git a/runtimes/apple/artboards.mdx b/runtimes/apple/artboards.mdx index 0274b93e..889002bb 100644 --- a/runtimes/apple/artboards.mdx +++ b/runtimes/apple/artboards.mdx @@ -38,7 +38,7 @@ import { Apple } from "/snippets/constants.mdx" Remember that the Rive configuration for a view is the `Rive` type. In the overview, we show initializing a `Rive` object with a file, opting to use the default artboard and state machine. However, you can initialize a `Rive` object with a specific artboard: ```swift let worker = try await Worker() - let file = try await File(source: .local("my_file", Bundle.main)) + let file = try await File(source: .local("my_file", Bundle.main), worker: worker) let artboardByName = try await file.createArtboard("Artboard") let rive = try await Rive(file: file, artboard: artboardByName) ``` diff --git a/runtimes/apple/caching-a-rive-file.mdx b/runtimes/apple/caching-a-rive-file.mdx index 7ef33cc1..dd38b323 100644 --- a/runtimes/apple/caching-a-rive-file.mdx +++ b/runtimes/apple/caching-a-rive-file.mdx @@ -34,7 +34,8 @@ import Overview from "/snippets/runtimes/caching/overview.mdx" } // Load and cache the file once - let file = try await File(source: ..., worker: Worker()) + let worker = try await Worker() + let file = try await File(source: ..., worker: worker) // Create a builder with the cached file let builder = RiveBuilder(file: file) diff --git a/runtimes/apple/data-binding.mdx b/runtimes/apple/data-binding.mdx index e2ecd1a6..0baed1a1 100644 --- a/runtimes/apple/data-binding.mdx +++ b/runtimes/apple/data-binding.mdx @@ -74,20 +74,20 @@ import { Apple } from "/snippets/constants.mdx" // When using a view model by name: // A blank view model instance - var blankInstance = try await file.createViewModelInstance(from: .blank(from: .name("ViewModel"))) + var blankInstance = try await file.createViewModelInstance(.blank(from: .name("ViewModel"))) // The default instance for the view model - var defaultInstance = try await file.createViewModelInstance(from: .name("ViewModel")) + var defaultInstance = try await file.createViewModelInstance(.viewModelDefault(from: .name("ViewModel"))) // An instance by name from the view model - var namedInstance = try await file.createViewModelInstance(from: .name("Instance", from: .name("ViewModel"))) + var namedInstance = try await file.createViewModelInstance(.name("Instance", from: .name("ViewModel"))) // Alternatively, using the default view model for an artboard let artboard: Artboard = ... // A blank view model instance - blankInstance = try await file.createViewModelInstance(from: .blank(from: .artboardDefault(Artboard))) + blankInstance = try await file.createViewModelInstance(.blank(from: .artboardDefault(Artboard))) // The default instance for the view model - defaultInstance = try await file.createViewModelInstance(from: .viewModelDefault(from: .artboardDefault(Artboard))) + defaultInstance = try await file.createViewModelInstance(.viewModelDefault(from: .artboardDefault(Artboard))) // An instance by name from the view model - namedInstance = try await file.createViewModelInstance(from: .name("Instance", from: .artboardDefault(Artboard))) + namedInstance = try await file.createViewModelInstance(.name("Instance", from: .artboardDefault(Artboard))) ``` diff --git a/runtimes/apple/layouts.mdx b/runtimes/apple/layouts.mdx index e7f95762..691b3379 100644 --- a/runtimes/apple/layouts.mdx +++ b/runtimes/apple/layouts.mdx @@ -27,11 +27,12 @@ import ResponsiveLayouts from "/snippets/runtimes/layouts/responsive-layouts.mdx You can set the fit and layout options on a `Rive` object. The `.fit` can be updated at runtime without creating a new `Rive` object. - For all possible options, see [Fit.swift](https://github.com/rive-app/rive-ios/blob/main/Source/Experimental/View/Fit.swift) + For all possible options, see [Fit.swift](https://github.com/rive-app/rive-ios/blob/main/Source/Concurrency/View/Fit.swift) ```swift // Set a fit and alignment for an artboard that does not use layouts - let file = try await File(source: ..., worker: Worker()) + let worker = try await Worker() + let file = try await File(source: ..., worker: worker) var rive = try await Rive(file: file, fit: .contain(alignment: .center)) // Update the fit and alignment at runtime rive.fit = .fitWidth(alignment: .topCenter) @@ -157,7 +158,8 @@ import ResponsiveLayouts from "/snippets/runtimes/layouts/responsive-layouts.mdx When creating a new `Rive` object, you can set the fit to layout, with two options for the scale factor: automatic or explicit. ```swift - let file = try await File(source: ..., worker: Worker()) + let worker = try await Worker() + let file = try await File(source: ..., worker: worker) // Create a new Rive object with a layout fit that automatically determines the scale factor based on the screen the view is being displayed on var rive = try await Rive(file: file, fit: .layout(scaleFactor: .automatic)) // Or, use an explicit scale factor diff --git a/runtimes/apple/migrating-from-legacy.mdx b/runtimes/apple/migrating-from-legacy.mdx index 0e997377..fdc8efcc 100644 --- a/runtimes/apple/migrating-from-legacy.mdx +++ b/runtimes/apple/migrating-from-legacy.mdx @@ -21,22 +21,12 @@ This guide covers: ## Package and Import -The new Apple runtime is available in the same Swift package and CocoaPods pod as the legacy runtime. - -The new Apple runtime APIs are currently behind the `@_spi(RiveExperimental)` SPI: - -```swift -@_spi(RiveExperimental) import RiveRuntime -``` - -Compared to the legacy runtime: +The new Apple runtime is available in the same Swift package and CocoaPods pod as the legacy runtime. Both runtime APIs are available in the same package, so you can import the runtime using the same import statement. ```swift import RiveRuntime ``` -This is a temporary transition mechanism while the new API remains experimental. - ## Asynchronous APIs The new runtime is built around Swift Concurrency. Most setup and query operations are asynchronous and should be called from an async context. @@ -482,7 +472,7 @@ The new runtime binds artboards with a typed property descriptor and `setValue` ```swift let worker = try await WorkerProvider.shared.worker() let file = try await File(source: .local("my_rive_file", Bundle.main), worker: worker) -let viewModelInstance = try await file.createViewModelInstance(from: .name("My View Model")) +let viewModelInstance = try await file.createViewModelInstance(.viewModelDefault(from: .name("My View Model"))) let artboardProperty = ArtboardProperty(path: "path/to/artboard") let artboard = try await file.createArtboard("My Artboard") @@ -574,7 +564,7 @@ In the new runtime, update the bound value after the view is created. No explici let worker = try await WorkerProvider.shared.worker() let file = try await File(source: .local("my_rive_file", Bundle.main), worker: worker) -let instance = try await file.createViewModelInstance(from: .name("My View Model")) +let instance = try await file.createViewModelInstance(.viewModelDefault(from: .name("My View Model"))) let property = StringProperty(path: "path/to/string") let rive = try await Rive(file: file, dataBind: .instance(instance)) let riveView = RiveUIView(rive: rive) diff --git a/runtimes/apple/state-machines.mdx b/runtimes/apple/state-machines.mdx index a338eafb..853c5535 100644 --- a/runtimes/apple/state-machines.mdx +++ b/runtimes/apple/state-machines.mdx @@ -44,7 +44,7 @@ import { Apple } from "/snippets/constants.mdx" ```swift let worker = try await Worker() - let file = try await File(source: .local("my_file", Bundle.main)) + let file = try await File(source: .local("my_file", Bundle.main), worker: worker) let artboardByName = try await file.createArtboard("Artboard") let stateMachine = try await artboardByName.createStateMachine("StateMachine") let rive = try await Rive(file: file, artboard: artboardByName, stateMachine: stateMachine) diff --git a/snippets/constants.mdx b/snippets/constants.mdx index f8c52601..679e1d6e 100644 --- a/snippets/constants.mdx +++ b/snippets/constants.mdx @@ -1 +1 @@ -export const Apple = { currentRuntimeName: "New Runtime (Experimental)", legacyRuntimeName: "Legacy Runtime" }; \ No newline at end of file +export const Apple = { currentRuntimeName: "New Runtime", legacyRuntimeName: "Legacy Runtime" }; \ No newline at end of file