Skip to content

Updating for swift 4.x and Xcode 10.1#295

Merged
jeffctown merged 4 commits into
AliSoftware:masterfrom
jeffctown:feature/Swift4Support
Mar 14, 2019
Merged

Updating for swift 4.x and Xcode 10.1#295
jeffctown merged 4 commits into
AliSoftware:masterfrom
jeffctown:feature/Swift4Support

Conversation

@jeffctown

Copy link
Copy Markdown
Collaborator

Updating for version 7.0.0.
Updating to swift 4.2 (but retaining compatibility with swift 2.3 & 3x & 4.x.
Updating deployment target to iOS 8.0 since Xcode 10.1 doesn’t support iOS 7 anymore.
Updating example projects.
Updating README badges.
Updating CHANEGLOG.
Updating Rakefile for Xcode 10.1.

Checklist

  • I've checked that all new and existing tests pass
  • I've updated the documentation if necessary
  • I've added an entry in the CHANGELOG to credit myself

Description

Updated for Swift 4.x and Xcode 10.1.

Motivation and Context

This change resolves compilation issues for projects using Swift 4.x and Xcode 10.1. The current version of Xcode (10.1) also does not support iOS 7, so I removed support for that.

I tested this change by compiling the two examples projects and running them to make sure they function as before. I also ran all 3 sets of unit tests.

@jeffctown

jeffctown commented Jan 17, 2019

Copy link
Copy Markdown
Collaborator Author

I have a carthage archive of this branch if the CI passes and the PR is approved.

@jeffctown jeffctown changed the title Updating to swift 4.2. Updating for swift 4.x and Xcode 10.1 Jan 17, 2019
@jeffctown

Copy link
Copy Markdown
Collaborator Author

@AliSoftware let me know if you have any issues with this or if there's anything I can do to get travis running.

@AliSoftware AliSoftware left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR!

This seems file at first (only looked at it in GitHub web UI for now), so except the point I was wondering about for LaunchKey, should be good to go.

PS: Note though that tbh, I've fallen back a little on my maintenance on OHHTTPStubs lately, with some prior PRs that should have been ready to merge for a while, but for which I haven't found time to check everything and revalidate them to release an official version yet… So I might need to find the time to merge those older PRs first, then do a 6.x. release with their changes, to finally merge yours afterwards (which would indeed bump to 7.0); so might take a few days for me to find the time where I can have a Mac nearby and do all that properly 😉

Comment thread Examples/Swift/AppDelegate.swift Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested, but I think this change would need a extension UIApplication { typealias LaunchOptionKey = UIApplicationLaunchOptionKey } inside some #if swift(>…) to be able to still work with older Swift versions which did not have the new namespacing of that type before?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c9b28c9.

@AliSoftware

Copy link
Copy Markdown
Owner

Note that for some time now, Travis-CI hasn't been very reliable on OHHTTPStubs especially due to some timing tests randomly failing (depending on the CI CPU speed I think), but also sometimes travis failing to kick in and trigger the VM and tests… (I'm willing to migrate to CircleCI for a while but didn't yet). It's always fun to have to regularly restart the CI jobs when that happens, so don't be too surprised by that CI state, it might not be related to your PR specifically…

@jeffctown

Copy link
Copy Markdown
Collaborator Author

This totally makes sense @AliSoftware . Let me know if I can help with any of this.

FYI - I read the Xcode 10.2 beta release notes today, and Swift 3 won't be supported.

Swift 3 mode has been removed. Supported values for the -swift-version flag are 4, 4.2, and 5. (43101816)

from: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_beta_release_notes/swift_5_release_notes_for_xcode_10_2_beta

@sunshinejr

Copy link
Copy Markdown
Collaborator

Hey @AliSoftware @jeffctown, what's left here to get this one merged in?

@jeffctown

jeffctown commented Feb 19, 2019

Copy link
Copy Markdown
Collaborator Author

👋 @sunshinejr . I'm happy to help out, but I'm waiting on next steps from @AliSoftware.

Since the existing code compiles fine in Swift 4.2, once I updated my test target to Swift 4.2 and ran pod install this dependency is compiling and working fine in Swift 4.2. I'm not sure if this would work with your app / setup, but it unblocked my Swift 4.2 migration.

@marcussc

marcussc commented Mar 5, 2019

Copy link
Copy Markdown

@AliSoftware Maybe I can help on this one too? Xcode 10.2 is coming closer very fast would be a shame to have to stick to 10.1 because of our beloved OHHTTPStubs :)

@AliSoftware

Copy link
Copy Markdown
Owner

I have to be honest I just started a new job, in a new country… so pretty swamped those days in it's not gonna get better until a few weeks I think.

I happy to hand over and give push access to anyone willing to help, so if you're interested in becoming a co-maintainer and help with merging PRs and doing releases I'll be happy to make it happen so that someone can make those move forward while I'm busy 😅

@jeffctown

Copy link
Copy Markdown
Collaborator Author

