Another week, another feature for our app. This week I had to make some research about how to add some curved text to our app.
I searched a lot and end up on different resources: from an official (but outdated) Apple example with CoreText, to a post on Stack Overflow written in Swift 2, 3, and 4. However, none of them offered a straightforward, easy to follow, mathematically sound approach.
I made several experiments, trials, and errors, before reaching this solution. I had to properly understand several concepts of how the text can be rendered on the screen and it could be useful to write them on (digital) paper for both the future me and anyone who could need it. …
I have never worked with gestures in iOS. Seems weird, but it’s the truth. This week, I had to integrate a gesture in an app to test a couple of things that we are developing, but I struggled a bit to make it work properly with our MVVM architecture.
At Bending Spoons we are extremely eager to help out our colleagues and to share what we know. Lucky for me, I have a colleague who worked on that same issue before and shared a nice trick to solve the problem elegantly. …
This week I’d like to explore a UI-related topic. When implementing an app, there is often the need to create an onboarding experience, a tutorial, or some other feature for which we want to obscure part of the interface to make the relevant parts pop out and grab the user's attention.
Although this may look like a simple task, there isn’t any straightforward way to achieve this. So, today I want to share a way to do it. …
This week I was exploring some API to work with images and to apply some filters. The default way to do that is by using the
CoreImage framework. It leverages the GPU to apply special filters to your images so that you can plug them into your UI with some amazing effects.
Everything seems to work fine if you have to work with a single image. The typical steps to apply a filter are the following:
CIImage, we can use the
applyingFilter(_:parameters:) method to obtain a new image, modified by the filter. …
This week an interesting question has been raised in Bending Spoons (virtual) office about how the iOS Lifecycle works. To properly frame the problem, you need to know that we can interact with the lifecycle of iOS in two different ways:
application(_:didFinishLaunchingWithOptions:)) to respond to changes in the steps of the lifecycle.
UIApplication.shared.applicationStateto know in which state the app is in a given moment in time. This enum can assume three different values:
Last week we discussed how to export the dependencies of our Snake app to gain full control over our codebase. We also finalized the test of the state we were not able to finish a couple of weeks ago.
In the process of factoring out the dependencies, we worked on the timer, moving it from the
Reducer to the
Environment to have the possibility to control it. However, we did not use it in our tests. …
Last week we end up our article with a cliffhanger: we were about to test what happens when the snake eats the mouse, but we could not do it properly. In fact, as soon as the snake eats the mouse, the reducer uses a static function to create a random location for a new mouse. …
This is the fourth article of a series. These are the previous articles:
Welcome back to another article on the Composable Architecture. Today I’d like to explore how to test the state updates of our app.
Testability is one of the pillars of the Composable Architecture by pointfree.co: this concept is so important that they created a whole sub-framework called
ComposableArchitectureTestSupport that is already shipped within the Composable Architecture.
The TestSupport is built on top of the
ComposableArchitecture and the Apple
XCTest framework. …
This is the third article of a series on how to implement an app with SwiftUI and Swift Composable Architecture. You can find the previous articles at the following links:
Last two weeks we created the basic UI and the basic logic for our Snake game. If you ever played Snake, you know that the original game was slightly different: the snake moves continuously in the current direction and the player can only change where it’s heading. Moreover, whenever the snake hits itself, the game ends.
Last week we introduced the concept of Effects: this is (complex) logic that the app uses to interact with the external world, and, more generally, to perform computation. …
This is the second article of a series on how to write an app using SwiftUI and Swift Composable Architecture by https://pointfree.co.
The first episode can be found here.
In last week's article, we explored how to write the UI of the Snake classic game. We used SwiftUI, the new framework from Apple. In the final code, we had the UI and a first version of the logic. The logic was intertwined in the
body field of our
ContentView: not a really good thing! When we write an app we would like to decouple the UI from the Logic.
There are several solutions that can help here. At Bending Spoons we developed our own framework for that, called Katana. However, as I like to explore new technologies, I want to try a new framework I have been studying in the past months: Swift Composable Architecture (SCA) by https://pointfree.co. …