Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error generating bindings: No such file or directory (os error 2) #69

Open
Jomy10 opened this issue Nov 18, 2024 · 2 comments
Open

Error generating bindings: No such file or directory (os error 2) #69

Jomy10 opened this issue Nov 18, 2024 · 2 comments

Comments

@Jomy10
Copy link

Jomy10 commented Nov 18, 2024

I am running into the following error:

Failed due to the following error:
Could not generate UniFFI bindings for udl files due to the following error:
 No such file or directory (os error 2)

Steps to reproduce:

├── Cargo.toml
├── build.rs
└── src
    ├── lib.rs
    └── lib.udl

Cargo.toml

[package]
name = "expression_interpreter"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["staticlib", "lib"]
name = "expression_interpreter"

[dependencies]
uniffi = "0.28"

[build-dependencies]
uniffi = { version = "0.28", features = ["build"] }

build.rs

fn main() {
    uniffi::generate_scaffolding("./src/lib.udl").unwrap();
}

lib.rs

uniffi::include_scaffolding!("lib");

pub struct Executor {
}

impl Executor {
    pub fn new() -> Self {
        Executor {}
    }
}

lib.udl

namespace ExpressionInterpreter {};

interface Executor {
  constructor();
};

Full build output:

✗ cargo swift package -n ExpressionInterpreter -p macos
✔ Building target macOS
    cargo build --target x86_64-apple-darwin
    cargo build --target aarch64-apple-darwin
    mkdir -p target/universal-macos/debug
    lipo target/x86_64-apple-darwin/debug/libexpression_interpreter.a \
        target/aarch64-apple-darwin/debug/libexpression_interpreter.a -create -output \
        target/universal-macos/debug/libexpression_interpreter.a                                                                            x Generating Swift bindings...

Failed due to the following error:
Could not generate UniFFI bindings for udl files due to the following error:
 No such file or directory (os error 2)

More info

Lipo should have succeeded because the files are present:

✗ file target/x86_64-apple-darwin/debug/libexpression_interpreter.a
target/x86_64-apple-darwin/debug/libexpression_interpreter.a: current ar archive
✗ file target/aarch64-apple-darwin/debug/libexpression_interpreter.a
target/aarch64-apple-darwin/debug/libexpression_interpreter.a: current ar archive
✗ file target/universal-macos/debug/libexpression_interpreter.a
target/universal-macos/debug/libexpression_interpreter.a: Mach-O universal binary with 2 architectures: [x86_64:current ar archive] [arm64]
target/universal-macos/debug/libexpression_interpreter.a (for architecture x86_64):	current ar archive
target/universal-macos/debug/libexpression_interpreter.a (for architecture arm64):	current ar archive
@Jomy10
Copy link
Author

Jomy10 commented Nov 18, 2024

After some more playing around, I found this error occurs because the Swift package name is not the same as the rust crate name defined in Cargo.toml.

@antoniusnaumann
Copy link
Owner

After some more playing around, I found this error occurs because the Swift package name is not the same as the rust crate name defined in Cargo.toml.

thanks for coming back and pointing this out. I'll see if there is an elegant fix here or at least a warning that clarifies this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants