I'm trying to use libgit2 in an iOS application. I've packaged up libgit2, libssh2, libssl, and libcrypto in XCFrameworks. The XCFrameworks support iOS arm64, simulator, and Catalyst. I want to build a Swift wrapper over the frameworks and deploy them using a Swift Package.
When I link against the XCFrameworks directly in my application, I can consume libgit2 by creating a bridging header and #import <git2.h> from libgit2.xcframework. When I move the code into a Swift Package, it fails to build or find libgit2 even though it's part of the package. I can't find any indication of whether I need a bridging header or how to add the bridging header to my Swift package.
Here's my Package.swift file:
The documentation seems to indicate that I can reference binaryTarget dependencies in a Swift target in order to create a wrapper library. Can anyone help me to understand what I am missing here? How do I create the equivalent of a bridging header so that I can access the native frameworks from my Swift code?
Thank you.
When I link against the XCFrameworks directly in my application, I can consume libgit2 by creating a bridging header and #import <git2.h> from libgit2.xcframework. When I move the code into a Swift Package, it fails to build or find libgit2 even though it's part of the package. I can't find any indication of whether I need a bridging header or how to add the bridging header to my Swift package.
Here's my Package.swift file:
Code Block swift // swift-tools-version:5.3 import PackageDescription let package = Package( name: "Git", platforms: [.iOS(.v13)], products: [ .library( name: "Git", targets: [ "SwiftGit" ] ), ], targets: [ .target( name: "SwiftGit", dependencies: [ .target(name: "libcrypto"), .target(name: "libssl"), .target(name: "libssh2"), .target(name: "libgit2") ] ), .binaryTarget( name: "libcrypto", path: "lib/libcrypto.xcframework" ), .binaryTarget( name: "libssl", path: "lib/libssl.xcframework" ), .binaryTarget( name: "libssh2", path: "lib/libssh2.xcframework" ), .binaryTarget( name: "libgit2", path: "lib/libgit2.xcframework" ) ] )
The documentation seems to indicate that I can reference binaryTarget dependencies in a Swift target in order to create a wrapper library. Can anyone help me to understand what I am missing here? How do I create the equivalent of a bridging header so that I can access the native frameworks from my Swift code?
Thank you.