Introduction to iOS HealthKit with Core Bluetooth using Swift 4

My original article — Introduction to HealthKit with Core Bluetooth — was published on appcoda.com.

[Download the Xcode 9 project from GitHub so you can follow along with my code explanation and try iOS HealthKit features yourself!]

In a previous tutorial, I discussed the technology, applications, and benefits of Apple’s Core Bluetooth framework. I showed you how to build an app that wirelessly connected to a Bluetooth® heart rate monitor (HRM) — a small, portable, and “wearable” device. My sample app’s code read heart rate data from the HRM, but it didn’t do anything with the heart rate data except display it in real-time on an iPhone’s screen. While edifying and interesting, there are already a bazillion apps in the App Store that can read heart rate data, and other wearable data, using Core Bluetooth. What about doing something interesting with that data, like analyzing it, deriving value-added and meaningful results from it, and sharing it with researchers? That’s where Apple’s HealthKit framework shines. Please download the Xcode 9 project written is Swift 4 so you can follow along with my discussion.

Continue reading “Introduction to iOS HealthKit with Core Bluetooth using Swift 4”

Tutorial: Core Bluetooth communication with a wearable in Swift 4

The original article – Working with Core Bluetooth in iOS 11 – was published on appcoda.com.

[Download the Xcode 9 project from GitHub so you can follow along with my code explanation and try iOS Core Bluetooth features yourself!]

As iOS developers, we’re very aware that humans love connectivity. Obviously, we love to communicate with each other using wireless devices. More recently, we’ve come expect that we can communicate with what once were considered standalone, ordinary devices. We’ve come to love, even expect, that some of those wireless devices can gather and analyze data about ourselves (usually “wearables”). So many devices have become intrinsic parts of our lives that we’ve coined a now commonly-used phrase, the “Internet of Things” or “IoT.” There are now billions of wireless, communicable devices on the planet. In this tutorial, we’re going to focus on just one segment of the IoT: Bluetooth®.

I’ll explain the essential concepts behind Bluetooth® technology, show you how getting proficient in Bluetooth® software development presents you with a tremendous career opportunity, remind you that you can’t distribute an app that uses Bluetooth® without determining if you need to go through “qualification,” provide you with an overview of Apple’s Core Bluetooth framework (see also here), and finally, walk you through the development of an iOS app in Swift 4 that monitors a person’s heart rate via Core Bluetooth via a Bluetooth® device.

Continue reading “Tutorial: Core Bluetooth communication with a wearable in Swift 4”

UPDATE: The UICollectionView is much more than a grid or matrix

Get started by [downloading the full Xcode project from GitHub.]

Let’s talk about the UICollectionView, a rich, configurable, and powerful iOS user interface component. I will write code in Swift 3.0 to create a UICollectionView to which I can add, select/highlight, deselect/unhighlight, and remove UICollectionViewCell’s. I’ll show you that I can select, deselect, add, and remove one cell at a time, or multiple cells at a time. And most importantly, I’ll demonstrate the importance of the relationship between a UICollectionView and its data source, and the importance of keeping a UICollectionView and its data source synchronized. You can download my entire Xcode 8.2.1 project. Feel free to reuse my code as long as you follow the terms of the license agreement. Today, we’re going to build a basic but completely functional instance of the UICollectionView in Swift 3.0 as illustrated by the following video:

Continue reading “UPDATE: The UICollectionView is much more than a grid or matrix”

iOS 101 or … Basic animation, Auto Layout, and view geometry – Part 5

[Download the full Xcode project from GitHub.]

Today, I’m going answer all the questions I posed in this series of posts entitled “Basic animation, Auto Layout, and view geometry – Part X” (see parts 1, 2, 3, and 4). I’ll help you understand how how I created the following iPhone animation using Swift 3.0 — and/or how to get started with your first iOS app:

Continue reading “iOS 101 or … Basic animation, Auto Layout, and view geometry – Part 5”

Using Xcode 7 with the iOS 10 SDK

Today, we’ll be discussing getting an older version of Xcode (7) to work with a newer version of the iOS SDK (10). When done reading this article, you’ll be able to build, link, install, and debug apps in/from Xcode 7 onto iPhones/iPads/iPods running iOS 10. (If you don’t need background, just skip to the solution.) The main reasons for doing this?

  • You have an app built for the last iOS version (9) that has a problem when running in the latest iOS version (10) and you’d like to debug the code; and/or,
  • Apple releases a new beta iOS (10) and beta Xcode (8), you want to see how your current, stable code (built for iOS 9) runs on the new beta iOS (10), but you don’t want to trash your current, stable Xcode (7) installation with the beta Xcode (8).

Continue reading “Using Xcode 7 with the iOS 10 SDK”