rolandleth / LTHPasscodeViewController

iOS 7 style Passcode Lock
MIT License
615 stars 143 forks source link

Adds Support for Swift Package Manager #208

Closed jaerod95 closed 5 months ago

jaerod95 commented 3 years ago

Adds support for SPM. See README.md for instructions on how to add it to your project.

Finally got around to fixing this up again. Now that Apple supports Resources I was able to import the Localizations. I added to the LTHPasscodeViewControllerStrings method to search for the SPM bundle if it didn't find a localized string since Apple moves those localizations into its own bundle.

jaerod95 commented 3 years ago

The reason I needed to change the LTHPasscodeViewControllerStrings was due to how the new SPM tooling processes resources. Basically it compiles them into a bundle and exposes that bundle to Swift and Objc. I gathered most of my information on what that looks like from this article: https://darjeelingsteve.com/articles/How-to-Use-Module-Resources-in-Objective-C-SPM-Packages.html

rolandleth commented 3 years ago

Thanks for sharing the article!

Hmm, is there any way to test the package before merging? Can I add it to a project by entering the URL of your dev branch? Not sure what the syntax would be, maybe https://github.com/SimpleNexus/LTHPasscodeViewController/tree/dev?

jaerod95 commented 3 years ago

Thanks for sharing the article!

Hmm, is there any way to test the package before merging? Can I add it to a project by entering the URL of your dev branch? Not sure what the syntax would be, maybe https://github.com/SimpleNexus/LTHPasscodeViewController/tree/dev?

Yes! You can simply add https://github.com/SimpleNexus/LTHPasscodeViewController as the git source, then on the rules page, just select branch and point it at dev as seen in the picture below: Screen Shot 2021-04-08 at 10 16 45 AM

rolandleth commented 3 years ago

Cool, I'll give it a go today, thanks!

rolandleth commented 3 years ago

Hey! Very sorry for the long delay, but I managed to give it a go today. I added the package to a Swift project and everything works, except localization. Maybe I'm not doing it properly, but I set the project to use English and German, I added a Localizable.strings file, but the passcode view isn't localized.

Either I'm doing something wrong, or the macro isn't working properly 🤔🤔 Can you get localization to work when using the passcode as a package?

The demo project is properly localized.

jaerod95 commented 2 years ago

@rolandleth Sorry for the delay, got distracted for a quick....8 months haha. However, I updated the code to work with localization (nice catch by the way). There was an issue where I was looking in the wrong bundle. The last two commits fix that. Let me know if there are any other issues.

rolandleth commented 5 months ago

@jaerod95 This has to be the slowest moving PR in history 🙈 I tested it and it works, I think it's good to merge, thank you!