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:
// 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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
My Catalyst-capable apps stopped building with the newly released Xcode 12. I tested it out also on a brand new SwiftUI project with the same result. I have my App structure looking like the fragment below. This is the code that was generated by Xcode; no modifications.
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
I get the following compiler errors:
'TestApp' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void
Cannot find type 'App' in scope
Cannot find type 'Scene' in scope
This code compiles fine when I build for an iPhone or iPad device.
Is anyone else seeing this? Any ideas on how to fix it?