s1ddok
s1ddok

Reputation: 4654

Provide configuration file to Swift Package Manager

I'm trying to marry swiftpm and .xcconfig files.

I've created Config.xcconfig file right next to my Package.swift file with two lines:

LIBRARY_SEARCH_PATHS = $(inherited) $(SRCROOT)/../3rdparty/mylib/.build/
OTHER_LDFLAGS = $(inherited) -lmylibRelease

But I still have 120 linkage errors, my guess is that swift build does not see my config file.

What should I do?

Upvotes: 5

Views: 5539

Answers (3)

Max MacLeod
Max MacLeod

Reputation: 26672

The appropriate way to specify a header search path, and linker flags, is to use the Package.swift struct values. They are provided for that very purpose.

For header search paths, use CSetting.

For linker flags, use LinkerSetting.

Full specification of Package.swift can be found at the PackageDescription API.

Upvotes: 0

Kostiantyn Koval
Kostiantyn Koval

Reputation: 8483

SwiftPM support custom Xcode configs. You have to specify the path to your custom config file when invoking generate-xcodeproj command.
To see more details about generate-xcodeproj run swift package generate-xcodeproj -h

Example

swift package generate-xcodeproj --xcconfig-overrides Config.xcconfig

Upvotes: 9

Ugo Arangino
Ugo Arangino

Reputation: 2958

Xcode 11.3 supports now SPM with custom Xcode configurations.

Upvotes: -5

Related Questions