Matter Example Projects in SDK 3.0.x Failed to Build on Mac OS

Hi,

All my matter projects failed to build when working with SDK 3.0.x. It looks like some python issues. The error from the build log is below. 

[11/23] Generating new Factory Data...
FAILED: matter_template/zephyr/factory_data.hex /Users/x/Developer/embedded/nordic/ws/x/matter_template/build/matter_template/zephyr/factory_data.hex 
cd /Users/x/Developer/embedded/nordic/ws/x/matter_template/build/_sysbuild && /opt/nordic/ncs/toolchains/ef4fc6722e/opt/[email protected]/bin/python3.12 /opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py --sn 11223344556677889900 --date 2022-01-01 --vendor_id 65521 --product_id 32768 --vendor_name Nordic\ Semiconductor\ ASA --product_name not-specified --hw_ver 0 --hw_ver_str prerelease --dac_cert /opt/nordic/ncs/v3.0.2/modules/lib/matter/credentials/development/attestation/Matter-Development-DAC-FFF1-8000-Cert.der --dac_key /opt/nordic/ncs/v3.0.2/modules/lib/matter/credentials/development/attestation/Matter-Development-DAC-FFF1-8000-Key.der --pai_cert /opt/nordic/ncs/v3.0.2/modules/lib/matter/credentials/development/attestation/Matter-Development-PAI-FFF1-noPID-Cert.der --spake2_it 1000 --spake2_salt U1BBS0UyUCBLZXkgU2FsdA== --discriminator 0xF00 --passcode 20202021 --include_passcode --overwrite --product_finish other --generate_onboarding --enable_key 00112233445566778899AABBCCDDEEFF -o /Users/x/Developer/embedded/nordic/ws/x/matter_template/build/matter_template/zephyr/factory_data -s /opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/nrfconnect_factory_data.schema --offset 0x16a000 --size 0x16a000
[INFO] Generating SPAKE2+ Verifier...
[WARNING] KEY password has not been provided. It means that DAC key is not encrypted.
[INFO] Validating JSON with schema...
[INFO] Validate OK
Traceback (most recent call last):
  File "/opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py", line 594, in <module>
    main()
  File "/opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py", line 583, in main
    generator.generate_json()
  File "/opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py", line 370, in generate_json
    self._generate_onboarding_data()
  File "/opt/nordic/ncs/v3.0.2/modules/lib/matter/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py", line 431, in _generate_onboarding_data
    qr = qrcode.make(setup_payload.generate_qrcode())
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nordic/ncs/toolchains/ef4fc6722e/lib/python3.12/site-packages/qrcode/main.py", line 28, in make
    return qr.make_image()
           ^^^^^^^^^^^^^^^
  File "/opt/nordic/ncs/toolchains/ef4fc6722e/lib/python3.12/site-packages/qrcode/main.py", line 363, in make_image
    from qrcode.image.pil import Image, PilImage
  File "/opt/nordic/ncs/toolchains/ef4fc6722e/lib/python3.12/site-packages/qrcode/image/pil.py", line 2, in <module>
    from PIL import Image, ImageDraw
  File "/opt/nordic/ncs/toolchains/ef4fc6722e/lib/python3.12/site-packages/PIL/Image.py", line 88, in <module>
    from . import _imaging as core
ImportError: dlopen(/opt/nordic/ncs/toolchains/ef4fc6722e/lib/python3.12/site-packages/PIL/_imaging.cpython-312-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/libtiff/lib/libtiff.6.dylib
  Referenced from: <18048ED7-8C26-3793-8DC9-94D5D6CDABA2> /opt/nordic/ncs/toolchains/ef4fc6722e/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/PIL/_imaging.cpython-312-darwin.so
  Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libtiff/lib/libtiff.6.dylib' (no such file), '/opt/homebrew/opt/libtiff/lib/libtiff.6.dylib' (no such file)
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/ef4fc6722e/bin/cmake --build /Users/x/Developer/embedded/nordic/ws/x/matter_template/build

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

This happens with everything matter examples I tried in SDK 3.0.x
It looked like some library missing. But don't think it should be relying at homebrew paths at first place, if in venv. Then if I install that missing library. Some other libraries would be shown missing.

I have even tried reintall all the toolchain and SDKs but it none seemed to work.

Thanks

Related