Private APIs, Objective-C runtime, and Swift
Posted 08 Sep 2020
Sometimes when building an app, we find ourselves in a situation when we want to use a private API. It may provide some important functionality that is not exposed (yet), or we may want to work around a known platform issue. Or, you may be just debugging your code and poking around to get extra details.
Bringing the Best of SwiftUI to Our Team’s UIKit Code
Posted 26 May 2020 in Grammarly Engineering Blog
Like pretty much all our colleagues in the field, iOS developers at Grammarly are excited about SwiftUI. Released at the 2019 Apple Worldwide Developers Conference (WWDC), it represents a major step forward in Apple’s support for building great user experiences. But as much as we want to use SwiftUI for everything, we can’t. For one thing, the libraries are still new and will probably take a few years to completely stabilize. Plus, SwiftUI is only bundled in iOS 13+, and we need to continue to support Grammarly for older versions of iOS. And finally, our existing UIKit code represents a huge, years-long investment for our team—we don’t want to just throw it out.
String Index Type Safety in Swift
Posted 19 Dec 2019 in Grammarly Engineering Blog
Code is much like a conversation, and misunderstandings can happen when assumptions aren’t stated upfront. It brings to mind a quote (perhaps apocryphal) from the Enlightenment philosopher Voltaire: “If you wish to converse with me, first define your terms.” Though he is unlikely to have anticipated how this advice might apply to computer science, it rings true when considering the code development process. Misunderstandings lead to bugs—which our team found out when working with our iOS text manipulation logic.
DRY String Localization with Interface Builder
Posted 21 Aug 2017
Great applications should have great localization. And users will appreciate an option to use beloved apps in their native language. There is no excuse for developers not to support interface localization even on early stages of the development process, especially when it’s so easy to do.
I prefer to design mostly with the Interface Builder. In this article I would like to share an approach I use in my projects to localize those resources.
Generic Optional Handling in Swift
Posted 13 Aug 2017
Sometimes you want to write a generic algorithm working on any Optional
type no matter what actual type
is wrapped inside. Ok, this can be easily done with a free generic function, but what if you want to write
a Sequence
extension to remove all nil
values for example?
Things get a little bit complicated here since Optional
is not a protocol but a concrete type and so it
can’t be used as a generic type constraint.