Skip to content

Commit

Permalink
Xcode 9.3 / Swift 4.1 / Swift 3.3 updates
Browse files Browse the repository at this point in the history
Strictly I’d feel better to test all configurations, but PromiseKit only uses Foundation, so the chance that for some reason there is an API break or worse some kind of runtime issue is pretty low and I feel that we have to be kinder to Travis’s free infrastructure.

Tag 6.0.2
  • Loading branch information
mxcl committed Feb 16, 2018
1 parent 9cc1cc9 commit 5984787
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 63 deletions.
60 changes: 31 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
matrix:
include:
- {osx_image: xcode8.3, env: 'PLAT=macOS SWFT=3.1 DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=iOS SWFT=3.1 DST="OS=8.4,name=iPhone 4s"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=iOS SWFT=3.1 DST="OS=9.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=iOS SWFT=3.1 DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=tvOS SWFT=3.1 DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=watchOS SWFT=3.1 DST="OS=2.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'PLAT=watchOS SWFT=3.1 DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=iOS DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=tvOS DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=watchOS DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode9.2, env: 'PLAT=macOS SWFT=3.2 DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=3.2 DST="OS=8.4,name=iPhone 4s"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=3.2 DST="OS=9.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=3.2 DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=3.2 DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=tvOS SWFT=3.2 DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=tvOS SWFT=3.2 DST="OS=11.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=watchOS SWFT=3.2 DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=watchOS SWFT=3.2 DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=iOS DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=tvOS DST="OS=11.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=watchOS DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode9.2, env: 'PLAT=macOS SWFT=4.0 DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=4.0 DST="OS=8.4,name=iPhone 4s"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=4.0 DST="OS=9.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=4.0 DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=iOS SWFT=4.0 DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=tvOS SWFT=4.0 DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=tvOS SWFT=4.0 DST="OS=11.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=watchOS SWFT=4.0 DST="OS=2.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=watchOS SWFT=4.0 DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'PLAT=watchOS SWFT=4.0 DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=3.3 PLAT=iOS DST="OS=11.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=3.3 PLAT=tvOS DST="OS=11.3,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=3.3 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=3.3 PLAT=watchOS DST="OS=4.3,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=iOS DST="OS=8.4,name=iPhone 4s"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=iOS DST="OS=9.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=iOS DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=iOS DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=tvOS DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=tvOS DST="OS=11.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=watchOS DST="OS=2.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=watchOS DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=watchOS DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode9.3beta, env: 'SWFT=4.1 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=4.1 PLAT=iOS DST="OS=11.3,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=4.1 PLAT=tvOS DST="OS=11.3,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.3beta, env: 'SWFT=4.1 PLAT=watchOS DST="OS=4.3,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {os: linux, dist: trusty, sudo: required, services: docker, env: 'DOCKER_IMAGE=swift:3.1'}
#TODO please help us test Linux with Swift 3.0, 3.2 and 4.0
- {os: linux, dist: trusty, sudo: required, services: docker, env: 'DOCKER_IMAGE=swift:4.0'}

before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
Expand All @@ -40,8 +42,8 @@ script:
- set -o pipefail
- case $PLAT in
iOS|tvOS|macOS)
xcodebuild -scheme PromiseKit -destination "$DST" -quiet build-for-testing SWIFT_VERSION=$SWFT -enableCodeCoverage YES | xcpretty;
xcodebuild -scheme PromiseKit -quiet test;;
xcodebuild -scheme PromiseKit SWIFT_VERSION=$SWFT -quiet build-for-testing -destination "$DST" -enableCodeCoverage YES | xcpretty;
xcodebuild -scheme PromiseKit SWIFT_VERSION=$SWFT -quiet test;;
watchOS)
xcodebuild -scheme PromiseKit -destination "$DST" -quiet build SWIFT_VERSION=$SWFT | xcpretty;;
*)
Expand Down
8 changes: 4 additions & 4 deletions Documentation/CommonPatterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ avoiding throwing an error because you can’t be bothered to define a good glob

## Abstracting Away Asychronicity

```switch
```swift
var fetch = API.fetch()

