CloudKit and Serial-port Communication

Hi everyone. I am working on a project at my university where I have an Arduino that is using some sensors to read data. I wanted to go above and beyond on this project because it's for a final.

The setup consists of an Arduino that will be connected to my MacBook via USB. This Arduino is going to send data values from its sensor when it receives a command. These commands will be uploaded to the CloudKit database from the users iPhone via a button in the UI. They will then be fetched from the CloudKit database on the MacBook where they will be sent to the Arduino. When the data returns to the MacBook, it will then be uploaded to the database where the users device will fetch the updated data and display it on the screen.

I know this is not the ideal system by any means but it is what I have to work with.

I've mostly finished the iOS side of things and have a working test app but my issue is the MacBook portion of the system.

How can I preform this serial port communication and utilize CloudKit at the same time?

Answered by DTS Engineer in 708949022

How can I preform this serial port communication and utilize CloudKit at the same time?

You shouldn’t have any specific difficulty combining these things. They are both asynchronous processes, and so you’ll have to write the code carefully to avoid race conditions, but I can’t see any other complications.

You added the Command Line Tools tag to this thread, which suggests that you want to do this in a command-line tool on the Mac. That does present a complication when it comes to CloudKit, because CloudKit access is gated by restricted entitlements, ones that must be authorised by a provisioning profile.

During the bring-up phase I recommend that you do this work in a Mac app. That way Xcode can help you with the entitlement stuff. If, later on, you want to transition to a command-line tool you can do that [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Using the process described in Signing a Daemon with a Restricted Entitlement. Although please don’t try to use CloudKit from a daemon. I’m not sure if that’ll work.

I have done research on serial port communication using a macOS app a little bit ago but it seems like I will need to use a Command-line tool program. Is this correct? If I do go the Command-line tool route I will have to use cktool I believe. Will cktool allow me to use NSPersistentCloudKitContainer or similar command to allow a silent notification type fetch data system?

Accepted Answer

How can I preform this serial port communication and utilize CloudKit at the same time?

You shouldn’t have any specific difficulty combining these things. They are both asynchronous processes, and so you’ll have to write the code carefully to avoid race conditions, but I can’t see any other complications.

You added the Command Line Tools tag to this thread, which suggests that you want to do this in a command-line tool on the Mac. That does present a complication when it comes to CloudKit, because CloudKit access is gated by restricted entitlements, ones that must be authorised by a provisioning profile.

During the bring-up phase I recommend that you do this work in a Mac app. That way Xcode can help you with the entitlement stuff. If, later on, you want to transition to a command-line tool you can do that [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Using the process described in Signing a Daemon with a Restricted Entitlement. Although please don’t try to use CloudKit from a daemon. I’m not sure if that’ll work.

CloudKit and Serial-port Communication
 
 
Q