ESP32 'DNSServer.h: No such file or directory'

I am coding a project that uses HomeSpan on the ESP32, and when I try to build my code, I get the following error:

fatal error: DNSServer.h: No such file or directory

I have tried adding DNSServer to the platformio.ini file lib_deps section, but that leads to further errors with other files. I have also tried adding lib_ldf_mode = chain+ and lib_ldf_mode = deep+, but adding these leads to errors with files like Network.h.

Here is my current platformio.ini file:

[env]
framework = arduino
lib_deps = homespan/HomeSpan@^2.1.0

[env:node32s]
platform = espressif32
board = node32s
monitor_speed = 115200

The DNSServer.h header is being included in some part of HomeSpan’s headers.

To fix this, simply add an #include <DNSServer.h> before #include <HomeSpan.h>. Also a include <Arduino.h> is a good idea.

So the minimized “01-SimpleLightBulb” example should look like this:

#include <Arduino.h>
#include <DNSServer.h>
#include <HomeSpan.h>

void setup() {
    Serial.begin(115200);

    homeSpan.begin(Category::Lighting, "HomeSpan LightBulb");

    new SpanAccessory();
    new Service::AccessoryInformation();

    new Characteristic::Identify();
    new Service::LightBulb();
    new Characteristic::On();
} 

void loop() {
    homeSpan.poll();
}

Note:
This library requires Arduino 3.x. Therefore you have to use pioarduino.
You also have to change the partition layout, as the app will exceed the default size of 1310720 Bytes.

[env]
framework = arduino
lib_deps = homespan/HomeSpan@^2.1.0

[env:node32s]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip
board = node32s
monitor_speed = 115200
board_build.partitions = huge_app.csv

Result:

Processing node32s (platform: https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip; board: node32s; framework: arduino)
------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/node32s.html
PLATFORM: Espressif 32 (53.3.11) > Node32s
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.1.1 
 - framework-arduinoespressif32-libs @ 5.3.0+sha.cfea4f7c98 
 - tool-esptoolpy @ 4.8.5 
 - tool-mklittlefs @ 3.2.0 
 - tool-riscv32-esp-elf-gdb @ 14.2.0+20240403 
 - tool-xtensa-esp-elf-gdb @ 14.2.0+20240403 
 - toolchain-xtensa-esp-elf @ 13.2.0+20240530
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 42 compatible libraries
Scanning dependencies...
Dependency Graph
|-- HomeSpan @ 2.1.0
|-- DNSServer @ 3.1.1
Building in release mode
Retrieving maximum program size .pio/build/node32s/firmware.elf
Checking size .pio/build/node32s/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  18.6% (used 61016 bytes from 327680 bytes)
Flash: [=====     ]  45.6% (used 1433760 bytes from 3145728 bytes)