'How to use UserDefaults inside a swift package that can fetch data from main Swift codebase?

I have a package (say, "PackageDemo") that is imported inside my application (say, "ApplicationDemo"). I have some methods in PackageDemo that needs data to be fetched from UserDefaults that were saved by ApplicationDemo.

Please let me know, shall you need further clarifications.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source