SwiftPM "swift build" for iOS


I am developing a Swift Package for iOS. In using attempting to use the command line tool swift build, it will result in fatal error: 'UIKit/UIKit.h' file not found. I know my package is working properly, since I can import it via iOS apps.

It seems that swift build is only configured to build for MacOS, and I don't see any options via swift build --help to allow specifying the OS. Is there something I am missing, or is this a feature that is being developed? It would definitely speed up and improve the dev process for building Swift Packages.

Thank you for your help!

See similar issue on Stack Overflow.

You're not missing anything, swift build indeed does not support iOS. You can build your package on the commandline using xcodebuild, though.

You can use xcodebuild -list to see the available schemes and then use xcodebuild just like you would with an Xcode project, including passing -destination to build for iOS.

1 Like

Hi @NeoNacho, thanks for the reply.

I know that xcodebuild can be used to build schemes. Though, I am curious if there is a way a command line tool to verify that a Swift Package can be built to be consumed (similar to pod lib lint available in CocoaPods - which spins up a sample xcodeproj and makes sure the Pod you're developing is able to be consumed).

I don't see any similar offerings via the swift package command line tools. I wanted to ask as it would make developing and testing a Swift Package quicker and more efficient. Thanks!


Terms of Service

Privacy Policy

Cookie Policy