Skip to content

Commit 4f817e1

Browse files
authored
Release 1.1.0 (#9)
## [1.1.0] - 2020-07-20 ### Added - Support `arm64e` on `appletvos`, `iphoneos`, and `macosx` SDKs by extending valid architectures. - Support for building LDSwiftEventSource on Linux. Currently this library will not generate log messages on Linux, and may not behave correctly on Linux due to Foundation being [incomplete](https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md).
1 parent ac1f0e0 commit 4f817e1

File tree

11 files changed

+177
-65
lines changed

11 files changed

+177
-65
lines changed

.circleci/config.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: 2.1
22
jobs:
3-
# TODO (gwhelanld): Consider adding linux CI job for swiftpm linux build/test
43
build:
54
shell: /bin/bash --login -eo pipefail
65

@@ -63,3 +62,61 @@ jobs:
6362

6463
- store_artifacts:
6564
path: artifacts
65+
66+
build_macos_universal:
67+
macos:
68+
xcode: '12.0.0-UA'
69+
70+
steps:
71+
- checkout
72+
73+
- run:
74+
name: Setup for builds
75+
command: |
76+
mkdir -p 'test-results'
77+
mkdir -p 'artifacts'
78+
79+
- run:
80+
name: Build for ARM64 macOS
81+
command: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | tee 'artifacts/raw-logs-macosx-arm64e.txt' | xcpretty
82+
when: always
83+
84+
- run:
85+
name: Build & Test on x86_64 macOS Simulator
86+
command: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | tee 'artifacts/raw-logs-macosx-x86_64.txt' | xcpretty -r junit -o 'test-results/platform-macosx-x86_64/junit.xml'
87+
when: always
88+
89+
- store_test_results:
90+
path: test-results
91+
92+
- store_artifacts:
93+
path: artifacts
94+
95+
build_linux:
96+
shell: /bin/bash --login -eo pipefail
97+
98+
docker:
99+
- image: norionomura/swift:latest
100+
101+
steps:
102+
- checkout
103+
104+
- run:
105+
name: Setup for builds
106+
command: mkdir -p 'artifacts'
107+
108+
- run:
109+
name: Build & Test with swiftpm
110+
command: swift test -v | tee 'artifacts/raw-logs-swiftpm-linux.txt'
111+
112+
- store_artifacts:
113+
path: artifacts
114+
115+
workflows:
116+
version: 2
117+
118+
build:
119+
jobs:
120+
- build
121+
- build_linux
122+
- build_macos_universal

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to the LaunchDarkly Swift EventSource library will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [1.1.0] - 2020-07-20
6+
### Added
7+
- Support `arm64e` on `appletvos`, `iphoneos`, and `macosx` SDKs by extending valid architectures.
8+
- Support for building LDSwiftEventSource on Linux. Currently this library will not generate log messages on Linux, and may not behave correctly on Linux due to Foundation being [incomplete](https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md).
9+
510
## [1.0.0] - 2020-07-16
611
This is the first public release of the LDSwiftEventSource library. The following notes are what changed since the previous pre-release version.
712
### Changed

LDSwiftEventSource.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "LDSwiftEventSource"
3-
s.version = "1.0.0"
3+
s.version = "1.1.0"
44
s.summary = "Swift EventSource library"
55
s.homepage = "https://github.com/launchdarkly/swift-eventsource"
66
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE.txt" }

LDSwiftEventSource.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@
289289
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
290290
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
291291
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
292+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
292293
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
293294
CLANG_WARN_STRICT_PROTOTYPES = YES;
294295
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -330,11 +331,11 @@
330331
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
331332
SWIFT_VERSION = 5.0;
332333
TVOS_DEPLOYMENT_TARGET = 10.0;
333-
"VALID_ARCHS[sdk=appletvos*]" = arm64;
334+
"VALID_ARCHS[sdk=appletvos*]" = "arm64 arm64e";
334335
"VALID_ARCHS[sdk=appletvsimulator*]" = x86_64;
335-
"VALID_ARCHS[sdk=iphoneos*]" = "arm64 armv7 armv7s";
336+
"VALID_ARCHS[sdk=iphoneos*]" = "arm64 arm64e armv7 armv7s";
336337
"VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64";
337-
"VALID_ARCHS[sdk=macosx*]" = "x86_64 arm64";
338+
"VALID_ARCHS[sdk=macosx*]" = "x86_64 arm64 arm64e";
338339
"VALID_ARCHS[sdk=watchos*]" = "armv7k arm64_32";
339340
"VALID_ARCHS[sdk=watchsimulator*]" = "x86_64 i386";
340341
VERSIONING_SYSTEM = "apple-generic";
@@ -369,6 +370,7 @@
369370
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
370371
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
371372
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
373+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
372374
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
373375
CLANG_WARN_STRICT_PROTOTYPES = YES;
374376
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -403,11 +405,11 @@
403405
SWIFT_OPTIMIZATION_LEVEL = "-O";
404406
SWIFT_VERSION = 5.0;
405407
TVOS_DEPLOYMENT_TARGET = 10.0;
406-
"VALID_ARCHS[sdk=appletvos*]" = arm64;
408+
"VALID_ARCHS[sdk=appletvos*]" = "arm64 arm64e";
407409
"VALID_ARCHS[sdk=appletvsimulator*]" = x86_64;
408-
"VALID_ARCHS[sdk=iphoneos*]" = "arm64 armv7 armv7s";
410+
"VALID_ARCHS[sdk=iphoneos*]" = "arm64 arm64e armv7 armv7s";
409411
"VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64";
410-
"VALID_ARCHS[sdk=macosx*]" = "x86_64 arm64";
412+
"VALID_ARCHS[sdk=macosx*]" = "x86_64 arm64 arm64e";
411413
"VALID_ARCHS[sdk=watchos*]" = "armv7k arm64_32";
412414
"VALID_ARCHS[sdk=watchsimulator*]" = "x86_64 i386";
413415
VERSIONING_SYSTEM = "apple-generic";
@@ -439,7 +441,7 @@
439441
"@executable_path/../Frameworks",
440442
"@loader_path/Frameworks",
441443
);
442-
MARKETING_VERSION = 1.0.0;
444+
MARKETING_VERSION = 1.1.0;
443445
SKIP_INSTALL = YES;
444446
"TARGETED_DEVICE_FAMILY[sdk=appletvos*]" = 3;
445447
"TARGETED_DEVICE_FAMILY[sdk=appletvsimulator*]" = 3;
@@ -473,7 +475,7 @@
473475
"@executable_path/../Frameworks",
474476
"@loader_path/Frameworks",
475477
);
476-
MARKETING_VERSION = 1.0.0;
478+
MARKETING_VERSION = 1.1.0;
477479
SKIP_INSTALL = YES;
478480
"TARGETED_DEVICE_FAMILY[sdk=appletvos*]" = 3;
479481
"TARGETED_DEVICE_FAMILY[sdk=appletvsimulator*]" = 3;

