Skip to content

Commit 646db5b

Browse files
committed
feat: add CocoaPods support
1 parent d3e566a commit 646db5b

File tree

9 files changed

+322
-19
lines changed

9 files changed

+322
-19
lines changed

.github/workflows/main.yml

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,75 @@ jobs:
6666
]
6767
}
6868
69-
# cocoapods-test:
70-
# name: CocoaPods
71-
# uses: SwiftyLab/ci/.github/workflows/cocoapods.yml@main
69+
cocoapods-test:
70+
name: CocoaPods
71+
uses: SwiftyLab/ci/.github/workflows/cocoapods.yml@main
72+
with:
73+
matrix: >
74+
{
75+
"include": [
76+
{
77+
"os": "macos-12",
78+
"xcode": "latest-stable",
79+
"platform": "macos"
80+
},
81+
{
82+
"os": "macos-12",
83+
"xcode": "latest-stable",
84+
"platform": "watchos"
85+
},
86+
{
87+
"os": "macos-12",
88+
"xcode": "latest-stable",
89+
"platform": "tvos"
90+
},
91+
{
92+
"os": "macos-12",
93+
"xcode": "latest-stable",
94+
"platform": "ios"
95+
}
96+
]
97+
}
7298
7399
xcode-test:
74100
name: Xcode
75101
uses: SwiftyLab/ci/.github/workflows/xcode.yml@main
102+
with:
103+
matrix: >
104+
{
105+
"include": [
106+
{
107+
"os": "macos-12",
108+
"xcode": "latest-stable",
109+
"platform": "macOS"
110+
},
111+
{
112+
"os": "macos-12",
113+
"xcode": "latest-stable",
114+
"platform": "watchOS"
115+
},
116+
{
117+
"os": "macos-12",
118+
"xcode": "latest-stable",
119+
"platform": "tvOS"
120+
},
121+
{
122+
"os": "macos-12",
123+
"xcode": "latest-stable",
124+
"platform": "iOS"
125+
},
126+
{
127+
"os": "macos-12",
128+
"xcode": "latest-stable",
129+
"platform": "mac-catalyst"
130+
}
131+
]
132+
}
76133
77134
ci:
78135
name: CI
79136
if: github.event_name == 'push'
80-
needs: [swift-package-test, xcode-test]
137+
needs: [swift-package-test, xcode-test, cocoapods-test]
81138
# needs: [analyze, swift-package-test, xcode-test, cocoapods-test]
82139
uses: SwiftyLab/ci/.github/workflows/ci.yml@main
83140

@@ -90,14 +147,14 @@ jobs:
90147
github.event.inputs.release == 'true' &&
91148
needs.swift-package-test.result == 'success' &&
92149
needs.xcode-test.result == 'success' &&
150+
needs.cocoapods-test.result == 'success' &&
93151
(needs.ci.result == 'success' || needs.ci.result == 'skipped'))
94-
# needs.cocoapods-test.result == 'success' &&
95152
# (needs.analyze.result == 'success' || needs.analyze.result == 'skipped')
96-
needs: [ci, swift-package-test, xcode-test]
153+
needs: [ci, swift-package-test, xcode-test, cocoapods-test]
97154
# needs: [ci, analyze, swift-package-test, xcode-test, cocoapods-test]
98155
uses: SwiftyLab/ci/.github/workflows/cd.yml@main
99156
with:
157+
os: macos-12
100158
version: ${{ github.event.inputs.version }}
101-
cocoapods: false
102159
secrets:
103160
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

