iOS for Mobile App Development

Introduction

This guide is meant for developers who wish to update the accompanying iPhone DevEdge IoT app. The open source repository lives here.

Prerequisites

  • A Mac running macOS 12 Monterey or later.
  • Xcode 14.2 or later installed on your Mac.
  • Git installed on your Mac.

Why would I want to implement the instructions in this document?

  • To be able to change the Bluetooth code, or any of the code, for the accompanying iPhone DevEdge IoT app.

What is the iPhone DevEdge IoT app?

Also known as the DevEdge IoT app, this app allows the user to see "signs of life" in the kit without having to use commands at CLI.

Some Important Things to Note

The project can be used as sample code for programmers who wish to learn how to transfer data between the T-Mobile DevEdge IoT DevKit board and an iOS app via Bluetooth. While the user interface is built in SwiftUI, the Bluetooth code can also be used for UIKit-based apps.

These are the code files most relevant for Bluetooth communication:

  • Board.swift - This models the T-Mobile DevEdge board's state by storing all the values that have been read from the connected board. The app UI reflects this model's state.
  • Bluetooth/BluetoothManager.swift - This handles discovering and connecting to the T-Mobile DevEdge IoT DevKit board, as well as reading and writing values to the board.
  • Bluetooth/DataParser.swift - This contains functions that parse values from the data provided by the connected board.
  • Extensions/CBUUID.swift - This provides identifiers for the Bluetooth services and characteristics used by the project.


Configuration

Step A

Clone the iOS repository.

  1. Open Terminal or a web browser.

  2. Download the source code for the app by doing one of two things:
    1. Type git clone https://github.com/tmobile/DevEdge-IoTDevKit-App-iOS.git in Terminal then press Return on your keyboard
    2. Navigate to https://github.com/tmobile/DevEdge-IoTDevKit-App-iOS in a web browser and download the zip file from the repository.

  3. Navigate to where the iOS files downloaded onto your computer.

  4. Open the DevEdge-IoTDevKit-App-iOS-main folder.

  5. Double click on the IoT Dev Kit Development.xcodeproj file.

  6. Xcode opens.

Step B

Set the Team and Bundle Identifier in Xcode. Setting your Team allows you to run the project on your phone.

  1. Select IoT Dev Kit Development > Signing & Capabilities > Add Account.

  2. Log in to your Apple Developer Account in Xcode to pick your development team.

  3. Set the Bundle Identifier to something that makes sense to you.

    It is good practice to use reverse domain name notation for the Bundle Identifier.

Step C

Update Board.swift, BluetoothManager.swift, DataParser.swift, and CBUUID.swift if you wish to update the Bluetooth code found in the app.

  1. Make code changes to the Board.swift, BluetoothManager.swift, DataParser.swift, and CBUUID.swift files.

  2. Save your changes and connect your iPhone to your Mac via a USB to Lightning cord.

  3. Click Run to test your Bluetooth changes.

Step D

This is an optional step. If you wish to update the Bluetooth, or any other code, in the iOS repository, follow the steps below:

  1. Create your branch.
  2. Make the changes you would like to your branch.
  3. Commit your changes to your branch.
  4. Create a pull request here to merge your branch into our main branch.

    Your changes are appreciated but may not be accepted. There is also no guarantee that they will be accepted quickly. Here are some guidelines. https://devedge.t-mobile.com/documentation-hub/open-source-documentation/contributing

  5. Ask that the pull request be merged back into our main branch.

Troubleshooting

Firmware development debugging tips

  • When connecting to a peripheral over Bluetooth, the app's Debug screen provides information about all the services and characteristics discovered for the peripheral.

  • An attempt to read a value is performed for each discovered characteristic. If the characteristic is not one the app is set up to handle, a log event that lists the received value bytes is shown in the Debug screen.
  • It is recommended to connect to your board, wait long enough for the initial read attempts to complete, and then disconnect to take a look at the received values in the Debug screen.
  • Since unhandled characteristics are not included in the app's continuous polling it may help to set the polling interval to 15 seconds or longer, in order to avoid flooding the Debug screen with log events. The polling interval can be configured in the iOS Settings app.


FAQ