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

Replacing NSCoder with Swift's Codable #868

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Vaidios
Copy link

@Vaidios Vaidios commented Sep 6, 2024

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

  • Replaced occurrences of NSKeyedUnarchiver/NSKeyedArchiver with JSONDecoder/JSONEncoder
  • Added encode function to Credentials type

📎 References

It doesn't seem like usage of this API is required in this context. Credentials type doesn't use polymorphism, which could be only handled by NSKeyedUnarchiver.

Thanks to these changes my code now properly runs inside a SPM package

Please let me know if there is something that I don't understand :)

https://forums.swift.org/t/should-i-stick-with-codable-or-switch-back-to-nscoding/61604
#862

🎯 Testing

This is not a breaking change, these code paths are covered by unit tests

@Vaidios Vaidios requested a review from a team as a code owner September 6, 2024 10:29
@Vaidios Vaidios changed the title Removing nskeyedunarchiver Replacing NSCoder with Swift's Codable Sep 6, 2024
do {
return try JSONDecoder().decode(Credentials.self, from: data)
} catch {
print(error.localizedDescription)
Copy link

@theolampert theolampert Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vaidios I know that this error was already not being surfaced here, so this is not a comment on your PR but more this process in general. If an NSCoder failure is the cause of #862 there is an argument to be made that the problem would have been easier to debug had this function either throw here and bubbled the error up or have the .noCredentials error provide a more descriptive message. What are your thoughts @desusai7 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree, it would be much easier to find a root cause if that error would be propagated.
Maybe we should throw an error such as 'credentialsParsingFailure' instead of non-descriptive 'noCredentials'.

PS. For the time being, I will remove that do-catch with print to be optional try, just as before

@Vaidios
Copy link
Author

Vaidios commented Sep 10, 2024

@theolampert sorry for tagging you here, I was just wondering if there is any button to ask for the review from maintainers and I clicked it without thinking much about it :E

@desusai7
Copy link
Contributor

desusai7 commented Sep 10, 2024

Hi @Vaidios,

Thank you for raising a PR to address this, we will look into it and get back to you !

@Vaidios
Copy link
Author

Vaidios commented Sep 19, 2024

Hey @desusai7, are there any updates on 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

Successfully merging this pull request may close these issues.

3 participants