AsyncObjects.podspec

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require 'json'
2+
3+
Pod::Spec.new do |s|
4+
package = JSON.parse(File.read('package.json'), {object_class: OpenStruct})
5+
6+
s.name = 'AsyncObjects'
7+
s.version = package.version.to_s
8+
s.homepage = package.homepage
9+
s.summary = package.summary
10+
s.description = package.description
11+
s.license = { :type => package.license, :file => 'LICENSE' }
12+
s.social_media_url = package.author.url
13+
s.readme = "#{s.homepage}/blob/main/README.md"
14+
s.changelog = "#{s.homepage}/blob/main/CHANGELOG.md"
15+
s.documentation_url = "https://swiftylab.github.io/AsyncObjects/#{s.version}/documentation/#{s.name.downcase}/"
16+
17+
s.source = {
18+
package.repository.type.to_sym => package.repository.url,
19+
:tag => "v#{s.version}"
20+
}
21+
22+
s.authors = {
23+
package.author.name => package.author.email
24+
}
25+
26+
s.swift_version = '5.6'
27+
s.ios.deployment_target = '13.0'
28+
s.macos.deployment_target = '10.15'
29+
s.tvos.deployment_target = '13.0'
30+
s.watchos.deployment_target = '6.0'
31+
s.osx.deployment_target = '10.15'
32+
33+
s.source_files = "Sources/#{s.name}/**/*.swift", "Sources/#{s.name}/*.docc"
34+
s.preserve_paths = "{Sources,Tests}/#{s.name}*/**/*", "*.md"
35+
s.pod_target_xcconfig = {
36+
'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'YES',
37+
'RUN_DOCUMENTATION_COMPILER' => 'YES'
38+
}
39+
40+
s.dependency 'OrderedCollections', '~> 1.0.0'
41+
42+
s.test_spec do |ts|
43+
ts.source_files = "Tests/#{s.name}Tests/**/*.swift"
44+
end
45+
end

Helpers/AsyncObjects.podspec

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'json'
2+
3+
Pod::Spec.new do |s|
4+
package = JSON.parse(File.read('package.json'), {object_class: OpenStruct})
5+
6+
s.name = 'AsyncObjects'
7+
s.version = package.version.to_s
8+
s.homepage = package.homepage
9+
s.summary = package.summary
10+
s.description = package.description
11+
s.license = { :type => package.license, :file => 'LICENSE' }
12+
s.social_media_url = package.author.url
13+
s.readme = "#{s.homepage}/blob/main/README.md"
14+
s.changelog = "#{s.homepage}/blob/main/CHANGELOG.md"
15+
s.documentation_url = "https://swiftylab.github.io/AsyncObject/#{s.version}/documentation/#{s.name.downcase}/"
16+
17+
s.source = {
18+
package.repository.type.to_sym => package.repository.url,
19+
:tag => "v#{s.version}"
20+
}
21+
22+
s.authors = {
23+
package.author.name => package.author.email
24+
}
25+
26+
s.swift_version = '5.6'
27+
s.ios.deployment_target = '13.0'
28+
s.macos.deployment_target = '10.15'
29+
s.tvos.deployment_target = '13.0'
30+
s.watchos.deployment_target = '6.0'
31+
s.osx.deployment_target = '10.15'
32+
33+
s.vendored_frameworks = "#{s.name}.xcframework"
34+
s.dependency 'OrderedCollections', '~> 1.0.0'
35+
# @todo: Enable when CocoaPods starts supporting docc
36+
# s.source_files = "#{s.name}.docc"
37+
# s.pod_target_xcconfig = {
38+
# 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'YES',
39+
# 'RUN_DOCUMENTATION_COMPILER' => 'YES'
40+
# }
41+
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# AsyncObjects
22

