All App-o-Mat articles

How to Make Pong in SpriteKit Part III: Detecting a miss

If you play the game, you'll see that once we miss the ball, it goes off the screen and, well, then nothing happens.

We want the miss to be detected, and then for a new ball to be placed in the center so we can continue.

Let's do that.

Read more ...

How to Make Pong in SpriteKit Part II: Touch Events

In the previous article, we set up the visible elements of pong and the basic physics that governs the movement of the ball.

At the end of the article, we had the ball bouncing off the walls and paddle and moving in a gravity-free, drag-free environment.

The next thing we'll tackle is letting the players move the paddles.

Read more ...

How to Make Pong in SpriteKit: Part I

In the previous article we learned that SpriteKit games are based on physics simulations. We put an SKScene on a UIViewController and then let a ball fall to the ground based on gravity.

This game isn't very fun.

But, it's helpful to understand SpriteKit games this way.

Read more ...

Some useful CGVector Extensions for SpriteKit

When you are creating and analyzing vectors in SpriteKit, it's useful to think of them as an angle and a length, not just as a (dx, dy) pair.

Here is an extension that helps you do that.

Read more ...

Some useful SKPhysicsBody Extensions for SpriteKit nodes

Each node we create in the scene can optionally have a physicsBody associated with it. If it does, then it will have velocity and acceleration and forces, like collisions and gravity, will have an effect on them.

There are some common patterns, so it's useful to extend SKPhysicsBody. Here are two functions that are meant to be used when you create a physics body.

Read more ...

Putting a SpriteKit Scene on a View Controller

In a typical iOS app, you build your screens either with UIKit's UIViewController, UIView and possibly storyboards or you might try SwiftUI and build out a View based on an ObservableObject.

Those kinds of apps often have scrollable lists of data, forms, tabs, or hierarchical navigation suitable for a to do list or an email client.

But games are something very different.

Read more ...

How to Get HealthKit Permissions in WatchKit

The user's running distance, heart rate, and calories expended are only available if you get permission beforehand. You also need permission to save Workouts in HealthKit so that they will show up in the Fitness app or be readable by other apps.

Read more ...

How to Animate the Workout Countdown Timer

In this article we'll learn how to animate a countdown by manipulating how we set countdown. The built-in animations won't work because we can't get them to change text along with the ring, so we'll to do something a little more manual.

Read more ...

How to Develop a Workout Countdown in Watchkit

Making a countdown animation for your workout app is really not that different than any other SwiftUI based animation you might do.

But, we have to start somewhere

Read more ...

How to navigate from one page set to another in WatchKit

If you are targeting watchOS 6, and you have several possible root views, then you define each in a Storyboard and you need to navigate between them outside of SwiftUI.

Read more ...

How to develop page based navigation UI on Apple Watch

On the Apple Watch, it's possible to have a set of screens that are peers to each other. You get to each page with left and right swipes. The bottom of the screen has a dot for each page in the set, with the current one lit up.

Read more ...

Programmatic Navigation with NavigationLink on an Apple Watch

NavigationLink has built in functionality to manage the presentation and dismissal of the subview, and automatically puts a back button on the screen for you.

But, sometimes, there is a reason to send the user back to the calling view based on other things they do. In UIKit, we'd call dismiss, but in SwiftUI, we don't call methods on views to change them, we change state and let the view get re-rendered.

Read more ...

How to use NavigationLink in a SwiftUI Watch App

In iOS, we use UINavigationViewController from UIKit to create a hierarchical navigation structure. Using it, we can push views onto the view controller stack, and we automatically get a back button to take us back.

UIKit and this class are not available to Apple watch developers, and so before SwiftUI, watch app developers used WKInterfaceController's pushController method and Storyboards.

Luckily, this is easier in SwiftUI.

Read more ...

The Swift Programming Language Companion: Initialization

This article is part of a series on learning Swift by writing code to The Swift Programming Language book from Apple.

Read each article after you have read the corresponding chapter in the book. This article is a companion to Initialization.

Read more ...

Apple WatchKit Breathe Animation Tutorial

In the last article, we drew the initial state of the the Breathe app. Now let's learn how to animate it.

Read more ...

Apple Watch App SwiftUI Simple Example Views

If you already tried out SwiftUI on the iPhone, most of what you know works the same on the watch. If you haven't, here are simple recreations of user interfaces in two of the built-in Apple Watch apps.

Read more ...

Apple Watch SwiftUI App Tutorial: Creating the Project

This tutorial will use Xcode to make a minimal Apple Watch app. But, before you move on, it's a good idea to understand what it did so that you'll know how to add to it later.

Read more ...

Why You Should Use SwiftUI for Developing Apple Watch Apps

Xcode 12 and watchOS 7 are not perfect, but they are much better than their immediate predecessors and I would say are about as capable as pre-SwiftUI WatchKit. I am confident that adopting this for any new Apple Watch app is the right decision.

Read more ...

The Swift Programming Language Companion: Inheritance

This article is part of a series on learning Swift by writing code to The Swift Programming Language book from Apple.

Read each article after you have read the corresponding chapter in the book. This article is a companion to Inheritance.

Read more ...

The Swift Programming Language Companion: Subscripts

At this point, you should have read Subscripts in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Methods

At this point, you should have read Methods in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Properties Part 2

This is Part 2 of the Properties companion. It builds on Properties Part 1, so read that if you have not and do the exercises. The exercises in this chapter require that you have done those already.

Read more ...

The Swift Programming Language Companion: Properties Part 1

At this point, you should have read Properties in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Structures and Classes

At this point, you should have read Structures and Classes in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Enumerations

At this point, you should have read Enumerations in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Closures

At this point, you should have read Closures in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Review of Basics to Functions (Part 2)

We've covered the basics up to functions, and reviewed them in the last article, and we're going to continue reviewing those chapters in this one.

Read more ...

The Swift Programming Language Companion: Review of Basics to Functions

We've covered the basics up to functions, and now I'll provide exercises that review topics from all of those chapters.

Read more ...

The Swift Programming Language Companion: Functions (Part 2)

In the last article, I gave some exercises for functions. Here are some more to cover the more advanced features.

Read more ...

The Swift Programming Language Companion: Functions

At this point, you should have read Functions in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Control Flow

At this point, you should have read Control Flow in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Collection Types

At this point, you should have read Collection Types in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Strings and Characters

At this point, you should have read Strings and Characters in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Basic Operators

At this point, you should have read Basic Operators in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: Optionals

At this point, you should have read The Basics in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

Read more ...

The Swift Programming Language Companion: The Basics

So, to recap, we have the book and Xcode side-by-side. We're going to read the first chapter, The Basics, and write code in the Playground.

Read more ...

The Swift Programming Language Companion: Introduction

The intended audience for this guide are people that don't know Swift and possibly don't know any other programming language.

Read more ...

Make a Test Build to use with Appium

When you make GUI tests using XCUI directly in Xcode, it will automatically build the app for you when you run the test. Appium, however, is run completely outside of Xcode, so you must supply a build for it.

Read more ...

Setting Accessibility Identifiers for Appium in iOS

If you are considering Appium or any other GUI testing framework for iOS, like XCUI Tests, then the first thing you should do is start using accessibility identifiers. Without them, your test scripts will be much more brittle.

Read more ...