diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d478b81 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "uniffi" + ] +} \ No newline at end of file diff --git a/hello/platforms/HelloAppleDemoApp/Hello/Tests/HelloTests/HelloTests.swift b/hello/platforms/HelloAppleDemoApp/Hello/Tests/HelloTests/HelloTests.swift index 9c64faf..e85dc8e 100644 --- a/hello/platforms/HelloAppleDemoApp/Hello/Tests/HelloTests/HelloTests.swift +++ b/hello/platforms/HelloAppleDemoApp/Hello/Tests/HelloTests/HelloTests.swift @@ -7,5 +7,6 @@ final class HelloTests: XCTestCase { // Use XCTAssert and related functions to verify your tests produce the correct // results. // XCTAssertEqual(Hello.text, "Hello, World!") + XCTAssertEqual(rustGreeting(name: "Bob"), "Hello, Bob!") } } diff --git a/hello/platforms/HelloAppleDemoApp/HelloAppleDemoApp/ViewController.swift b/hello/platforms/HelloAppleDemoApp/HelloAppleDemoApp/ViewController.swift index 540d724..0058709 100644 --- a/hello/platforms/HelloAppleDemoApp/HelloAppleDemoApp/ViewController.swift +++ b/hello/platforms/HelloAppleDemoApp/HelloAppleDemoApp/ViewController.swift @@ -8,7 +8,7 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. - sayHello(name: "Apple Demo App") + print(rustGreeting(name: "Bob")) } } diff --git a/hello/src/hello.udl b/hello/src/hello.udl index 89c43fa..f54fd39 100644 --- a/hello/src/hello.udl +++ b/hello/src/hello.udl @@ -1,3 +1,3 @@ namespace Hello { - void say_hello(string name); + string rust_greeting(string name); }; diff --git a/hello/src/lib.rs b/hello/src/lib.rs index 3c321c7..0f6c576 100644 --- a/hello/src/lib.rs +++ b/hello/src/lib.rs @@ -1,6 +1,5 @@ - -pub fn say_hello(name: String) { - println!("Hello, {}!", name); +pub fn rust_greeting(to: String) -> String { + return format!("Hello, {}!", to); } include!(concat!(env!("OUT_DIR"), "/hello.uniffi.rs"));