33
[![API Docs](http://img.shields.io/badge/Read_the-docs-2196f3.svg)](https://swiftylab.github.io/AsyncObjects/documentation/asyncobjects/)
4+
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AsyncObjects.svg?label=CocoaPods&color=C90005)](https://badge.fury.io/co/AsyncObjects)
45
[![Swift Package Manager Compatible](https://img.shields.io/github/v/tag/SwiftyLab/AsyncObjects?label=SPM&color=orange)](https://badge.fury.io/gh/SwiftyLab%2FAsyncObjects)
56
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)
67
[![Swift](https://img.shields.io/badge/Swift-5.6+-orange)](https://img.shields.io/badge/Swift-5-DE5D43)
78
[![Platforms](https://img.shields.io/badge/Platforms-all-sucess)](https://img.shields.io/badge/Platforms-all-sucess)
89
[![CI/CD](https://github.com/SwiftyLab/AsyncObjects/actions/workflows/main.yml/badge.svg?event=push)](https://github.com/SwiftyLab/AsyncObjects/actions/workflows/main.yml)
910
[![Maintainability](https://api.codeclimate.com/v1/badges/37183c809818826c1bcf/maintainability)](https://codeclimate.com/github/SwiftyLab/AsyncObjects/maintainability)
1011
[![codecov](https://codecov.io/gh/SwiftyLab/AsyncObjects/branch/main/graph/badge.svg?token=jKxMv5oFeA)](https://codecov.io/gh/SwiftyLab/AsyncObjects)
11-
<!-- [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AsyncObjects.svg?label=CocoaPods&color=C90005)](https://badge.fury.io/co/AsyncObjects) -->
1212
<!-- [![CodeQL](https://github.com/SwiftyLab/AsyncObjects/actions/workflows/codeql-analysis.yml/badge.svg?event=schedule)](https://github.com/SwiftyLab/AsyncObjects/actions/workflows/codeql-analysis.yml) -->
1313

1414
Several synchronization primitives and task synchronization mechanisms introduced to aid in modern swift concurrency.

Sources/AsyncObjects/AsyncObject.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ public func waitForTaskCompletion(
244244
}
245245
if let result = await group.next() {
246246
timedOut = !result
247-
} else {
248-
timedOut = true
249247
}
250248
group.cancelAll()
251249
}

Tests/AsyncObjectsTests/NonThrowingFutureTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class NonThrowingFutureTests: XCTestCase {
4747
let value = await allFuture.value
4848
XCTAssertEqual(value, [1, 3, 2])
4949
}
50+
// Make sure previous tasks started
51+
try await Self.sleep(forSeconds: 0.01)
5052
group.addTask {
5153
try await Self.sleep(seconds: 1)
5254
await future1.fulfill(producing: 1)
@@ -82,6 +84,8 @@ class NonThrowingFutureTests: XCTestCase {
8284
}
8385
}
8486
}
87+
// Make sure previous tasks started
88+
try await Self.sleep(forSeconds: 0.01)
8589
group.addTask {
8690
try await Self.sleep(seconds: 1)
8791
await future1.fulfill(producing: 1)
@@ -112,6 +116,8 @@ class NonThrowingFutureTests: XCTestCase {
112116
XCTAssertEqual(value, 1)
113117
}
114118
}
119+
// Make sure previous tasks started
120+
try await Self.sleep(forSeconds: 0.01)
115121
group.addTask {
116122
try await Self.sleep(seconds: 1)
117123
await future1.fulfill(producing: 1)
@@ -142,6 +148,8 @@ class NonThrowingFutureTests: XCTestCase {
142148
XCTAssertEqual(value, 1)
143149
}
144150
}
151+
// Make sure previous tasks started
152+
try await Self.sleep(forSeconds: 0.01)
145153
group.addTask {
146154
try await Self.sleep(seconds: 1)
147155
await future1.fulfill(producing: 1)
@@ -158,4 +166,23 @@ class NonThrowingFutureTests: XCTestCase {
158166
}
159167
}
160168
}
169+
170+
func testConstructingAllFutureFromZeroFutures() async {
171+
let future = await Future<Int, Never>.all()
172+
let value = await future.value
173+
XCTAssertTrue(value.isEmpty)
174+
}
175+
176+
func testConstructingAllSettledFutureFromZeroFutures() async {
177+
let future = await Future<Int, Never>.allSettled()
178+
let value = await future.value
179+
XCTAssertTrue(value.isEmpty)
180+
}
181+
182+
func testMultipleTimesFutureFulfilled() async throws {
183+
let future = await Future<Int, Never>(with: .success(5))
184+
await future.fulfill(producing: 10)
185+
let value = await future.value
186+
XCTAssertEqual(value, 5)
187+
}
161188
}

0 commit comments

Comments
 (0)