Swift Package Manager: […] is only available on OS X 10.11 or newer

Problem

You want to use „new“ API in your project while using the Swift Package Manager, but you get the following or similar warning:

'systemFont(ofSize:weight:)' is only available on OS X 10.11 or newer

Solution

There is a option available, that allows you to override the build settings and therefore also the DEPLOYMENT_TARGET while using the swift package generate-xcodeproj command.

To override the settings you need a .xcconfig file and use the following extra flag: --xcconfig-overrides.

Sample usage

  • Setup:
.
├── Package.swift
└── main.xcconfig
  • main.xcconfig contents:
IPHONEOS_DEPLOYMENT_TARGET = 9.1
MACOSX_DEPLOYMENT_TARGET = 10.11
  • SPM command

swift package generate-xcodeproj --xcconfig-overrides ./main.xcconfig

Result

And thats it, now you can use 10.11 API without these nasty warnings:

spm-error

Sources: