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

Codable is unavailable in Embedded Swift and no alternative is present #78811

Open
MaxDesiatov opened this issue Jan 22, 2025 · 3 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Codable Area → standard library: `Codable` and co. diagnostics QoI Bug: Diagnostics Quality of Implementation embedded Embedded Swift existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values standard library Area: Standard library umbrella

Comments

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Jan 22, 2025

Description

Serializing and deserializing data is a frequent requirement for embedded applications.

Reproduction

Attempt to add Codable conformance to any type when Embedded Swift is enabled.

Expected behavior

A Codable conformance is generated for compatible types, or actionable diagnostic message is emitted that suggests viable alternatives.

Environment

Swift 6.1 development snapshots for any of the supported platforms.

@MaxDesiatov MaxDesiatov added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Codable Area → standard library: `Codable` and co. embedded Embedded Swift standard library Area: Standard library umbrella existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values diagnostics QoI Bug: Diagnostics Quality of Implementation labels Jan 22, 2025
@andy0808
Copy link

Serializing and deserializing data is a frequent requirement for embedded applications.

Totally agree! I was able to use this third-party JSON encoder/decoder seamlessly in a bare-metal environment without any additional dependencies. However, when I enable the embedded mode, the Internet of Things turns into the Internet of Nothing.

@Joannis
Copy link
Member

Joannis commented Jan 24, 2025

@andy0808 IkigaJSON is getting support for Embedded Swift orlandos-nl/IkigaJSON#44

@andy0808
Copy link

andy0808 commented Jan 24, 2025

@andy0808 IkigaJSON is getting support for Embedded Swift orlandos-nl/IkigaJSON#44

@Joannis That’s really awesome to hear. Thank you very much for the information. 😊 I’ll give it a try and see if it works for me.

However, based on feedback from my SwiftIO clients, I believe existentials support is crucial in many application programming scenarios. Most of my clients are originally iOS developers, with only a few having hardware experience. I can sense their disappointment with the current limitations.

I understand that balancing simplicity, performance, and binary size is an incredibly challenging task. I just wanted to share this piece of feedback from my perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Codable Area → standard library: `Codable` and co. diagnostics QoI Bug: Diagnostics Quality of Implementation embedded Embedded Swift existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants