Skip to content

Commit b8ca443

Browse files
authored
Merge pull request #1 from RakuyoKit/feature/add-tools
Add toolchains and more
2 parents 7622f68 + b765c45 commit b8ca443

40 files changed

Lines changed: 566 additions & 260 deletions

.github/workflows/build.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# GitHub recommends pinning actions to a commit SHA.
7+
# To get a newer version, you will need to update the SHA.
8+
# You can also reference a tag or branch, but the action may change without warning.
9+
10+
name: Swift Build
11+
12+
on:
13+
pull_request:
14+
branches: [main]
15+
workflow_dispatch:
16+
17+
jobs:
18+
build:
19+
name: Xcode ${{ matrix.xcode }} on ${{ matrix.os }}
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
os: [macos-14]
24+
xcode: ["15"]
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: jdx/mise-action@v2
28+
- uses: maxim-lobanov/setup-xcode@v1
29+
with:
30+
xcode-version: ${{ matrix.xcode }}
31+
- name: Lint
32+
run: rake swift:lint
33+
- name: Test
34+
run: rake swift:test

.gitignore

Lines changed: 103 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/macos,objective-c,swift,swiftpackagemanager,xcode
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,objective-c,swift,swiftpackagemanager,xcode
3+
4+
### macOS ###
5+
# General
6+
.DS_Store
7+
.AppleDouble
8+
.LSOverride
9+
10+
# Icon must end with two \r
11+
Icon
12+
13+
# Thumbnails
14+
._*
15+
16+
# Files that might appear in the root of a volume
17+
.DocumentRevisions-V100
18+
.fseventsd
19+
.Spotlight-V100
20+
.TemporaryItems
21+
.Trashes
22+
.VolumeIcon.icns
23+
.com.apple.timemachine.donotpresent
24+
25+
# Directories potentially created on remote AFP share
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
32+
### macOS Patch ###
33+
# iCloud generated files
34+
*.icloud
35+
36+
### Objective-C ###
137
# Xcode
238
#
339
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
@@ -30,37 +66,73 @@ DerivedData/
3066
*.dSYM.zip
3167
*.dSYM
3268

69+
# CocoaPods
70+
# We recommend against adding the Pods directory to your .gitignore. However
71+
# you should judge for yourself, the pros and cons are mentioned at:
72+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
73+
# Pods/
74+
# Add this line if you want to avoid checking in source code from the Xcode workspace
75+
# *.xcworkspace
76+
77+
# Carthage
78+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
79+
# Carthage/Checkouts
80+
81+
Carthage/Build/
82+
83+
# fastlane
84+
# It is recommended to not store the screenshots in the git repo.
85+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
86+
# For more information about the recommended setup visit:
87+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
88+
89+
fastlane/report.xml
90+
fastlane/Preview.html
91+
fastlane/screenshots/**/*.png
92+
fastlane/test_output
93+
94+
# Code Injection
95+
# After new code Injection tools there's a generated folder /iOSInjectionProject
96+
# https://github.com/johnno1962/injectionforxcode
97+
98+
iOSInjectionProject/
99+
100+
### Objective-C Patch ###
101+
102+
### Swift ###
103+
# Xcode
104+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
105+
106+
107+
108+
109+
110+
33111
## Playgrounds
34112
timeline.xctimeline
35113
playground.xcworkspace
36114

37115
# Swift Package Manager
38-
#
39116
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40117
# Packages/
41118
# Package.pins
42119
# Package.resolved
43120
# *.xcodeproj
44-
#
45121
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46122
# hence it is not needed unless you have added a package configuration file to your project
47-
# .swiftpm
48123

124+
.swiftpm
49125
.build/
50126

51127
# CocoaPods
52-
#
53128
# We recommend against adding the Pods directory to your .gitignore. However
54129
# you should judge for yourself, the pros and cons are mentioned at:
55130
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56-
#
57-
Pods/
58-
#
131+
# Pods/
59132
# Add this line if you want to avoid checking in source code from the Xcode workspace
60133
# *.xcworkspace
61134

62135
# Carthage
63-
#
64136
# Add this line if you want to avoid checking in source code from Carthage dependencies.
65137
# Carthage/Checkouts
66138

@@ -71,30 +143,38 @@ Dependencies/
71143
.accio/
72144

73145
# fastlane
74-
#
75146
# It is recommended to not store the screenshots in the git repo.
76147
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
77148
# For more information about the recommended setup visit:
78149
# https://docs.fastlane.tools/best-practices/source-control/#source-control
79150

80-
fastlane/report.xml
81-
fastlane/Preview.html
82-
fastlane/screenshots/**/*.png
83-
fastlane/test_output
84151

85152
# Code Injection
86-
#
87153
# After new code Injection tools there's a generated folder /iOSInjectionProject
88154
# https://github.com/johnno1962/injectionforxcode
89155

90-
iOSInjectionProject/
91-
.DS_Store
92156

93-
# For SPM
157+
### SwiftPackageManager ###
158+
Packages
159+
xcuserdata
160+
*.xcodeproj
161+
162+
163+
### Xcode ###
164+
165+
## Xcode 8 and earlier
166+
167+
### Xcode Patch ###
168+
*.xcodeproj/*
169+
!*.xcodeproj/project.pbxproj
170+
!*.xcodeproj/xcshareddata/
171+
!*.xcodeproj/project.xcworkspace/
172+
!*.xcworkspace/contents.xcworkspacedata
173+
/*.gcno
174+
**/xcshareddata/WorkspaceSettings.xcsettings
175+
176+
# End of https://www.toptal.com/developers/gitignore/api/macos,objective-c,swift,swiftpackagemanager,xcode
94177

