All posts by Denis Kutlubaev

iOS Developer, creator of Tornado Browser and many other popular apps

Removing Git branches by mask

When working in a team with Git, you often have to create and delete branches. If you are a terminal user like me, you can optimize branch deletion as follows. Maybe someone will come in handy, I use it all the time.

Before:

Apply:

After:

How to add the SwiftLint without pain

Why do you need SwiftLint?

  1. It speed ups code reviews, you stop wasting time on code formatting, force casting, and other common issues
  2. It improves the code quality, code becomes more readable, and maintainable

Integration

1. Add SwiftLint to a podfile

Or use another option from the official documentation.

2. Add this .swiftlint.yml config file to the project root folder

The main trick to make integration easy is to disable all rules at first.

3. Build a project, add additional rules to the disabled_rules section, if there are many warnings for them

4. Delete rules from the disabled_rules section one by one and fix all the warnings

5. Leave the trailing_whitespace and other rules that you don’t want to fix in the disabled_rules section

In the end, you will have something like this in your config file.

Some ideas on how to fix common code issues

Force Cast Violation: Force casts should be avoided. (force_cast)

Problem:

Solution:

Force Try Violation: Force tries should be avoided. (force_try)

Problem:

Solution:

Exceptions

In very rare cases you will not be able to fix the warning. For example, when you use a framework and you cannot easily change its API. Then you can switch off a SwiftLint rule for a particular code block using // swiftlint:disable rule_name and // swiftlint:enable rule_name comments.

Мой конспект Apple Event June 2021


Apple показали iOS 15, Mac OS Monterey и многое другое. Это мой конспект, который я использую, чтобы не забыть важные моменты для себя. Записи сделал с точки зрения возможностей практического применения.

Что нового для пользователей

Live Text

  • Можно будет фотографировать названия, состав товаров и переводить в текстовый вид, чтобы находить инструкции, отзывы в интернете, страницы товаров у производителей.
  • Можно фотографировать объявления на стенах и переводить в цифровой текстовый вид,
  • чтобы потом копировать адрес, телефон.

Maps

  • Immersive walking instructions можно будет использовать в поездках в места, где это хорошо работает.

Universal Controls

  • Можно будет использовать iPad как второй переносной экран к Macbook

Safari Tab groups

  • Это лучше, чем закладки в папках, так как закладки остаются навсегда, но при этом не хочется захламлять свои закладки временными вкладками, которые хочется продолжить изучать только завтра.

Spatial Audio

  • AirPods Pro дают не только шумоподавление, но и пространственный звук, который стал еще лучше

iOS Focus

  • По моему личному опыту фокус очень важен для продуктивности. Можно будет группировать уведомления с приложений. Я выключал все уведомления со всех мессенджеров, кроме рабочего и со всех соц. сетей. Из-за этого я иногда пропускал важные сообщения. Теперь верну их, но создам для них отдельную группу, чтобы читать их только когда не работаю.

Shortcuts app on Mac

  • Любая автоматизация увеличивает производительность. Я уже использую автоматизацию в Trello для обновления чек-листов и задач на день. Можно будет использовать для автоматизации открытия наборов окон перед работой над разными проектами. Это позволит быстрее приступать к работе.

Privacy

  • Борьба со спамом и трекингом, анонимность в интернете – это хорошо и важно. Privacy в Apple Mail позволит запретить трекинг открытия письма через скрытый пиксель. Появится защита IP адреса в Mail.
  • С помощью Hide My Email в составе iCloud + можно будет создавать о прокси email адреса для всяких мелких сервисов и магазинов, чтобы скрыть свой настоящий адрес

SpotLight, Health, Photos, Watch OS

  • Много мелких улучшений, хорошо в целом

SharePlay, Facetime, Message

  • API SharePlay станет доступно для приложений
  • Не использовал и не собираюсь – не хватает кроссплатформенности и ее не добавили.

Что нового для разработчиков

APIs

  • SharePlay
  • Voice isolation, wide spectrum audio, portrait mode for video conferencing apps
  • New APIs for Focus and Notifications, for screen time
  • RealityKit, Object Capture для мерчендайза с AR

Swift

  • Concurrency (async, await, actor)

AppStore

  • Multiple product pages
  • In-App events

XCode Cloud

  • build in cloud
  • test in cloud in parallel
  • distribute to testers

TestFlight for Mac

Ссылки

Apple Event 2021, WWDC

https://www.apple.com/apple-events/june-2021/

iOS 15

https://www.apple.com/ios/ios-15-preview/

Mac OS X Monterey

https://www.apple.com/macos/monterey-preview/

iOS – How to remove “Back” text from the back button

The best solution is to create base classes for UIViewController and UITableViewController and override their init methods. This will allow you to add ViewControllers to the NavigationController programmatically after a rootViewController. If you put this code in the ViewDidLoad method, it will not be called in this case and the next controller will be pushed with a back text.

BaseViewController in Objective C:

BaseTableViewController:

Using SFSafariViewController to open URL inside app without transitioning to Safari or using WebView

RxSwift/RxCocoa example:

Merging Three Git Repositories Into One Repository Without Losing File History

Let’s assume that we have three separate git repos named uremont-client, uremont-service, uremont-sdk. We want to create a new repo, named uremont-ios, that contains all those repos in separate folders to have one single repo.

Why do we want to do this? In my case I had two apps and one sdk for them, and it was inconvenient for me to push changes to three separate repos while I was working with these projects and sdk at the same time.

Let’s start.

Terminal setup to allow git to move all folders except one. We will need this later.

Create a new folder uremont-ios and initialize git repo:

Add remote of first old project uremont-client that we want to merge to the new git repo and fetch it:

Merge first old project uremont-client to the new repo:

Move all folders and files of that old project to the separate folder inside of our new project:

Commit changes:

Similarly merge second old project uremont-service to the new repo:

And third:

Finally, add a new remote to our new repo and push it:

Chaining example on RxSwift

This is one of the reasons I love RxSwift. It allows to chain requests beautifully.

Here I authorize user by getting auth token, then I request userInfo, then I request profile.

Что нового в iOS 12

ARKit 2
Multiuser and Persistent AR. – сохранение данных из AR сессии в приложении, многопользовательский режим AR.
Object Detection. – распознавание объектов реального мира и добавление их в AR приложения.

Siri Shortcuts
Siri предсказывает быстрый доступ (shortcuts) для действий в приложении.

Health Records
Доступ к информации о здоровье в приложениях.

Effects
Показ стикеров и сообщений в iMessage в виде эффектов.

Interactive Controls in Notifications
Полная кастомизация уведомлений.

Authentication Services
Позволяет шарить логин-сессию между Safari и приложением, чтобы логинить пользователя проще.

CarPlay for Navigation Apps

Network Framework
Доступ к протоколам TLS, TCP, UDP.
URLSession, работающий с HTTP, построен поверх этого фреймворка.

Natural Language
Получение метаданных из текста.

Deprecation of OpenGL ES
OpenGL ES deprecated, необходимо использовать только Metal.

Получение строки, содержащей склонения дней дня день

Достаточно часто используемая штука, поэтому решил сохранить сниппет:

Использование:

Результат: 11 дней