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

Compile Errors #3

Open
reyamir opened this issue Nov 15, 2024 · 9 comments
Open

Compile Errors #3

reyamir opened this issue Nov 15, 2024 · 9 comments

Comments

@reyamir
Copy link

reyamir commented Nov 15, 2024

I've tried to use Nostr SDK in my SwiftUI app, but when compile, I've got a lot of errors

Screenshot 2024-11-15 at 10 16 37

My simple code:

Init

import SwiftUI
import SwiftData
import NostrSDK

@Observable
class Nostr {
  var client: Client = ClientBuilder.init().database(database: try! NostrDatabase.lmdb(path: "nostr.db")).build();
}

@main
struct SampleApp: App {
  @State private var nostr = Nostr()
	
  var body: some Scene {
    WindowGroup {
      ContentView().environment(nostr)
    }
  }
}

Just get the nostr state

struct ContentView: View {
  @Environment(Nostr.self) private var nostr

  var body: some View {
    NavigationSplitView {
      List {
      }
      .navigationSplitViewColumnWidth(min: 180, ideal: 200)
      } detail: {
        Text("Select an item")
      }
  }
}
@reyamir
Copy link
Author

reyamir commented Nov 15, 2024

Maybe related to this issue? mozilla/uniffi-rs#2108

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 15, 2024
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 15, 2024
@yukibtc
Copy link
Member

yukibtc commented Nov 15, 2024

Maybe related to this issue? mozilla/uniffi-rs#2108

I don't think, because I'm not using nested errors in bindings.

I opened a PR with a possible fix here: rust-nostr/nostr#633
I haven't a mac so I can't try it, are you able to test it? You can follow these steps for compilation: https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi#swift

Later, instead of use the package from the git repo, point it to /path/to/nostr/bindings/nostr-sdk-ffi/swift dir.

If it works, I'll publish the fix.

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 15, 2024
@reyamir
Copy link
Author

reyamir commented Nov 16, 2024

I still got same error

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 16, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 17, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc
Copy link
Member

yukibtc commented Nov 17, 2024

I think the issue should be fixed. At least, the previous error is no longer returned in the CI, now it return linking errors when running swift test, but I'm not sure if this is related to the GitHub Actions or is effectively an issue in the Swift Package (I not found a way to make the swift test works).

Can you let me know if now works? The fix-swift branch in https://github.com/rust-nostr/nostr repo.

@reyamir
Copy link
Author

reyamir commented Nov 18, 2024

Hi, this issue is fixed. I will add Example for Nostr Swift soon

@reyamir reyamir closed this as completed Nov 18, 2024
@reyamir reyamir reopened this Nov 18, 2024
@reyamir
Copy link
Author

reyamir commented Nov 18, 2024

image I've got a other error which say "UniFFI API checksum mismatch", but I not sure it related to your fixes or not. I've tried rebuild project but still not work.

@yukibtc
Copy link
Member

yukibtc commented Nov 18, 2024

Maybe I found the issue: the uniffi_checksum_derive crate was at another version (0.28.2 instead of 0.28.0, selected automatically). I'll publish a fix soon.

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc
Copy link
Member

yukibtc commented Nov 18, 2024

I pushed the fix. The CI still fail, but hope the "UniFFI API checksum mismatch" error is fixed.

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc
Copy link
Member

yukibtc commented Nov 18, 2024

I've finally fixed all the CI issues. I can now see the "Uniffi API checksum mismatch" error. It's weird that this happen only in Swift and not in Python or Kotlin. I opened an issue on the UniFFI repo: mozilla/uniffi-rs#2321

yukibtc added a commit to rust-nostr/nostr that referenced this issue Nov 18, 2024
Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a

Fixes rust-nostr/nostr-sdk-swift#3

Signed-off-by: Yuki Kishimoto <[email protected]>
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