Liam Appelbe
Liam Appelbe

Reputation: 41

Is there a way of generating an ObjC header for a Swift API from the command line?

If I have a .swift file, Apple's documentation says I can use Xcode to create an ObjC wrapper header for it, so I can call it from other ObjC code: https://developer.apple.com/documentation/swift/importing-swift-into-objective-c

But there's no way of automating something like that as part of an external build (I've also just found it clunky and unreliable). So is there a way of generating the wrapper from the command line, say with some xcodebuild or swiftc command?

Upvotes: 1

Views: 648

Answers (1)

Liam Appelbe
Liam Appelbe

Reputation: 41

Found this: https://theswiftdev.com/how-to-use-a-swift-library-in-c/

Looks like swiftc has a -emit-objc-header flag.

Upvotes: -1

Related Questions