scannillo
(Sammy C)
1
Hello
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.
5 Likes
NeoNacho
(Boris Buegling)
2
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.
5 Likes
scannillo
(Sammy C)
3
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!
Thanks!
4 Likes
jazz
(Jasveer Singh)
4
I was able to get this working for swift-only packages with the below command, However Objc files still fail.
swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios13.0-simulator"
2 Likes
still seems to be building for macos despite passing iOS target:
error: the library 'xxx' requires macos 10.13
I could wrap everything is directives to get it to build, but then binary won't include any of my iOS definitions!
#if os(iOS)
@objc public class MediaPlayer : NSObject {
Alternative is to build using xcodebuild
xcodebuild build -scheme RadioPlayerLocal -sdk "`xcrun --sdk iphonesimulator --show-sdk-path`" -destination "OS=17.1,name=iPhone 13 Pro"