This week, I figured out I was missing a relevant part in my exploration of the automated UI Tests: the interaction with Apple dialogs. They can appear in various moments, to ask for user permissions for example. How can we interact with them?
A first guess would be that they behave like the rest of the app: we could query them with the
XCUIElement APIs. However, that is not (directly) the case: such dialogs can be prompted in non-deterministic moments. It is the system that decides when to present them.
Therefore, let’s see together how we can work with them,
I prepared a very simple app to test them and to check how they work. The app adds the
NSCameraUsageDescription key in the
Info.plist and it is composed of a simple view with a couple of labels to track the current camera state. It also has a button to trigger the permission dialog. …
I already talked about UI Testing in several other articles and I find this topic fascinating. While discussing with my colleagues at Bending Spoons how we could use them, it emerged that it could be cool to have a recording of the
UITest execution. This could save a ton of time for our QA colleagues, for example.
I take a look at the matter and I’d like to share with you how we can automatically record any
UITest, in a completely automatic way.
I prepared a small app to test this approach. The code of the app is not relevant. However, I think that starting with a small, simple project is a very good approach for this kind of test. …
Every time we write an iOS app there is at least one screen where the user has to input something: their username and password to log in, their name in a game, a note, …
The keyboard handling is a basic use case but Apple forces us to manage it manually. This somehow annoys me so let’s see how we can automate this, once and for all.
The first step in solving a problem is to understand how the process is working at the moment.
When we add a control on the screen — such as a
UITextField — , we launch the app and we tap on the control, the keyboard appears and we are able to input some text. …
Swift is an interesting language. It is very friendly for new developers: its syntax is concise and simple to grasp, as well as its main concepts.
However, it takes a lot of time to really master it. Every feature of the language has some details that are deeper than what described in swift.org’s Language Guide.
In today’s article, I’d like to explore some more advanced usages of
Enums are extremely powerful and they are often underused or misused. I hope to shed some light on ways to use them that you may have not thought about.
Starting with the simplest idea,
enum can be used to express alternatives: you need to choose between
swimming? Use an
enum! You need to list the days of the week? …
In 2019 Apple presented SwiftUI, a new UI framework to develop our apps in a declarative way. Before that, all the iOS apps have to use UIKit to implement their UI.
SwiftUI promises incredibly advantages while developing:
Therefore, the overall goal to achieve is to reduce the development time required to build an App. …
With iOS14, Apple introduced a new framework to implement widgets:
WidgetKit. Widgets are small pieces of UI, rendered in the Springboard, that offer quick access to some information from our apps. They come in 3 sizes: small, medium, and large. A small widget occupies the space of 4 app icons. A medium one, the space of 8 app icons. A large one, the space of 16 app icons.
Widgets can only be implemented in
SwiftUI and, by quoting the documentation:
Widgets present read-only information and don’t support interactive elements such as scrolling elements or switches. …
It could happen that the output of a feature of your app is not easy to unit test because it is something visual, like an image or a video. Or maybe, the main goal of your app is to implement some fancy filter to apply to a picture.
Even in these cases, we would want something that can protect us against changes in the codebase and reassure us that the implemented logic is sound and solid. What can we do in these contexts where unit tests looks not that useful?
The people from pointfree.co have developed and open-sourced a very interesting library called Snapshot Testing. Thanks to this library, we can take a snapshot of a view controller, a view, or any object, and compare them to see if anything has changed in the codebase. This kind of testing is called regression testing and it is extremely useful when we build our app incrementally: it can prevent some unwanted changes in the UI. …
The main way to show some text to the users is through
UILabels. Labels let us customize their text with some attributes. Most of us always use the same attributes to customize them.
NSAttributedString API’s offer so many customization possibilities that I took some time to explore them. In today’s article, I’d like to share them with everybody, showing how they behave so that, the next time, we could use the right attribute for the job.
Starting from the basics, the first customization point is about changing fonts, font size, and colors. …
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. …