LinuxMain.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import XCTest
2+
3+
import LDSwiftEventSourceTests
4+
5+
var tests = [XCTestCaseEntry]()
6+
tests += LDSwiftEventSourceTests.__allTests()
7+
8+
XCTMain(tests)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ pod 'LDSwiftEventSource', '~> 1.0'
2424

2525
### Carthage
2626

27-
To use the [Carthage](https://github.com/Carthage/Carthage) dependency manager to integrate LDSwiftEventSource into your Xcode project, specify it in your `Cartfile` :
27+
To use the [Carthage](https://github.com/Carthage/Carthage) dependency manager to integrate LDSwiftEventSource into your Xcode project, specify it in your `Cartfile`:
2828

2929
```ogdl
3030
github "LaunchDarkly/swift-eventsource" ~> 1.0
3131
```
3232

3333
### Swift Package Manager
3434

35-
The [Swift Package Manager](https://swift.org/package-manager/) is a dependency manager integrated into the `swift` compiler and XCode. Note that the LDSwiftEventSource Swift package provides both a `LDSwiftEventSource` product, which is explicitely dynamic, and a `LDSwiftEventSourceStatic` product which is explicitely static.
35+
The [Swift Package Manager](https://swift.org/package-manager/) is a dependency manager integrated into the `swift` compiler and Xcode. Note that the LDSwiftEventSource Swift package provides both a `LDSwiftEventSource` product, which is explicitely dynamic, and a `LDSwiftEventSourceStatic` product which is explicitely static.
3636

37-
To integrate LDSwiftEventSource into an XCode project, go to the project editor, and select `Swift Packages`. From here hit the `+` button and follow the prompts using `https://github.com/LaunchDarkly/swift-eventsource.git` as the URL.
37+
To integrate LDSwiftEventSource into an Xcode project, go to the project editor, and select `Swift Packages`. From here hit the `+` button and follow the prompts using `https://github.com/LaunchDarkly/swift-eventsource.git` as the URL.
3838

3939
To include LDSwiftEventSource in a Swift package, simply add it to the dependencies section of your `Package.swift` file. And add the desired product as a dependency for your targets.
4040

Source/LDSwiftEventSource.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import Foundation
2+
3+
#if os(Linux)
4+
import FoundationNetworking
5+
#endif
6+
7+
#if !os(Linux)
28
import os.log
9+
#endif
310

411
public class EventSource {
512
private let esDelegate: EventSourceDelegate
@@ -69,10 +76,13 @@ public class EventSource {
6976

7077
class EventSourceDelegate: NSObject, URLSessionDataDelegate {
7178

79+
#if !os(Linux)
80+
private let logger: OSLog = OSLog(subsystem: "com.launchdarkly.swift-eventsource", category: "LDEventSource")
81+
#endif
82+
7283
private let config: EventSource.Config
7384

7485
private let delegateQueue: DispatchQueue = DispatchQueue(label: "ESDelegateQueue")
75-
private let logger: OSLog
7686

7787
private var readyState: ReadyState = .raw
7888

@@ -90,14 +100,15 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
90100
self.config = config
91101
self.lastEventId = config.lastEventId
92102
self.reconnectTime = config.reconnectTime
93-
self.logger = OSLog(subsystem: "com.launchdarkly.swift-eventsource", category: "LDEventSource")
94103
}
95104

96105
func start() {
97106
delegateQueue.async {
98107
guard self.readyState == .raw
99108
else {
109+
#if !os(Linux)
100110
os_log("Start method called on this already-started EventSource object. Doing nothing", log: self.logger, type: .info)
111+
#endif
101112
return
102113
}
103114
self.connect()
@@ -115,7 +126,9 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
115126
func getLastEventId() -> String? { lastEventId }
116127

117128
private func connect() {
129+
#if !os(Linux)
118130
os_log("Starting EventSource client", log: logger, type: .info)
131+
#endif
119132
let connectionHandler: ConnectionHandler = (
120133
setReconnectionTime: { reconnectionTime in self.reconnectTime = reconnectionTime },
121134
setLastEventId: { eventId in self.lastEventId = eventId }
@@ -149,11 +162,15 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
149162
var nextState: ReadyState = .closed
150163
let currentState: ReadyState = readyState
151164
if errorHandlerAction == .shutdown {
165+
#if !os(Linux)
152166
os_log("Connection has been explicitly shut down by error handler", log: logger, type: .info)
167+
#endif
153168
nextState = .shutdown
154169
}
155170
readyState = nextState
171+
#if !os(Linux)
156172
os_log("State: %@ -> %@", log: logger, type: .debug, currentState.rawValue, nextState.rawValue)
173+
#endif
157174

158175
if currentState == .open {
159176
config.handler.onClosed()
@@ -174,7 +191,9 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
174191
let maxSleep = min(config.maxReconnectTime, reconnectTime * pow(2.0, Double(reconnectionAttempts)))
175192
let sleep = maxSleep / 2 + Double.random(in: 0...(maxSleep/2))
176193

194+
#if !os(Linux)
177195
os_log("Waiting %.3f seconds before reconnecting...", log: logger, type: .info, sleep)
196+
#endif
178197
delegateQueue.asyncAfter(deadline: .now() + sleep) {
179198
self.connect()
180199
}
@@ -190,13 +209,17 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
190209

191210
if let error = error {
192211
if readyState != .shutdown {
212+
#if !os(Linux)
193213
os_log("Connection error: %@", log: logger, type: .info, error.localizedDescription)
214+
#endif
194215
errorHandlerAction = dispatchError(error: error)
195216
} else {
196217
errorHandlerAction = .shutdown
197218
}
198219
} else {
220+
#if !os(Linux)
199221
os_log("Connection unexpectedly closed.", log: logger, type: .info)
222+
#endif
200223
}
201224

202225
afterComplete()
@@ -207,7 +230,9 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
207230
dataTask: URLSessionDataTask,
208231
didReceive response: URLResponse,
209232
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
233+
#if !os(Linux)
210234
os_log("initial reply received", log: logger, type: .debug)
235+
#endif
211236

212237
let httpResponse = response as! HTTPURLResponse
213238
if (200..<300).contains(httpResponse.statusCode) {
@@ -216,7 +241,9 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate {
216241
config.handler.onOpened()
217242
completionHandler(.allow)
218243
} else {
244+
#if !os(Linux)
219245
os_log("Unsuccessful response: %d", log: logger, type: .info, httpResponse.statusCode)
246+
#endif
220247
errorHandlerAction = dispatchError(error: UnsuccessfulResponseError(responseCode: httpResponse.statusCode))
221248
completionHandler(.cancel)
222249
}

Tests/EventParserTests.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,4 @@ final class EventParserTests: XCTestCase {
173173
XCTAssertEqual(eventHandler.received, [.message("msg", MessageEvent(data: "foo", lastEventId: nil)),
174174
.message("message", MessageEvent(data: "bar", lastEventId: nil))])
175175
}
176-
177-
static var allTests = [
178-
("testDispatchesSingleLineMessage", testDispatchesSingleLineMessage),
179-
("testDoesNotFireMultipleTimesIfSeveralEmptyLines", testDoesNotFireMultipleTimesIfSeveralEmptyLines),
180-
("testDispatchesSingleLineMessageWIthId", testDispatchesSingleLineMessageWIthId),
181-
("testDispatchesSingleLineMessageWithCustomEvent", testDispatchesSingleLineMessageWithCustomEvent),
182-
("testSendsCommentsForLinesStartingWithColon", testSendsCommentsForLinesStartingWithColon),
183-
("testSetsRetryTimeToSevenSeconds", testSetsRetryTimeToSevenSeconds),
184-
("testDoesNotSetRetryTimeUnlessEntireValueIsNumeric", testDoesNotSetRetryTimeUnlessEntireValueIsNumeric),
185-
("testReusesEventIdIfNotSet", testReusesEventIdIfNotSet),
186-
("testRemovesOnlyFirstSpace", testRemovesOnlyFirstSpace),
187-
("testAllowsNoLeadingSpace", testAllowsNoLeadingSpace),
188-
("testDoesNotDispatchEmptyData", testDoesNotDispatchEmptyData),
189-
("testOnlyLeadingSpaceTreatedAsEmpty", testOnlyLeadingSpaceTreatedAsEmpty),
190-
("testLineWithoutColonTreatedAsFieldNameWithEmptyData", testLineWithoutColonTreatedAsFieldNameWithEmptyData),
191-
("testMultipleDataDispatch", testMultipleDataDispatch),
192-
("testEmptyDataWithBufferedDataAppendsNewline", testEmptyDataWithBufferedDataAppendsNewline),
193-
("testCommentCanContainColon", testCommentCanContainColon),
194-
("testInvalidFieldNameIgnoredInEvent", testInvalidFieldNameIgnoredInEvent),
195-
("testEventNameResetAfterDispatch", testEventNameResetAfterDispatch)
196-
]
197176
}

Tests/LDSwiftEventSourceTests.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ final class LDSwiftEventSourceTests: XCTestCase {
4444
XCTAssertEqual(config.backoffResetThreshold, 120.0)
4545
XCTAssertEqual(config.idleTimeout, 180.0)
4646
}
47-
48-
static var allTests = [
49-
("testConfigDefaults", testConfigDefaults),
50-
("testConfigModification", testConfigModification)
51-
]
5247
}
5348

5449
private class MockHandler: EventHandler {
@@ -71,6 +66,4 @@ private class MockHandler: EventHandler {
7166
func onError(error: Error) {
7267

7368
}
74-
75-
7669
}

Tests/UTF8LineParserTests.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,4 @@ final class UTF8LineParserTests: XCTestCase {
107107
XCTAssertEqual(parser.append(data), expected)
108108
XCTAssertEqual(parser.closeAndReset(), [])
109109
}
110-
111-
static var allTests = [
112-
("testNoData", testNoData),
113-
("testEmptyData", testEmptyData),
114-
("testEmptyCrLine", testEmptyCrLine),
115-
("testBasicLine", testBasicLine),
116-
("testBasicLineCr", testBasicLineCr),
117-
("testBasicLineLf", testBasicLineLf),
118-
("testBasicLineCrLf", testBasicLineCrLf),
119-
("testBasicSplit", testBasicSplit),
120-
("testUnicodeString", testUnicodeString),
121-
("testInvalidCharacterReplaced", testInvalidCharacterReplaced),
122-
("testCodePointSplitNotReplaced", testCodePointSplitNotReplaced),
123-
("testPartialReplacedOnClose", testPartialReplacedOnClose),
124-
("testInvalidCharacterReplacedOnNextLineAfterCr", testInvalidCharacterReplacedOnNextLineAfterCr),
125-
("testMultiLineDataMixedLineEnding", testMultiLineDataMixedLineEnding)
126-
]
127110
}

0 commit comments

Comments
 (0)