Skip to content

Make swap types public and exportable#15

Open
pablof7z wants to merge 5 commits intozeugmaster:mainfrom
pablof7z:main
Open

Make swap types public and exportable#15
pablof7z wants to merge 5 commits intozeugmaster:mainfrom
pablof7z:main

Conversation

@pablof7z
Copy link
Copy Markdown

This PR makes the swap types ( and ) public and exportable by:

  • Moving them outside of the extension to ensure proper symbol export
  • Adding public initializers for both structs
  • Maintaining backward compatibility with typealias in the extension

This change allows external modules to properly access and use these swap types when importing the CashuSwift library.

@zeugmaster
Copy link
Copy Markdown
Owner

Hi Pablo 👋

Could you go into some more detail about what issues you are having with the current implementation and symbol export?

I am not against making SwapRequest and SwapResponse public (although they were meant only for internal use in the swap functions) and have also considered removing the CashuSwift namespace, but not in a piecemeal way, but a full, backwards compatible refactor (including some other updates to the interface).

If you let me know your use case and requirements I will make sure to include fixes in that overhaul ASAP.

@pablof7z
Copy link
Copy Markdown
Author

Hey @zeugmaster ; I'm having a ton of issues with linking issues; I'm brutally new to all things Swift, but what I'm finding is that I can build just fine when building in Xcode in the context of iOS apps, but just swift for CLI tools gives me all kinds of trouble about (per claude)

an issue with the CashuSwift dependency where internal symbols like SwapRequest, RestoreRequest, SwapResponse, etc. are not properly exposed or linked for the arm64 architecture.

CashuSwift Linking Issue

Problem: Internal CashuSwift types are not properly exported as public symbols for linking.

Missing Symbols (all for arm64 architecture):
•  CashuSwift.SwapRequest.init()
•  CashuSwift.RestoreRequest.init()  
•  CashuSwift.SwapResponse type metadata
•  CashuSwift.RestoreResponse type metadata
•  CashuSwift.KeysetRestoreResult.init()
•  Protocol conformance descriptors for Encodable/Decodable

Root Cause: These types are declared as internal in CashuSwift but are being referenced by static functions in the library itself (in swap.swift and restore.swift). When the library is compiled, these internal symbols aren't exported in the final binary, causing "undefined symbols" errors when linking against CashuSwift.

Location: The errors reference swap.swift.o and restore.swift.o object files within CashuSwift.

Fix Needed: CashuSwift needs to either:
1. Make these types public instead of internal
2. Restructure the code to avoid exposing internal types in public API surfaces
3. Ensure proper symbol export during library compilation

These types are used by NDKSwift and need to be public to avoid linking errors.
- Rename Sources/cashu-swift to Sources/CashuSwift
- Rename Tests/cashu-swiftTests to Tests/CashuSwiftTests
- Update Package.swift test target name
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

Successfully merging this pull request may close these issues.

2 participants