95-
/.build
96-
/Packages
97-
/*.xcodeproj
98-
.swiftpm/config/registries.json
99-
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
100-
.netrc
178+
### Projects ###
179+
*.xcodeproj
180+
*.xcworkspace

.mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
pre-commit = "3.7.0"

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
default_install_hook_types: [pre-commit, pre-push]
2+
fail_fast: true
3+
4+
repos:
5+
- repo: local
6+
hooks:
7+
- id: lint
8+
name: Run Lint
9+
language: system
10+
entry: rake swift:lint
11+
stages: [pre-commit]
12+
verbose: true
13+
- id: test
14+
name: Run Test
15+
language: system
16+
entry: rake swift:test
17+
stages: [pre-push]
18+
verbose: true

Demo.playground/Pages/Advanced.xcplaygroundpage/Contents.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import Foundation
66

77
import APIWrapper
88

9-
/*:
10-
The `RaAPIWrapper` is extremely extensible.
11-
You can work with the `userInfo` property to customize the api parameters you need.
12-
13-
The `RaAPIWrapper/AF` module then takes advantage of this feature and supports the `ParameterEncoding` field of `Alamofire`.
14-
15-
The following code demonstrates how to add a custom parameter to `API`:
16-
*/
17-
18-
// will be used later as a custom parameter of the api.
9+
// MARK: - VerificationType
10+
11+
/// :
12+
/// The `RaAPIWrapper` is extremely extensible.
13+
/// You can work with the `userInfo` property to customize the api parameters you need.
14+
///
15+
/// The `RaAPIWrapper/AF` module then takes advantage of this feature and supports the `ParameterEncoding` field of `Alamofire`.
16+
///
17+
/// The following code demonstrates how to add a custom parameter to `API`:
18+
19+
/// will be used later as a custom parameter of the api.
1920
enum VerificationType: Hashable {
2021
case normal
2122
case special
@@ -35,12 +36,13 @@ extension API {
3536
}
3637
}
3738

39+
// MARK: - AdvancedAPI
40+
3841
enum AdvancedAPI {
3942
/// Finally, the new initialization method declared above is called on
4043
/// the property wrapper to complete the interface definition.
4144
@GET("/api", verification: .normal)
4245
static var testAPI: APIParameterBuilder<()>? = nil
4346
}
4447

45-
4648
//: [Next](@next)

Demo.playground/Pages/Basic.xcplaygroundpage/Contents.swift

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import Foundation
44

55
import APIWrapper
66

7-
/*:
8-
This example uses [Postman Echo](https://www.postman.com/postman/workspace/published-postman-templates/documentation/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65?ctx=documentation) as the sample api.
9-
10-
The return value of this api depends on the parameters and will return the parameters, headers and other data as is.
11-
*/
7+
// MARK: - BasicAPI
8+
9+
/// :
10+
/// This example uses [Postman Echo](https://www.postman.com/postman/workspace/published-postman-templates/documentation/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65?ctx=documentation) as the sample api.
11+
///
12+
/// The return value of this api depends on the parameters and will return the parameters, headers and other data as is.
1213

1314
//: To begin by showing some of the most basic uses, look at how the api is defined.
1415

@@ -26,12 +27,12 @@ enum BasicAPI {
2627
do {
2728
// Requests the api and parses the return value of the interface. Note the use of the `$` character.
2829
let response = try await BasicAPI.$get.request(to: PostManResponse<Arg>.self)
29-
30+
3031
// You can also ignore the return value and focus only on the act of requesting the api itself.
3132
try await BasicAPI.$get.request()
32-
33+
3334
} catch {
34-
print("❌ get request failure: \(error)")
35+
Log.log("❌ get request failure: \(error)")
3536
}
3637

3738
//: The api with parameters is a little more complicated to define:
@@ -45,10 +46,10 @@ extension BasicAPI {
4546
static var postWithTuple: APIParameterBuilder<(foo1: String, foo2: Int?)>? = .init {
4647
[
4748
"foo1": $0.foo1,
48-
"foo2": $0.foo2
49+
"foo2": $0.foo2,
4950
]
5051
}
51-
52+
5253
/// This is an api for requests using the **POST** method.
5354
///
5455
/// The full api address is: [](https://postman-echo.com/post) .
@@ -59,18 +60,19 @@ extension BasicAPI {
5960

6061
do {
6162
// Request the api and parse the return value.
62-
let tupleAPIResponse = try await BasicAPI.$postWithTuple.request(with: (foo1: "foo1", foo2: nil), to: PostManResponse<Arg>.self)
63-
64-
/**
65-
* If you look at the return value, you will see that `foo2` is not passed to the server.
66-
* This is because `RaAPIWrapper` filters out all parameters with the value `nil`.
67-
*/
68-
63+
let tupleAPIResponse = try await BasicAPI.$postWithTuple.request(
64+
with: (foo1: "foo1", foo2: nil),
65+
to: PostManResponse<Arg>.self
66+
)
67+
68+
/// If you look at the return value, you will see that `foo2` is not passed to the server.
69+
/// This is because `RaAPIWrapper` filters out all parameters with the value `nil`.
70+
6971
// Try using model as a parameter and you will get the same result.
7072
let modelAPIResponse = try await BasicAPI.$postWithModel.request(with: .init(foo2: "foo2"), to: PostManResponse<Arg>.self)
71-
73+
7274
} catch {
73-
print("❌ post request failure: \(error)")
75+
Log.log("❌ post request failure: \(error)")
7476
}
7577

7678
//: [Next](@next)

0 commit comments

Comments
 (0)