Note that for some time now, Travis-CI hasn't been very reliable on OHHTTPStubs especially due to some timing tests randomly failing (depending on the CI CPU speed I think), but also sometimes travis failing to kick in and trigger the VM and tests… (I'm willing to migrate to CircleCI for a while but didn't yet). It's always fun to have to regularly restart the CI jobs when that happens, so don't be too surprised by that CI state, it might not be related to your PR specifically…

@AliSoftware

I have to be honest I just started a new job, in a new country… so pretty swamped those days in it's not gonna get better until a few weeks I think. ...

@AliSoftware totally understandable. I’d be happy to help merge and release.

Sent with GitHawk

@AliSoftware

Copy link
Copy Markdown
Owner

@jeffctown Just added you as contributor with push access ;) I trust you'll review other pending PRs too (checking if some need to be merged first before this one? then rebase this one, etc) so everything is ready for release 👍

Jeff Lett and others added 2 commits March 9, 2019 09:19
Updating for version 7.0.0.
Updating to swift 4.2 (but retaining compatibility with swift 2.3 & 3x & 4.x.
Updating deployment target to iOS 8.0 since Xcode 10.1 doesn’t support iOS 7 anymore.
Updating example projects.
Updating README badges.
Updating CHANEGLOG.
Updating Rakefile for Xcode 10.1.
Comment thread README.md Outdated
[![Carthage Swift 4.2](https://img.shields.io/badge/Carthage-Swift%204.2-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Build Status](https://travis-ci.org/AliSoftware/OHHTTPStubs.svg?branch=master)](https://travis-ci.org/AliSoftware/OHHTTPStubs)
[![Language: Swift-2.3/3.0/3.1/4.2](https://img.shields.io/badge/Swift-2.3%2F3.0%2F3.1%2F4.0%2F4.1%2F4.2-orange.svg)](https://swift.org)
[![Language: Swift-2.3/3.0/3.1/3.2/4.0/4.1/4.2](https://img.shields.io/badge/Swift-2.3%2F3.0%2F3.1%2F3.2%2F4.0%2F4.1%2F4.2-orange.svg)](https://swift.org)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At that point maybe it's not worth it to list them all as it'll get pretty long 😅, maybe just 2.3 to 4.2 or 2.x & 3.x & 4.x?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c9b28c9.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is something i wonder about. Why/How many Swift Versions should be kept? IMHO: Its not worth to keep so many Versions around. If someone needs an older Swift Version they can get an older Version of OHHTTPStubs?

Comment thread CHANGELOG.md
* Updating project settings for Xcode 10.1.
[@jeffctown](https://github.com/jeffctown)
* Updating example projects for new version.
[@jeffctown](https://github.com/jeffctown)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to also reference all the people who submitted a PR for updating to all those successive Xcode/Swift versions (even though we ended up not merging then because I was so late on my OSS time to merge them but since they made the effort…)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this idea. Updated in c9b28c9.

[self setImageView:nil];
[self setDelaySwitch:nil];
[super viewDidUnload];
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 Good old times 😄

Comment thread OHHTTPStubs/Podfile

target 'OHHTTPStubs iOS Lib Tests' do
platform :ios, '7.0'
platform :ios, '8.0'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that minimum certain requirement bump in the CHANGELOG too, after all it's a breaking change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c9b28c9.

Comment thread CHANGELOG.md Outdated

## [Future Release]

* Updating default Swift Version to 4.2, but keeping code compiling in Swift 2.3, 3.x, and 4.x.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be interesting to mention that only 4.x+ is tested on CI so 2.3 compatibility for example isn't guaranteed by tests and might break at any time because we don't test it anymore.

(Might actually be simpler to just drop the mention of 2.x altogether anyway and stop mentioning it tbh)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c9b28c9. I went with the path of removing 2.x mentions.

Comment thread README.md
* either use an older Xcode version
* or use the previous version of `OHHTTPStubs` (6.2.0) — whose `master` branch uses `3.0`
* or fork the repo just to change the `SWIFT_VERSION` build setting to `3.0`

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also add well remove the paragraph about 2.3 too here and make that paragraph about 3.x just replace it (instead of being in addition of it).

Also I'm not sure we did Swift-3.x branches back in the day, branches was just used during the 2 to 3 transition. So might just as well start that paragraph directly with "If you want…"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c9b28c9.

@AliSoftware AliSoftware left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the last nitpick LGTM

Comment thread Examples/Swift/AppDelegate.swift Outdated
typealias LaunchOptionsKey = UIApplication.LaunchOptionsKey
#else
typealias LaunchOptionsKey = UIApplicationLaunchOptionsKey
#endif

@AliSoftware AliSoftware Mar 10, 2019

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually only declare the typealias for old versions so that by the time we drop those old version we'll only have to delete the typealias 😉

#if !swift(>=4.0)
extension UIApplication {
  typealias LaunchOptionKey = UIApplicationLaunchOptionKey
}
#endif

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated.

@jeffctown jeffctown merged commit 5431829 into AliSoftware:master Mar 14, 2019
@jeffctown jeffctown deleted the feature/Swift4Support branch March 14, 2019 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants