pointfreeco / swift-custom-dump

A collection of tools for debugging, diffing, and testing your application's data structures.
MIT License
800 stars 89 forks source link

Add `if !os(WASI)` for SwiftWasm #53

Closed inamiy closed 2 years ago

inamiy commented 2 years ago

Related:

This PR adds if !os(WASI) for the scopes where some of the Foundation classes don't work in SwiftWasm.

Porting code from other platforms - Swift and WebAssembly

stephencelis commented 2 years ago

@inamiy Thanks for the PR! Because we're not quite familiar with why some of these APIs are available on WASM and some aren't I think we'd like to get some CI in place before merging. (Like why the extension Date isn't allowed but as Date in the NSDate extension is.) We'll try to look into that soon!

inamiy commented 2 years ago

@stephencelis For extension Date, IIRC the issue rather lives in TimeZone which SwiftWasm's modified Foundation doesn't allow it as mentioned in the above doc:

A few other types are unavailable in browsers or aren't standardized in WASI hosts, such as support for sockets and low-level networking, or support for time zone files, and they had to be disabled.

inamiy commented 2 years ago

And here's the steps I tried to detect compile errors (It's in doc too):

# swift-latest = SwiftWasm toolchain
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"

# For lib compile:
swift build --triple wasm32-unknown-wasi

# In the SwiftWasm demo app:
carton dev
stephencelis commented 2 years ago

@inamiy Thanks! That'll be helpful in getting CI up and running :smile:

stephencelis commented 2 years ago

@inamiy Got CI working on another branch, thanks! Gonna merge this, get the rest into main, and kick off a release.