apple / swift-matter-examples

An Embedded Swift Matter application running on ESP32-C6
https://apple.github.io/swift-matter-examples/tutorials/tutorial-table-of-contents/
Apache License 2.0
212 stars 16 forks source link

Something is missing in tutorials #14

Open lorenzofiamingo opened 2 weeks ago

lorenzofiamingo commented 2 weeks ago

I was struggling to run the command idf.py set-target esp32c6 in the "Explore the smart light example" tutorial. This was the error I encountered:

// ...
CMake Error at third_party/connectedhomeip/config/esp32/components/chip/CMakeLists.txt:308 (message):
The 'gn' command was not found. Make sure you have GN installed.Or have
followed necessary build preparations stated in BUILDING.md.

Following the suggestions in this link I tried running source path/to/connectedhomeip/scripts/activate.sh. This command also failed, but after that I tried re-runningidf.py set-target esp32c6 and this time it worked. I think some dependency, which was somehow installed by source path/to/connectedhomeip/scripts/activate.sh, is missing in the tutorial.

However, this wasn't enough to make the example work, as now idf.py build wasn't working. I thought the problem was the new swift-driver missing:

$ ~/Library/Developer/Toolchains/
swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a.xctoolchain
swift-latest.xctoolchain

$ TOOLCHAINS=org.swift.59202406131a swift --version
<unknown>:0: warning: using (deprecated) legacy driver, Swift installation does not contain swift-driver at: '/Library/Developer/CommandLineTools/usr/bin/swift-driver-new'
Apple Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Target: arm64-apple-darwin24.0.0

I fixed this using:

$ sudo xcode-select \
  --switch /Applications/Xcode-beta.app/Contents/Developer

Then I was able to build and flash and monitor, but when I try to connect to Matter the Home app displays "Unable to Connect to Network". Now I'm not being able to find a solution for this... any idea?

vtthanh83 commented 3 days ago

Hi @lorenzofiamingo

First I also met the same issue, however my case it was git-lfs missing issue during esp-matter clone which caused the connectedhomeip repo was not successfully loaded. After installing git-lfs and re-cloning esp-matter repo, running esp-matter/install.sh would install all the tool needed including gn, you don't have to re run source path/to/connectedhomeip/scripts/activate.sh as calling this script is a part of esp-matter/install.sh if the esp-matter repo is cloned fully without issue.

Hope this helps!