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

Trouble working with Swift REPL #70

Open
jurvis opened this issue Jan 1, 2025 · 0 comments
Open

Trouble working with Swift REPL #70

jurvis opened this issue Jan 1, 2025 · 0 comments

Comments

@jurvis
Copy link

jurvis commented Jan 1, 2025

Thank you for putting together such a tool that makes exposing Rust to Swift painless!

I'm having trouble getting the package to import when running the Swift REPL against the generated package. See the following output below for the greeter crate in the hello-world-macro example.

[15:47] hello-world-macro (main) | cd greeter                       15:47:14
[15:47] greeter (main) | cargo swift package                        15:47:18
✔ Swift Package Name · Greeter
✔ Select Target Platforms · macOS, iOS
✔ 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/libgreeter.a \
        target/aarch64-apple-darwin/debug/libgreeter.a -create -output \
        target/universal-macos/debug/libgreeter.a
✔ Building target iOS
    cargo build --target aarch64-apple-ios
✔ Building target iOS Simulator
    cargo build --target x86_64-apple-ios
    cargo build --target aarch64-apple-ios-sim
    mkdir -p target/universal-ios/debug
    lipo target/x86_64-apple-ios/debug/libgreeter.a \
        target/aarch64-apple-ios-sim/debug/libgreeter.a -create -output \
        target/universal-ios/debug/libgreeter.a
✔ Generating Swift bindings...
✔ Creating XCFramework...
✔ Creating Swift Package 'Greeter'...
✔ Successfully created Swift Package in 'Greeter/'!
[15:47] greeter (main) | ls                                         15:47:45
Cargo.lock  Cargo.toml  Greeter/    generated/  src/        target/
[15:48] greeter (main) | cd Greeter/                                15:48:07
[15:48] Greeter (main) | ls                                         15:48:11
Package.swift              Sources/
RustFramework.xcframework/
[15:48] Greeter (main) | swift run --repl                           15:48:12
Building for debugging...
[7/7] Linking libgreeter__REPL.dylib
Build complete! (3.89s)
Launching Swift REPL with arguments: repl -I/Users/jurvistest/Projects/cargo-swift/swift-examples/hello-world-macro/greeter/Greeter/.build/arm64-apple-macosx/debug -L/Users/jurvistest/Projects/cargo-swift/swift-examples/hello-world-macro/greeter/Greeter/.build/arm64-apple-macosx/debug -lgreeter__REPL
Welcome to Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2).
Type :help for assistance.
  1> import Greeter
error: error while processing module import: repl.swift:2:8: missing required module 'greeterFFI'
import Greeter

any ideas why that may be the case? could there be an option in swift run that I may be missing? the package works well when imported elsewhere, otherwise. TIA!

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

1 participant