apple / swift-embedded-examples

A collection of example projects using Embedded Swift
Apache License 2.0
700 stars 47 forks source link

Building steps in esp32-led-strip-sdk example fail #13

Closed spllr closed 3 months ago

spllr commented 3 months ago

I'm experiencing some issues with the Building steps from the esp32-led-strip-sdk README.

The TOOLCHAINS env var appears not to be picked up correctly.

$ cd esp32-led-strip-sdk
$ export TOOLCHAINS=...
$ . <path-to-esp-idf>/export.sh
$ idf.py set-target esp32c6
$ idf.py build

When inspecting the resulting ninja.build file it uses the Xcode toolchain instead of the one specified via TOOLCHAINS resulting in failed builds (error: unknown argument: '-import-bridging-header).

Manually updating ninja.build so it uses the nightly toolchain fixes the issue.

In any case, super cool project.

spllr commented 3 months ago

Found the thread about this issue.

spllr commented 3 months ago

FYI: The solution to my issue was found in https://oleb.net/2024/swift-toolchains/ and was me misunderstanding the TOOLCHAINS env var.

It must be set to the toolchain id, not the toolchain path.

So export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/THE_TOOLCHAIN_VERSION.xctoolchain/Info.plist) should fix this issue.

Love4yzp commented 3 months ago
TOOLCHAINS=org.swift.5101202406041a
IDF_PATH=/Users/spencer/esp/esp-idf_5_2
OPENOCD_SCRIPTS=/Users/spencer/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts
ESP_ROM_ELF_DIR=/Users/spencer/.espressif/tools/esp-rom-elfs/20230320/
IDF_PYTHON_ENV_PATH=/Users/spencer/.espressif/python_env/idf5.2_py3.9_env
ESP_IDF_VERSION=5.2
IDF_DEACTIVATE_FILE_PATH=/var/folders/w7/kjcdb5dx0tg61cnp_qxn2vr00000gn/T/tmp1o56ku9xidf_7356
IDF_TOOLS_EXPORT_CMD=/Users/spencer/esp/esp-idf_5_2/export.sh
IDF_TOOLS_INSTALL_CMD=/Users/spencer/esp/esp-idf_5_2/install.sh
_=/usr/bin/env

This is env, I have no idea why I still facing the problem:

unknown>:0: error: unknown argument: '-enable-experimental-feature'
<unknown>:0: error: unknown argument: '-import-bridging-header'
[697/952] Building C object esp-idf/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/psa_crypto.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /Users/spencer/Dev/swift-embedded-examples/esp32-led-strip-sdk/build/log/idf_py_stderr_output_11611 and /Users/spencer/Dev/swift-embedded-examples/esp32-led-strip-sdk/build/log/idf_py_stdout_output_11611
spllr commented 3 months ago

@Love4yzp Is the OOLCHAINS a typo in your comment (missing T in TOOLCHAINS) or in your export?

<unknown>:0: error: unknown argument: '-import-bridging-header' probably means your are still using the Xcode embedded toolchain.

You could check by having a look at build/ninja.build and seeing if you can still find a reference to /Applications/Xcode.app/Contents//Developer/Toolchains/XcodeDefault.xctoolchain.

if so you might want start fresh:

export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-11-a.xctoolchain/Info.plist)
idf.py fullclean; rm -r build/; idf.py set-target esp32c6; idf.py build
Love4yzp commented 3 months ago

@Love4yzp Is the OOLCHAINS a typo in your comment (missing T in TOOLCHAINS) or in your export? Sorry, I didn't copy it correctly. I've edited the comment.

I'm using MacOS(12.7.5) to build it, where I haven't installed Xcode.

I am installing the swift toolchain from https://download.swift.org/swift-5.10.1-release/xcode/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-osx.pkg.

I didn't find the ninja.build file, but I did find the build.ninja file and there is no reference to /Applications/Xcode.app/Contents//Developer/Toolchains/XcodeDefault.xctoolchain.

Thanks for your patient response.

I tried Windows and MacOS, thought my MacOS is more smooth, it's still facing problem, god.

spllr commented 3 months ago

I am installing the swift toolchain from https://download.swift.org/swift-5.10.1-release/xcode/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-osx.pkg.

You will need a Swift 6 release in order to build the project.

Love4yzp commented 3 months ago

I am installing the swift toolchain from https://download.swift.org/swift-5.10.1-release/xcode/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-osx.pkg.

You will need a Swift 6 release in order to build the project.

Okay, I'll have a try.