Skip to content

Commit

Permalink
[Darwin] Fix CHIPTool iOS compilation (#14801)
Browse files Browse the repository at this point in the history
* Remove ping support to fix CHIPTool compilation

* Add a simple README for CHIPTool

* Restyled by prettier-markdown

* Fix typos in Readme

* Add words to the allowlist

* Update src/darwin/CHIPTool/README.md

Co-authored-by: Boris Zbarsky <[email protected]>

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Aug 9, 2023
1 parent b91f81c commit 0b0a46a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 26 deletions.
19 changes: 12 additions & 7 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ ATW
ATWC
AudioOutput
auth
autoconnect
autocompletion
autoconnect
autocrlf
autogenerated
automake
Expand Down Expand Up @@ -225,8 +225,8 @@ connstring
conntype
const
ContentApp
ContentAppPlatform
ContentApp's
ContentAppPlatform
ContentLaunch
ContentLauncher
continuousHinting
Expand Down Expand Up @@ -275,8 +275,8 @@ DCL
DCMAKE
DCONFIG
debianutils
deepnote
DEDEDEDE
deepnote
DelayedActionTime
demangle
deployable
Expand Down Expand Up @@ -338,6 +338,7 @@ DOVERLAY
downcasting
Doxygen
dpkg
dropdown
dryrun
DS
duplicative
Expand Down Expand Up @@ -543,8 +544,8 @@ jre
js
json
JTAG
Jupyter
jupyter
Jupyter
jupyterlab
KA
Kconfig
Expand Down Expand Up @@ -776,6 +777,7 @@ Passcode
PBKDF
pbuf
pbufs
pbxproj
PCA
pcaps
PDFs
Expand Down Expand Up @@ -804,7 +806,6 @@ pre
preprocessor
Presetup
prj
providerNodeId
ProductID
ProductLabel
ProductName
Expand All @@ -813,6 +814,7 @@ proto
protobuf
protos
Prover
providerNodeId
PRs
PSCAN
PSK
Expand Down Expand Up @@ -866,8 +868,8 @@ Rendez
RendezvousInformation
RendezvousParameters
RendezVousTest
REPL
repl
REPL
repo
req
Requestor
Expand Down Expand Up @@ -910,8 +912,8 @@ ScriptBinding
SDC
SDHC
SDK
sdkconfig
SDK's
sdkconfig
SDKs
SDKTARGETSYSROOT
sdl
Expand Down Expand Up @@ -1101,6 +1103,7 @@ vlatest
VLEDs
vnc
vous
VPN
VSC
VSCode
WakeOnLan
Expand Down Expand Up @@ -1130,6 +1133,8 @@ xaver
xbef
xcd
Xcode
xcodeproj
xcworkspace
xd
xdeadbeefcafe
xds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,7 @@ - (IBAction)sendMessage:(id)sender
msg = [self.messageTextField placeholder];
}

if (CHIPGetConnectedDevice(^(CHIPDevice * _Nullable chipDevice, NSError * _Nullable error) {
if (chipDevice) {
CHIPBasic * cluster = [[CHIPBasic alloc] initWithDevice:chipDevice endpoint:0 queue:dispatch_get_main_queue()];
[self updateResult:@"MfgSpecificPing command sent..."];

[cluster mfgSpecificPingWithCompletionHandler:^(NSError * _Nullable error) {
NSString * resultString = (error == nil)
? @"MfgSpecificPing command: success!"
: [NSString stringWithFormat:@"An error occurred: 0x%02lx", error.code];
[self updateResult:resultString];
}];
} else {
[self updateResult:@"Failed to establish a connection with the device"];
}
})) {
[self updateResult:@"Waiting for connection with the device"];
} else {
[self updateResult:@"Failed to trigger the connection with the device"];
}
[self updateResult:@"Not Supported"];
}

@end
96 changes: 96 additions & 0 deletions src/darwin/CHIPTool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CHIP Tool iOS Sample Commissioner App

A prototype application that demonstrates device commissioning and cluster
control.

---

- [CHIP Tool iOS Sample Commissioner App](#chip-tool-ios-sample-commissioner-app)
- [Building the Application](#building-the-application)
- [Compilation Fixes](#compilation-fixes)
- [Installing the Application](#installing-the-application)
- [Pairing an Accessory](#pairing-an-accessory)

---

## Building the Application

CHIPTool iOS can be built with the latest Xcode releases.

- Open the `Darwin.xcworkspace` file located in `src/darwin` with Xcode.

- Then select the `CHIP Tool App` scheme at the top.

- Running the `CHIP Tool App` scheme in Xcode (select the scheme and then hit
the "play button" to "run" the scheme) will attempt to compile the
application and then install it to the connected iOS device selected in the
scheme.

Because we do not share a developer group, directly running this scheme will
fail with missing signing configuration errors.

You need to update the Project configuration for CHIPTool to use your Personal
Developer account and a unique Bundle ID.

### Compilation Fixes

Before you can run the `CHIP Tool App` scheme, you need to amend the
`project.pbxproj` file for the CHIPTool project. The file is located here
`src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj`.

You can choose to amend this file via Xcode directly or manually with any text
editor. This Readme will focus on doing it via Xcode.

- With the `Darwin.xcworkspace` loaded, you should see 2 projects on the left
side pane in Xcode. `CHIPTool` and `CHIP`.

- Selecting `CHIPTool` should bring up the project configuration view in
Xcode. Next, select the `Signing & Capabilities` tab.

- Perform the following steps to enable building CHIPTool:

1. Ensure "Automatically manage signing" is checked

2. Select your Personal Team in the "Team" dropdown.

3. Change the bundle identifier from `com.chip.CHIPTool` to something
unique, like `com.chip.CHIPTool-username`. These bundle IDs get reserved
for a short amount of time and so it's best to use something only you
might think of to avoid conflicts (you'll see that the default bundle ID
does not work if you skip this step).

4. Confirm that the Signing Certificate now says "Apple Development:
<your personal account>"

Now you can install CHIPTool to your connected iOS device by clicking on the
"Play"/Run icon.

## Installing the Application

The first time you install this application to your iOS device, Xcode will not
be able to launch it. This is because iOS prevents arbitrary developer apps from
running prior to user consent. To give this application consent, navigate to
`Settings->General->VPN & Device Management` and give CHIPTool permission to
run.

Now you can launch the application from the Home screen or from Xcode by hitting
the run button once more.

## Pairing an Accessory

Once you have CHIPTool up and running, to pair an accessory simply:

- Click on the `QRCode Scanner` item in the list on screen
- Then the Camera icon on the top right corner to launch the scanner
- Then scan the QRCode of the accessory to begin commissioning it. CHIPTool
will prompt you for permission to use Bluetooth as well as to scan your
local network. Grant these requests. It will also prompt you for the WiFi
password for network the accessory should join. Note - Thread is not
supported by this application at this time.

Look for `Commissioning complete.` and `Sigma3` in the logs to know when the
device is commissioned and ready for use.

Note - CHIPTool also supports pairing via the Matter manual codes. Instead of
scanning the QRCode you can also type in the manual code. The rest of the steps
remain the same.

0 comments on commit 0b0a46a

Please sign in to comment.