override func viewDidAppear() {
Expand Down Expand Up @@ -288,10 +288,10 @@ func attempt<T>(interdelay: DispatchTimeInterval = .seconds(2), maxRepeat: Int =
var attempts = 0
func attempt() -> Promise<T> {
attempts += 1
return body().recover { error in
return body().recover { error -> Promise<T> in
guard attempts < maxRepeat else { throw error }

return after(interval: interdelay).then {
return after(interdelay).then {
attempt()
}
}
Expand Down Expand Up @@ -370,7 +370,7 @@ CLLocationManager.promise().then { locations in

Sometimes you don’t want an error to cascade, instead you have a default value:

```
```swift
CLLocationManager.promise().recover { error -> CLLocation in
guard error == MyError.airplaneMode else {
throw error
Expand Down
22 changes: 13 additions & 9 deletions Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ You can just drop `PromiseKit.xcodeproj` into your project and then add

PromiseKit contains Swift, so there have been rev-lock issues with Xcode:

| PromiseKit | Swift | Xcode | CI Status | Release Notes |
| ---------- | -------- | -------- | ------------ | ----------------- |
| 6 | 3.x, 4.x | 8.x, 9.x | ![ci-master] | [2018/02][news-6] |
| 5 | 3.x, 4.x | 8.x, 9.x | ![ci-master] | *Deprecated* |
| 4 | 3.x, 4.x | 8.x, 9.x | ![ci-master] | [2016/09][news-4] |
| 3 | 2.x | 7.x, 8.0 | ![ci-swift2] | [2015/10][news-3] |
| 2 | 1.x | 7.x | Unsupported | [2015/10][news-3] |
| 1† | *N/A* | * | ![ci-legacy] ||
| PromiseKit | Swift | Xcode | CI Status | Release Notes |
| ---------- | ----------------------- | -------- | ------------ | ----------------- |
| 6 | 3.1, 3.2, 3.3, 4.x | 8.3, 9.x | ![ci-master] | [2018/02][news-6] |
| 5 | 3.1, 3.2, 3.3, 4.x | 8.3, 9.x | *Deprecated* | *n/a* |
| 4 | 3.0, 3.1, 3.2, 3.3, 4.x | 8.x, 9.x | ![ci-master] | [2016/09][news-4] |
| 3 | 2.x | 7.x, 8.0 | ![ci-swift2] | [2015/10][news-3] |
| 2 | 1.x | 7.x | *Deprecated* | [2015/10][news-3] |
| 1† | *N/A* | * | ![ci-legacy] ||

† PromiseKit 1 is pure Objective-C and thus can be used with any Xcode, it is
Expand Down Expand Up @@ -149,9 +149,13 @@ Then when you `pod update`, ensure you also update your submodules:

# Release History

## [6.0](https://github.com/mxcl/PromiseKit/releases/tag/6.0.0) Feb 13th, 2019

* [PromiseKit 4 announcement post][news-6].

## [4.0](https://github.com/mxcl/PromiseKit/releases/tag/4.0.0)

* [PromiseKit 4 announcement post](http://promisekit.org/news/2016/09/PromiseKit-4.0-Released/).
* [PromiseKit 4 announcement post][news-4].

## [3.0](https://github.com/mxcl/PromiseKit/releases/tag/3.0.0) Oct 1st, 2015

Expand Down
16 changes: 11 additions & 5 deletions PromiseKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
6399A3721D595D9100D65233 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
TargetAttributes = {
630019011D596292003B4E30 = {
LastSwiftMigration = 0900;
Expand Down Expand Up @@ -785,12 +785,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -799,7 +801,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.0.1;
CURRENT_PROJECT_VERSION = 6.0.2;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -808,6 +810,7 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -825,7 +828,7 @@
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos watchsimulator iphonesimulator watchos iphoneos";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand All @@ -843,12 +846,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -857,13 +862,14 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.0.1;
CURRENT_PROJECT_VERSION = 6.0.2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -879,7 +885,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos watchsimulator iphonesimulator watchos iphoneos";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -96,7 +95,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ target "Change Me!" do
end
```

PromiseKit 6, 5 and 4 support Xcode 8.1, 8.2, 8.3, 9.0, 9.1 and 9.2; Swift 3.0,
3.1, 3.2, 4.0 and 4.1 ; iOS, macOS, tvOS, watchOS, Linux and Android; CocoaPods,
PromiseKit 6, 5 and 4 support Xcode 8.3, 9.0, 9.1 and 9.2; Swift 3.1,
3.2, 3.3, 4.0 and 4.1 ; iOS, macOS, tvOS, watchOS, Linux and Android; CocoaPods,
Carthage and SwiftPM; ([CI Matrix](https://travis-ci.org/mxcl/PromiseKit)).

For Carthage, SwiftPM, etc., or for instructions when using older Swifts or
Expand Down
13 changes: 3 additions & 10 deletions Sources/Thenable.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import Dispatch


//TODO fire off a message to the Queue's runloop to avoid zalgo
// if no runloop, show warning about zalgo
// in case of `nil` don't do that and also don't dispatch to queue later
// in caes of `main` we can optimize and avoid a dispatch if we're on the main queue and zalgo was avoided


public protocol Thenable: class {
associatedtype T
func pipe(to: @escaping(Result<T>) -> Void)
Expand Down Expand Up @@ -181,10 +174,10 @@ public extension Thenable where T: Sequence {

func compactMap<U>(on: DispatchQueue? = conf.Q.map, _ transform: @escaping(T.Iterator.Element) throws -> U?) -> Promise<[U]> {
return map(on: on) { foo -> [U] in
#if swift(>=4.1)
return try foo.compactMap(transform) }
#else
#if !swift(>=3.3) || (swift(>=4) && !swift(>=4.1))
return try foo.flatMap(transform)
#else
return try foo.compactMap(transform)
#endif
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/when.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ public func when<It: IteratorProtocol>(fulfilled promiseIterator: It, concurrent
func testDone() {
barrier.sync {
if pendingPromises == 0 {
#if !swift(>=3.3) || (swift(>=4) && !swift(>=4.1))
root.resolver.fulfill(promises.flatMap{ $0.value })
#else
root.resolver.fulfill(promises.compactMap{ $0.value })
#endif
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/0.0.0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension XCTestCase {
let (pending, seal) = Promise<Void>.pending()

do {
try body((pending, seal.fulfill, seal.reject), expectation)
try body((pending, { seal.fulfill(()) }, seal.reject), expectation)
waitForExpectations(timeout: timeout) { err in
if let _ = err {
XCTFail("wait failed: \(description)", file: file, line: line)
Expand Down

0 comments on commit 5984787

Please sign in to comment.