2/18/2023 0 Comments Obj c to swift converter![]() ![]() We favored if let and guard let statements wherever possible. We got rid of all the force unwrapping, force casting, explicit type declarations, implicitly unwrapped optionals. Fixing style not only helped the readability, but also improved our confidence on the errors. I was determined to get rid of all optionality bugs and stay close to style guide as much as possible. You can run SwiftLint on Xcode to see all the style guide exceptions on the lines they occur, and fix them quick. They help you to use the language the way it was designed to be used, and they prevent most bugs before you create them. It was “almost” casting, yet another force unwrapping error. ![]() We spent the next 100 hours debugging to find all theĪfter those, our app was initializing. Yes, our app was building, but returning no data and crashing at startup. After bunch of var to let conversions (converter defined all variables as var), we had an app that built!ĭon’t get so hyped yet, we were only beginning. Little did I know, I was going to pay a high price for this later on debugging. I used force unwrapping and force casting only to get rid of build errors. Only because I was eager to see the app built, I took a shortcut. (You don’t need to declare variable types most of the times as Swift can infer them). Or it would try to guess local variable types wrong. Converter always picks implicitly unwrapped variables instead of optionals. Most of the bugs turned out to be wrong guesses on the optionality types of class vars. My company sells a tool that in principle can be used to translate one C++ dialect to another, and that is tricky. We had to use assistant view to fix remaining bugs side by side. Automatic translation from one language to another while keeping the source code human-readable is iffy at best. This took 3 days as we go down all the way to 2 digits.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |