Skip to content

SPI (System Programming Interface)

Swift’s @_spi attribute marks declarations as pseudo-private, making them accessible only to clients that explicitly import the SPI. While these declarations are technically public, they’re intended for internal or restricted use.

When using --retain-public for framework projects, all public declarations are retained, including those marked with @_spi. However, you may want to check for unused code within specific SPIs. The --no-retain-spi option allows you to specify which SPIs should be checked for unused code even when --retain-public is enabled.

For example, with --retain-public --no-retain-spi Internal, Periphery will:

  • Retain regular public declarations
  • Retain @_spi(Testing) public declarations (different SPI)
  • Check @_spi(Internal) public declarations for unused code

This is particularly useful for internal SPIs that should be audited for unused code while still retaining the framework’s public API.