Today I'd like to share a story of how I made a game in Swift. It will have nothing to do with inDrive, and frankly, it'll have very little to do with iOS. There'll be a little bit of Swift and some game development stuff that I've learned. Also, there'll be very little technical stuff, so i shouldn't be too complicated or boring. Well, I hope it's not boring.
This is a text version of my talk @ CocoaHeads Kazakhstan from Decemebr 2022
Since 2021 I have been a part of inDrive, and to be more specific - on city-to-city travel feature of the app, where people can find and create long-distance car rides.
I wanted to tell a story of how the product I'm working at is Version 3.0, why Version 1.0 had been online for so long, and meanwhile, what happened to Version 2.0?
Swift was introduced in 2014 by Apple to replace Objective-C as the main programming language for all the Apple's platforms. It's fast, powerful, secure, and very beginner-friendly. Half a year later it was open sourced, so it was a matter of time when it would be ported to other platforms. Besides iOS, iPadOS, macOS, tvOS and watchOS it's officially supported on Linux and Windows. It even works on Android, but with some tweaks, you can read about it on Swift's official GitHub repo.
However, you can't really make much on these platforms besides some scripts and CLI programs. That is because a language is only a part of a code base. The other part is a User Interface framework. We have UIKit for mobile, AppKit for macOS and of course SwiftUI for both. Actually, there is a platform which does not require a UI framework. What is it?
By the end of 2020 I was still rocking a mid-2012 MacBook Pro as a personal machine. Waiting on those M2 chips, really, I'm a little skeptical of the overall success of M1 considering the fact that every first generation of an Apple product is usually followed by a much better product generation. iPhone 3G outlived the original iPhone, iPad2, which I was a proud owner of for a long time, was officially supported by Apple for way more than that thick first gen iPad. Thus, it was my prediction that M1, while being a huge success for Apple, would be followed by M2, even more powerful chip. So that's my excuse.
There are two categories a type in Swift can fall into:
- Value Type
- Reference Type
An instance of a Value type makes and keeps a unique copy of an original element. When the original element changes, the change does not affect the created copy.
An instance of a Reference type, however, creates a reference, and it shares a single copy with the original element. This way, when the original element changes, it affects all the existing references.
When I first started this blog I was writing about everything I found interesting, mostly programming and internet stuff. Eventually it transitioned into a basic programmer's blog with tutorials and nothing more. That's boring even to me, and I'm writing all this! Besides, I haven't posted in a while because I couldn't think of anything interesting to write a tutorial about.
That's why I decided to freshen things up a little bit and changed one little detail - I will now be writing in English. I don't think I have many (any) readers, especially English-speakers, so it's pretty much for myself.
Создание UIKit-проекта без использования Storyboard в первый раз кажется чем-то сложным, на самом же деле основные проблемы при попытке запустить проект без сторибордов могут появиться при неправильном установке, удалении ненужных файлов и зависимостей.
Одно из незначительных, но полезных нововведений - "история" в навигации. Чтобы вернуться на начальный экран Navigation Controller раньше приходился нажимать "назад" столько раз, сколько потребуется, но в iOS 14 есть возможность выбрать определённый экран в цепочке, по которой мы пришли к текущему, а также вернуться на первоначальный экран одним движением.
На первый взгляд полезная штука, про которую первое время придётся вспоминать, однако есть одна проблема. Современные дизайны часто используют кнопку "назад" без текста, из-за чего меню с историей выглядит пустым.