How to force a compilation error in Swift using

Опубликовано: 27 Июнь 2023
на канале: Vincent Pradeilles
1,425
66

#iOS #swift #softwaredeveloper #iosdeveloper

Thank you for watching this video 🙌

➜ Website: https://www.swiftwithvincent.com
➜ Twitter:   / v_pradeilles  
➜ GitHub: https://github.com/vincent-pradeilles/
➜ LinkedIn:   / vincentpradeilles  

TRANSCRIPT

Have you ever used #error() in Swift? If you're an SDK or an API developer, you might find it quite useful. Let me explain why! Imagine you need to create a sample project that shows how to use your SDK or your API. The first thing you probably want your users to do with the sample project is to update it with their own API key. So you need a way to easily and immediately direct their attention in that direction when they first open the sample project. And this is when #error() comes to the rescue. By adding an #error() at the place where users should write their API key, you will force the compiler to emit a compilation error, which is guaranteed to catch a user's attention and direct them to the place you want. That's all for this video, I hope you've enjoyed it. Remember to subscribe to the channel, it's really a big support for me. Thank you for watching, and see you next time!


Смотрите видео How to force a compilation error in Swift using онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Vincent Pradeilles 27 Июнь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,425 раз и оно понравилось 66 людям.