Skip to content

Replace partial MiniFoundation with FoundationEssentials#307

Merged
keeshux merged 10 commits intomasterfrom
feature/foundation-essentials
Feb 27, 2026
Merged

Replace partial MiniFoundation with FoundationEssentials#307
keeshux merged 10 commits intomasterfrom
feature/foundation-essentials

Conversation

@keeshux
Copy link
Member

@keeshux keeshux commented Feb 27, 2026

Give up on the overwhelming –and dumb– task of replacing Foundation completely. The footprint with FoundationEssentials is only marginally bigger, for dramatic benefits. If going serious at some point, dropping Swift would be a much wiser choice in the future.

Basically, merge MiniFoundation Native and Compat targets. Then export Foundation on Apple, and FoundationEssentials everywhere else. In the latter case, add some custom code behind the MINIF_COMPAT symbol to attain feature-parity with Foundation for the sake of the library.

MiniFoundation folders:

  • Foundation (Apple)
  • FoundationCompat (cross)
  • FoundationEssentials (Apple and cross)
  • Everything else is shared as before

Steps:

  • Delete SWON, rely on Codable/JSONEncoder/JSONDecoder
  • Delete redundant reimplementations (Data, Date, FileManager, URL, UUID)
  • Delete unused C code
  • Delete "mini" wrappers in the middle (e.g. MiniURLProtocol)
  • Return contents of URL path, not of a generic URL (would potentially require networking)
  • Implement compatible regular expressions in C++ (still targeting Swift 5.x)
  • Always export Dispatch
  • Disambiguate UUID on Windows

CMake issues:

Export Foundation on Apple, and FoundationEssentials everywhere else. In
the latter case, add some custom code behind the MINIF_COMPAT symbol to
attain feature-parity with Foundation for the sake of the library.

Steps:

- Delete SWON, rely on Codable/JSONEncoder/JSONDecoder
- Delete redundant compat entities (Data, Date, URL, UUID)
- Delete unused C code
- Returns contents of path, not generic URL (requires networking)
- Always export Dispatch
- Disambiguate UUID on Windows
Prepend FoundationEssentials just in case
@keeshux keeshux self-assigned this Feb 27, 2026
@keeshux keeshux added bug Something isn't working enhancement New feature or request refactoring Reworks the software architecture and removed bug Something isn't working labels Feb 27, 2026
@keeshux keeshux moved this to In Progress in 2026 Q1 Android Feb 27, 2026
@keeshux keeshux added this to the Multiplatform: ABI milestone Feb 27, 2026
@keeshux
Copy link
Member Author

keeshux commented Feb 27, 2026

Doubts:

  1. Given a file URL, this method is not available in FoundationEssentials and therefore reimplemented this way.

Are these methods equivalent?

  • FileManager.contentsOfDirectory(atPath: url.path)
  • FileManager.contentsOfDirectory(at: url)
public func contentsOfDirectory(at url: URL) throws -> [URL] {
    let items = try contentsOfDirectory(atPath: url.filePath())
    return items.map {
        URL(filePath: $0, relativeTo: url)
    }
}
  1. Are we overriding too much in the FoundationEssentials folder, given that Apple Foundation doesn't need manual implementations?

Specifically:

  • FileManager.contentsOfDirectory(at:)
  • String.replacingOccurrences(of:with:)

@keeshux keeshux merged commit ed54203 into master Feb 27, 2026
1 check passed
@keeshux keeshux deleted the feature/foundation-essentials branch February 27, 2026 20:26
@keeshux keeshux moved this from In Progress to Done in 2026 Q1 Android Feb 27, 2026
@keeshux keeshux added the Cross Building on non-Apple platforms label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cross Building on non-Apple platforms enhancement New feature or request refactoring Reworks the software architecture

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant