As someone who’s interested in computers and coding you keep hearing about the Internet of Things (IoT) and how cool it is. But, what use cases are there for our day to day lives other than colorful light bulbs or fridges that update you that you finished your ice cream last night after your Netflix binge? How can you enable the really interesting use cases of IoT? This article will show you, using Google Cloud IoT Core, how you can connect and control your phone from the cloud and open up new possibilities for your IoT ideas.

Image for post

Objectives

  • Install Podfile and dependencies
  • Connect iPhone to IoT Core
  • Receive Commands from IoT Core to the iPhone

Before you begin

This tutorial assumes that you already have some background in iOS development and the basics of creating a registry, registering devices, and subscribing to a PubSub topic.

If you haven’t done this before, first go through the steps in IoT Core Getting Started to learn the basics of IoT Core.

Setting up and installing Pods

Before connecting to IoT Core using MQTT, you need to first install CocoaPods. CocoaPods is an application-level dependency manager for Swift and many other languages that provides a standard format for managing external libraries. If you are using OSX, you should already have CocoaPods installed. To manually download or update CocoaPods use:

sudo gem install cocoapods

After verifying that CocoaPods is installed, install the dependencies. For this step, you need to initialize CocoaPods. Using Terminal or similar program, run the following command from the directory that contains the **_.xcodeproj _**file:

pod init

This initializes the CocoaPods and creates a podfile where you can include the libraries you need.

After CocoaPods is successfully initialized, a podfile will be created. This podfile holds all of the dependencies needed for your project, let’s add SwiftJWT and CocoaMQTT to the podfile:

target ‘iOS_MQTT’ do
pod ‘SwiftJWT’
use_frameworks! ## Add this if you are targeting iOS 8+
pod ‘CocoaMQTT’
end

Next, install the libraries to your project:

pod install

After the pods are successfully installed, make sure that the SwiftJWT and CocoaMQTT are included in the Xcode project. Click the .xcworkspace file to open the project.

If you’re getting an error that says “SwiftJWT or CocoaMQTT is not included” you will need to add them to the project dependencies.

#internet-of-things #iot #technology #google #google-cloud-platform #cloud

Controlling Your Phone From the Cloud
1.15 GEEK