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

Importing Build error #3

Open
bevice1 opened this issue Oct 21, 2023 · 2 comments
Open

Importing Build error #3

bevice1 opened this issue Oct 21, 2023 · 2 comments

Comments

@bevice1
Copy link

bevice1 commented Oct 21, 2023

Hi, when i use the Swift Package Manager to import your Library. I get a build error "cannot find type 'ResponseType' in scope".
If I clone the repo and import it as a local library, there are no build errors but none of your examples work. Despite importing LibP2PKadDHT it cannot find classes like BasicKadDHT.

XCode Version 15.0 (15A240d)
iOS 17

How is your package supposed to be used in a project? I saw the installation guide but thats only for importing to another package.

Kind regards

@btoms20
Copy link
Member

btoms20 commented Oct 21, 2023

Hey @bevice1,

It looks like I forgot to tag the latest commits to the swift-libp2p-kad-dht repo. Swifts package manager picks up the last tagged commit by default instead of the just the main branch. It's tagged now, so it should work.

In your project, if you right click on swift-libp2p-kad-dht in the dependencies on your left hand column and click update package it should updated to 0.1.0 and then build without errors.

As for using the swift-libp2p suite in an iOS / macOS project you can reference the iOS Chat App Example to get some ideas on how to start. In that example I create a Libp2p Service Singleton where I configure and manage the libp2p service (installing mplex, noise, and in that example mdns, but you can swap that for kadDHT). You can then pass the libp2p service to your various views throughout the project using dependency injection or as an environment variable in SwiftUI.

The Kad DHT package is in a pretty rough place at the moment. I was just testing it and noticed that peer discovery events don't get published correctly. So I'll try and set aside some time this week to tidy some things up and hopefully get the peer discovery portion working correctly.

Let me know if you have any more issues / questions, I'm happy to help.

@bevice1
Copy link
Author

bevice1 commented Oct 27, 2023

Hi, it works!
I have been playing around with the iOS Chat App example for a bit. And i discovered the an error at the peer discovery:

Attempting to restore chats Restored chats! 2023-10-27T10:18:44-0400 info libp2p.application[DqgaPu] : [LibP2P] New EventBus Initialized: [25989B38-FBF0-475A-ADFD-22E76DD885D1] 2023-10-27T10:18:44-0400 notice libp2p.application[DqgaPu] : [LibP2P] PeerID: 12D3KooWDqgaPudFzGugzpVHuM3rfxqz2KZqQMik26YNNstazySS 2023-10-27T10:18:44-0400 notice libp2p.application[DqgaPu] : mDNS=DqgaPu [LibP2PMDNS] mDNS ipV4: [IPv4]10.10.13.162/10.10.13.162:0 2023-10-27T10:18:44-0400 notice libp2p.application[DqgaPu] : mDNS=DqgaPu [LibP2PMDNS] mDNS ipV6: [IPv6]fe80::ce0:a8f0:634b:77db/fe80::ce0:a8f0:634b:77db:0 Attempting to start service 2023-10-27T10:18:52-0400 notice libp2p.application[DqgaPu] : [LibP2P] TCP Server starting on 0.0.0.0:10000 send failed: 22 send failed: 22 2023-10-27T10:18:52-0400 notice libp2p.application[DqgaPu] : [LibP2PChatExample] LibP2P Started! send failed: 22 2023-10-27T10:18:56-0400 notice libp2p.application[DqgaPu] : [LibP2PChatExample] We discovered a peer: PeerInfo(peer: <peer.ID QJmcc7>, addresses: [/ip4/127.0.0.1/tcp/10000/p2p/12D3KooWQJmcc7GdGKbrETfEmNThkr5ozDTGV6sWzocJtJubvGLH, /ip6/fe80::ce0:a8f0:634b:77db/tcp/10000/p2p/12D3KooWQJmcc7GdGKbrETfEmNThkr5ozDTGV6sWzocJtJubvGLH]) 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] Listeners Noise Handshake Identity Key does not match the Peer we dialed. Aborting Handshake and closing connection...(ExpectedRemotePeerID) 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] Expected: b58: 12D3KooWQJmcc7GdGKbrETfEmNThkr5ozDTGV6sWzocJtJubvGLH, cid: bafzaajaiaejcbv2kmpkyayngmhhmqbwefoyn7i22wymh3pbq4tpnfuiognqvubjc 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] =/= 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] Provided: b58: 12D3KooWDqgaPudFzGugzpVHuM3rfxqz2KZqQMik26YNNstazySS, cid: bafzaajaiaejcao6fervru3fvontjxsmsqycp7zrey6sqy5zkbwsqp4nabfimimt3 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] Expected Key Type: idOnly, nil 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : NOISE=initiator [LibP2PNoise] Provided Key Type: isPublic, Optional(LibP2PCrypto.LibP2PCrypto.Keys.GenericKeyType.ed25519) 2023-10-27T10:22:27-0400 error ARCConnection[DqgaPu][BBDA1] : [LibP2P] Failed to secure channel: remotePeerMismatch

Is this the bug you were talking about?

Do you have any ideas how to fix 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