0

I have a .riv file with two artboards (see screenshot): • Button Play • Stars

In SwiftUI I’m loading it with RiveRuntime. If I don’t specify an artboard, it loads the first artboard (Button Play) and works. If I do specify artboardName: "Stars", the app crashes saying it can’t find the artboard.

What am I doing wrong? Bug or my setup?


//
//  ContentView.swift
//  testRive
//
//  Created by Damiano Miazzi on 06/11/2025.
//

import SwiftUI
import RiveRuntime

struct ContentView: View {
    
  
    
    private let vm2 = RiveViewModel(
            fileName: "star",
            stateMachineName: "State Machine 1",
            artboardName: "Stars"
        )
    
    
    var body: some View {
        VStack {
            Text("Hello")
            vm2.view()
                
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

if I don't specified the artboard, the file works and load the first artboard which is Button Play

img

4
  • i think while adding .riv in xcode 'Copy items if needed' missing due to this reason it's not able to find. Commented Nov 10 at 7:11
  • I don't understand, what do you mean? I drag the item and I flag the copy items if need the file is in my project for sure because if I don't specify the artboard the file works Commented Nov 10 at 10:03
  • can you remove that .riv file from xcode and add it again? Commented Nov 10 at 10:06
  • rather than that you code looks good to me. Commented Nov 10 at 10:07

1 Answer 1

0

i tried a sample .riv file it's look good to me. it's working for me. can you check with your animation?

here is my code and animation.

animation link: https://rive.app/community/files/24532-45875-posture-animation/

import SwiftUI
import RiveRuntime

struct ContentView: View {
    // Initialize the Rive view model with the file name and optionally the artboard
    @StateObject var riveModel = RiveViewModel(fileName: "1animation", artboardName: "soldier selection")

    var body: some View {
        // Display the animation
        riveModel.view()
            .frame(width: 300, height: 300)
    }
}

#Preview {
    ContentView()
}

enter image description here

i seen some difference in your animation can you please check with you animation.

Sign up to request clarification or add additional context in comments.

1 Comment

I found the issue the art board need to be turn into components otherwise doesn’t work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.