Skip to content

Commit 15c318d

Browse files
committed
Add support for SwiftPM using SPMCLI
SPMCLI is an option since to compile SwiftGit2 we need to perform amounts of linking and passing flags during compilation which in turns very cumbersome. The other way is to use helper like Make or other automation. SPMCLI is choosen because it supports resolving configuration in dependencies. For now, ZipArchive. The user doesn't need to manually state each updated link and flags because SPMCLI will handle it.
1 parent 9cb184d commit 15c318d

File tree

9 files changed

+164
-0
lines changed

9 files changed

+164
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
SPMGenerated.xcodeproj
12
.vscode/
23
.build/
34

Diff for: Clibgit2/_stub.c

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Avoid warning in SwiftPM invocation.

Diff for: MacOS.xcconfig

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OTHER_LDFLAGS = $(inherited) ./External/libgit2.a ./External/libssl.a ./External/libcrypto.a /usr/lib/libcurl.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libz.tbd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libiconv.tbd
2+
OTHER_CFLAGS = $(inherited) -DHAVE_INTTYPES_H -DHAVE_PKCRYPT -DHAVE_STDINT_H -DHAVE_WZAES -DHAVE_ZLIB -DMZ_ZIP_NO_SIGNING -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -fapplication-extension -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code-aggressive -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body

Diff for: Package.resolved

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"object": {
3+
"pins": [
4+
{
5+
"package": "Nimble",
6+
"repositoryURL": "https://github.com/Quick/Nimble",
7+
"state": {
8+
"branch": null,
9+
"revision": "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
10+
"version": "7.3.4"
11+
}
12+
},
13+
{
14+
"package": "Quick",
15+
"repositoryURL": "https://github.com/Quick/Quick",
16+
"state": {
17+
"branch": null,
18+
"revision": "f2b5a06440ea87eba1a167cab37bf6496646c52e",
19+
"version": "1.3.4"
20+
}
21+
},
22+
{
23+
"package": "ZipArchive",
24+
"repositoryURL": "https://github.com/muizidn/ZipArchive",
25+
"state": {
26+
"branch": "master",
27+
"revision": "403986421556d945ce28b64bfc171e4ff9403a37",
28+
"version": null
29+
}
30+
}
31+
]
32+
},
33+
"version": 1
34+
}

Diff for: Package.swift

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// swift-tools-version:5.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SwiftGit2",
8+
platforms: [
9+
.macOS(.v10_11),
10+
],
11+
products: [
12+
.executable(
13+
name: "example",
14+
targets: ["example"]),
15+
.library(
16+
name: "SwiftGit2",
17+
targets: ["SwiftGit2"]),
18+
],
19+
dependencies: [
20+
.package(url: "https://github.com/Quick/Quick", from: "1.3.2"),
21+
.package(url: "https://github.com/Quick/Nimble", from: "7.3.1"),
22+
.package(url: "https://github.com/muizidn/ZipArchive", .branch("master")),
23+
],
24+
targets: [
25+
.target(
26+
name: "example",
27+
dependencies: ["SwiftGit2"],
28+
path: "example"),
29+
.target(
30+
name: "SwiftGit2",
31+
dependencies: ["Clibgit2"],
32+
path: "SwiftGit2",
33+
sources: ["Swift"]),
34+
.target(
35+
name: "Clibgit2",
36+
path: "Clibgit2"),
37+
.testTarget(
38+
name: "SwiftGit2Tests",
39+
dependencies: ["SwiftGit2", "Quick", "Nimble", "ZipArchive"],
40+
path: "SwiftGit2Tests"),
41+
]
42+
)

Diff for: README.md

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ If you want to build a copy of SwiftGit2 without Carthage, possibly for developm
6262
2. Run `git submodule update --init --recursive` to clone the submodules
6363
3. Build in Xcode
6464

65+
## Swift Package Manager
66+
To incorporate SwiftGit2 to your project, you may want to use [SPMCLI](https://github.com/pondok-programmer/spmcli) to automate tedious tasks including linking and passing flags.
67+
68+
We encourage you to check [SPMCLI.resolved](SPMCLI.resolved) file.
69+
70+
To generate Xcodeproj using SPMCLI, you need to use it's `xcproj` branch. It will automate set up OTHER_CFLAGS and OTHER_LDFLAGS.
71+
6572
## Contributions
6673
We :heart: to receive pull requests! GitHub makes it easy:
6774

Diff for: SPMCLI.resolved

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
mac:
2+
build:
3+
-Xcc:
4+
- -DHAVE_INTTYPES_H
5+
- -DHAVE_PKCRYPT
6+
- -DHAVE_STDINT_H
7+
- -DHAVE_WZAES
8+
- -DHAVE_ZLIB
9+
- -DMZ_ZIP_NO_SIGNING
10+
- -Wnon-modular-include-in-framework-module
11+
- -Werror=non-modular-include-in-framework-module
12+
- -fapplication-extension
13+
- -Wno-trigraphs
14+
- -fpascal-strings
15+
- -O0
16+
- -fno-common
17+
- -Wno-missing-field-initializers
18+
- -Wno-missing-prototypes
19+
- -Werror=return-type
20+
- -Wunreachable-code-aggressive
21+
- -Werror=deprecated-objc-isa-usage
22+
- -Werror=objc-root-class
23+
- -Wno-missing-braces
24+
- -Wparentheses
25+
- -Wswitch
26+
- -Wunused-function
27+
- -Wno-unused-label
28+
- -Wno-unused-parameter
29+
- -Wunused-variable
30+
- -Wunused-value
31+
- -Wempty-body
32+
- -Wuninitialized
33+
- -Wconditional-uninitialized
34+
- -Wno-unknown-pragmas
35+
- -Wno-shadow
36+
- -Wno-four-char-constants
37+
- -Wno-conversion
38+
- -Wconstant-conversion
39+
- -Wint-conversion
40+
- -Wbool-conversion
41+
- -Wenum-conversion
42+
- -Wno-float-conversion
43+
- -Wnon-literal-null-conversion
44+
- -Wobjc-literal-conversion
45+
- -Wshorten-64-to-32
46+
- -Wpointer-sign
47+
- -Wno-newline-eof
48+
- -fstrict-aliasing
49+
- -Wdeprecated-declarations
50+
- -g
51+
- -Wno-sign-conversion
52+
- -Winfinite-recursion
53+
- -Wcomma
54+
- -Wblock-capture-autoreleasing
55+
- -Wstrict-prototypes
56+
- -Wno-semicolon-before-method-body
57+
-Xlinker:
58+
- ./External/libgit2.a
59+
- ./External/libssl.a
60+
- ./External/libcrypto.a
61+
- /usr/lib/libcurl.dylib
62+
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libz.tbd
63+
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libiconv.tbd

Diff for: SPMCLI.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
mac:
2+
build:
3+
-Xlinker:
4+
- ${PWD}/External/libgit2.a
5+
- ${PWD}/External/libssl.a
6+
- ${PWD}/External/libcrypto.a
7+
- /usr/lib/libcurl.dylib
8+
9+
xcconfig:
10+
name: MacOS.xcconfig
11+
keys:
12+
OTHER_LDFLAGS: -Xlinker
13+
OTHER_CFLAGS: -Xcc

Diff for: example/main.swift

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import SwiftGit2

0 commit comments

Comments
 (0)