diff --git a/.gitignore b/.gitignore index 14fa0ae..6b55f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,10 @@ xcuserdata *.hmap *.ipa +# Swift Package Manager +.swiftpm +.build/ + # Fastlane *.app.dSYM.zip *.mobileprovision diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..430d2e3 --- /dev/null +++ b/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "WireGuardKit", + platforms: [ + .macOS(.v10_14), + .iOS(.v12) + ], + products: [ + .library(name: "WireGuardKit", targets: ["WireGuardKit"]) + ], + dependencies: [], + targets: [ + .target( + name: "WireGuardKit", + dependencies: ["libwg-go"], + path: "WireGuardKit/Sources/WireGuardKit" + ), + .target( + name: "libwg-go", + dependencies: [], + path: "WireGuardKit/Sources/libwg-go", + linkerSettings: [.linkedLibrary("wg-go")] + ) + ] +) diff --git a/WireGuardKit/Sources/WireGuardKit/WireGuardKit.swift b/WireGuardKit/Sources/WireGuardKit/WireGuardKit.swift new file mode 100644 index 0000000..8d005a9 --- /dev/null +++ b/WireGuardKit/Sources/WireGuardKit/WireGuardKit.swift @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. + +import Foundation +import libwg_go + +public func getWireGuardVersion() -> String { + return String(cString: wgVersion()!) +} diff --git a/WireGuardKit/Sources/libwg-go/dummy.c b/WireGuardKit/Sources/libwg-go/dummy.c new file mode 100644 index 0000000..d15abba --- /dev/null +++ b/WireGuardKit/Sources/libwg-go/dummy.c @@ -0,0 +1 @@ +// Empty diff --git a/WireGuardKit/Sources/libwg-go/include/libwg_go.h b/WireGuardKit/Sources/libwg-go/include/libwg_go.h new file mode 100644 index 0000000..55cc00d --- /dev/null +++ b/WireGuardKit/Sources/libwg-go/include/libwg_go.h @@ -0,0 +1 @@ +#include "../../../../wireguard-go-bridge/wireguard.h" diff --git a/WireGuardKit/Sources/libwg-go/module.modulemap b/WireGuardKit/Sources/libwg-go/module.modulemap new file mode 100644 index 0000000..9c50624 --- /dev/null +++ b/WireGuardKit/Sources/libwg-go/module.modulemap @@ -0,0 +1,5 @@ +module libwg_go { + umbrella header "include/libwg_go.h" + link "wg-go" + export * +}