Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted library and Demo project to Swift 3 #31

Merged
merged 12 commits into from
Nov 14, 2016

Conversation

ceyhun
Copy link
Collaborator

@ceyhun ceyhun commented Nov 9, 2016

I converted the project to Swift 3 using the master branch. It was not possible to rebase swift3 branch on top of master as mentioned in #30 because of numerous conflicts.

- Updated podspec version to 3.0.0
- Updated README and Changelog
- Removed `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting
- Updated `.travis.yml` and `.swift-version`
@ceyhun ceyhun closed this Nov 9, 2016
@ceyhun ceyhun reopened this Nov 9, 2016
@Grubas7
Copy link
Collaborator

Grubas7 commented Nov 9, 2016

@ceyhuno probably you are looking for #30

@ceyhun ceyhun mentioned this pull request Nov 9, 2016
5 tasks
@ceyhun
Copy link
Collaborator Author

ceyhun commented Nov 9, 2016

@Grubas7 I am aware of #30 but it has some conflicts with master and it hasn't received a response from @phatblat for a longtime. Also the things @AliSoftware requested to merge #30 like rebasing on top of master and cleaning the history cannot be done easily. I think we can close #30 and merge #31 instead.

@AliSoftware
Copy link
Owner

AliSoftware commented Nov 9, 2016

It seems that the CocoaPods version used by Travis isn't recent enough to catch the .swift-version file when linting the pod? The errors I see seems to be like it's linting with Swift 2.3 even if .swift-version contains 3.0 in that PR… Or I'm not even sure what's happening?

@ceyhuno Could you add SWIFT_VERSION=3.0 to the env entry in the .travis.yml (the same way it was set to 2.3 before your changes) to enforce that and check that it helps make it work on travis?

@@ -18,8 +18,8 @@ public extension UICollectionView {

- seealso: `registerNib(_:,forCellWithReuseIdentifier:)`
*/
final func registerReusableCell<T: UICollectionViewCell where T: NibReusable>(cellType: T.Type) {
self.registerNib(cellType.nib, forCellWithReuseIdentifier: cellType.reuseIdentifier)
final func registerReusableCell<T: UICollectionViewCell>(_ cellType: T.Type) where T: NibReusable {
Copy link
Owner

Choose a reason for hiding this comment

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

Wondering if, to comply to the Swift 3.0 API design guidelines, we shouldn't declare that as register<T: UICollectionViewCell>(cellType: T.Type) where T: NibReusable instead (so that call site looks like collectionView.register(cellType: MyXIBCell.self)?

Of course same comment and reflection applies to all the methods for UICollectionView and UITableView.

@phatblat
Copy link
Collaborator

phatblat commented Nov 9, 2016

Looks like this PR includes the API change @Grubas7 suggested. Less work to finish this up than to clean up the long history on #30. Thanks, @ceyhuno!

Copy link
Owner

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Careful with indentation, the YAML format is very picky about it and missing it makes the YAML invalid 😉

@AliSoftware
Copy link
Owner

I'm not sur what's happening on Travis. Analysing again the logs of the previous build that failed (th one before your commit to add SWIFT_VERSION=3.0), I now realise that the problem doesn't lie in the CocoaPods version on the VM (the VM comes with CP 1.0.1 before the gem install cocoapods but correctly updates it to 1.1.1 after), but by the Xcode version itself.

It seems to pick Xcode 7 instead of Xcode 8

$ xcodebuild -version -sdk
MacOSX10.11.sdk - OS X 10.11 (macosx10.11)
SDKVersion: 10.11
Path: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
PlatformVersion: 1.1
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
ProductBuildVersion: 15E60
ProductCopyright: 1983-2016 Apple Inc.
ProductName: Mac OS X
ProductUserVisibleVersion: 10.11.4
ProductVersion: 10.11.4
iPhoneOS9.3.sdk - iOS 9.3 (iphoneos9.3)
SDKVersion: 9.3
Path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk
PlatformVersion: 9.3
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
ProductBuildVersion: 13E230
ProductCopyright: 1983-2016 Apple Inc.
ProductName: iPhone OS
ProductVersion: 9.3
iPhoneSimulator9.3.sdk - Simulator - iOS 9.3 (iphonesimulator9.3)
SDKVersion: 9.3
Path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk
PlatformVersion: 9.3
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
ProductBuildVersion: 13E230
ProductCopyright: 1983-2016 Apple Inc.
ProductName: iPhone OS
ProductVersion: 9.3
AppleTVOS9.2.sdk - tvOS 9.2 (appletvos9.2)
SDKVersion: 9.2
Path: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk
PlatformVersion: 9.2
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform
ProductBuildVersion: 13Y227
ProductCopyright: 1983-2016 Apple Inc.
ProductName: Apple TVOS
ProductVersion: 9.2
AppleTVSimulator9.2.sdk - Simulator - tvOS 9.2 (appletvsimulator9.2)
SDKVersion: 9.2
Path: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.2.sdk
PlatformVersion: 9.2
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform
ProductBuildVersion: 13Y227
ProductCopyright: 1983-2016 Apple Inc.
ProductName: Apple TVOS
ProductVersion: 9.2
WatchOS2.2.sdk - watchOS 2.2 (watchos2.2)
SDKVersion: 2.2
Path: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk
PlatformVersion: 2.2
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform
ProductBuildVersion: 13V143
ProductCopyright: 1983-2016 Apple Inc.
ProductName: Watch OS
ProductVersion: 2.2
WatchSimulator2.2.sdk - Simulator - watchOS 2.2 (watchsimulator2.2)
SDKVersion: 2.2
Path: /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator2.2.sdk
PlatformVersion: 2.2
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform
ProductBuildVersion: 13V143
ProductCopyright: 1983-2016 Apple Inc.
ProductName: Watch OS
ProductVersion: 2.2
Xcode 7.3.1
Build version 7D1014

Given that the osx_image: xcode8 seems correctly specified in the .travis.yml to me, I don't know why it picks an Xcode 7 image…

@AliSoftware
Copy link
Owner

AliSoftware commented Nov 9, 2016

Previous build passed! The error was in fact due to .travis.yml did contain osx_image: xcode8.0 instead of osx_image: xcode8, and since a VM with this name doesn't exist in Travis, instead of Travis warning us about it it silently used the default VM, which uses Xcode 7.3.1. That all makes sense now.

It seems you already have fixed that (probably amended and force-pushed the fix since I don't s it anymore in the commit list of this PR 👍 ) and now use xcode8 image, so SWIFT_VERSION: 3.0 is probably not needed in the .travis.yml anymore.
And since we no longer have to test against multiple Xcode versions and multiple VM images, we can even get rid of those entries in the matrix/include: entry of .travis.yml since it's already listed as a top entry 👍


So the .travis.yml can probably just look like this instead:

language: swift

before_install:
  - which swiftlint || brew install swiftlint
  - gem install cocoapods

osx_image: xcode8

matrix:
    include:
        - env: 
            - TASK=lintpod
        - env: 
            - TASK=carthage

script:
  - rake ci:$TASK

@AliSoftware
Copy link
Owner

AliSoftware commented Nov 9, 2016

Seems we're good now 🎉

Given that this Swift 3 migration also means having an API compliant with Swift 3 guidelines, and that we can't mess this up for 3.0.0 (We don't want to forget to Swiftify one API in 3.0.0 and have to bump to 4.0.0 just to fix that and make a breaking change), I think it's important to double-check them. At first glance they seem OK, but we don't want to miss one.

So I think that would be cool if multiple persons could just take some time to double-check what the public APIs look like after that change and all approve if they're compliant with the expected Swift 3 guidelines (or suggest changes) before we really merge that PR — as I don't want to mess that up, and aim at a clean Swift 3 API 😉
(ping @Grubas7 @phatblat )

Once 2 or 3 people give their 👍 about how the new API look like, we'll be ready to merge… and ship!
(I'll probably review them myself too during this week-end)

Copy link
Owner

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Don't forget to credit yourself (and others) in the CHANGELOG 😉

@@ -1,5 +1,16 @@
# CHANGELOG

## UNRELEASED

* Converted library and Demo project to Swift 3.
Copy link
Owner

Choose a reason for hiding this comment

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

Hey @ceyhuno, you forgot to credit yourself! (I think the other people who worked on the Swift 3 migration like @phatblat on #30 deserve credits there too, btw)

Could you add there the links to your profiles and to the PRs related to that migration? (you can use other entries in the CHANGELOG as example)

(elementKind: String, indexPath: NSIndexPath, viewType: T.Type = T.self) -> T {
let view = self.dequeueReusableSupplementaryViewOfKind(elementKind, withReuseIdentifier: viewType.reuseIdentifier, forIndexPath: indexPath)
final func dequeueReusableSupplementaryView<T: UICollectionReusableView>
(ofKind elementKind: String, indexPath: IndexPath, viewType: T.Type = T.self) -> T where T: Reusable {
Copy link
Owner

Choose a reason for hiding this comment

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

I think the new API for this should be dequeueReusableSupplementaryView(ofKind:for:viewType:) instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I agree 👍

@@ -8,8 +8,7 @@ A Swift mixin to use `UITableViewCells`, `UICollectionViewCells` and `UIViewCont

[![Platform](http://cocoapod-badges.herokuapp.com/p/Reusable/badge.png)](http://cocoadocs.org/docsets/Reusable)
[![Version](http://cocoapod-badges.herokuapp.com/v/Reusable/badge.png)](http://cocoadocs.org/docsets/Reusable)
![Swift 2.2](https://img.shields.io/badge/Swift-2.2-orange.svg)
![Swift 2.3](https://img.shields.io/badge/Swift-2.3-orange.svg)
[![Language](https://img.shields.io/badge/Swift-3.0-orange.svg)](https://swift.org)
Copy link
Owner

Choose a reason for hiding this comment

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

For accessibility reasons (= because people with visual deficiency use the alt description of an image to help them understand what the image is) I think it would be better for non-automatic badges like this one (unlike the one whose image is auto-generated) to have a descriptive text, like Language: Swift 3.0 instead of just "Language"?

…` to `dequeueReusableSupplementaryView(ofKind:for:viewType:)`

Updated alt description of language badge in README
@AliSoftware
Copy link
Owner

One thing that could be a good idea to add in the README is that "if you still need Swift 2.x support, you should use Reusable 2.5.1" somewhere

Copy link
Owner

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

👍

@AliSoftware
Copy link
Owner

AliSoftware commented Nov 13, 2016

Ping @Grubas7 @phatblat if you could just take 1mn to double check with us that all the APIs after these changes are indeed all perfectly compliant with Swift-3.0? It seems ok to me but extra pair of eyes (to avoid having to do a major bump in case we missed one) welcome.

@Grubas7
Copy link
Collaborator

Grubas7 commented Nov 13, 2016

@AliSoftware I see that most of my remarks from #30 (useless completion blocks, descriptive var names) are not applied to this PR. Looks like most of fileprivate changes are pointless (I know it's migrator work, but most of properties and methods should stay private).

Please take a look at #30 remarks, and then I'll review this PR one more time :)

Copy link
Owner

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

@Grubas7 's remarks on #30 to be applied to this #31 :

(First two are not related to the Swift 3 migration per se but would be a good occasion to cleanup the core indeed. 3rd is more related to the migration even if it's only affecting the sample project.)

@ceyhun
Copy link
Collaborator Author

ceyhun commented Nov 13, 2016

I think all of these changes can be made in future pull requests and/or commits without the need to change the MAJOR/MINOR version of the framework. We shouldn't do code cleanup or non-framework-related changes during a migration and make this pull request bigger than it's supposed to be.

@AliSoftware
Copy link
Owner

@ceyhuno I do agree with you… except maybe for the last point (fileprivate->private) which is a change made by this PR while it shouldn't have been necessary?

@ceyhun
Copy link
Collaborator Author

ceyhun commented Nov 13, 2016

👍 I'll revert private -> fileprivate changes than

if let view = view as? UIView {
view.translatesAutoresizingMaskIntoConstraints = false
owner.addSubview(view)
layoutAttributes.forEach { attribute in
owner.addConstraint(NSLayoutConstraint(item: view,
attribute: attribute,
relatedBy: .Equal,
relatedBy: .equal,
toItem: owner,
attribute: attribute,
multiplier: 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

multiplier is CGFloat so I would do 1.0 instead of 1, but it's not crucial ;)

Copy link
Owner

Choose a reason for hiding this comment

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

Good point, but not related to the migration, so probably should fix in a separate PR 😉

@@ -18,8 +18,8 @@ public extension UICollectionView {

- seealso: `registerNib(_:,forCellWithReuseIdentifier:)`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Docs for this and UITableView extension still refers to Swift 2.x

-> register(_:forCellReuseIdentifier:)

@Grubas7
Copy link
Collaborator

Grubas7 commented Nov 13, 2016

I checked Reusable source code (except sample app), and looks good :)

@AliSoftware
Copy link
Owner

Cool! I'd then say once the last doc typo is fixed it'll be time to merge then! 🎉

@AliSoftware
Copy link
Owner

3 hours later and the Travis builds still haven't started 😭

@AliSoftware
Copy link
Owner

Ok, Travis seems to be sulking us and don't want to start the builds.

Given that Reusable still has no Unit Tests (which is a shame, I know, see #7) and that the Travis builds only lint the pod and test a carthage build — which I both tested locally using rake ci:lintpod and rake ci:carthage on my own Mac — I think I'm gonna merge it manually anyway (just need to add a patch commit for the .travis.yml beforehand)

@AliSoftware AliSoftware merged commit 1d99bea into AliSoftware:master Nov 14, 2016
AliSoftware added a commit that referenced this pull request Nov 14, 2016
@AliSoftware
Copy link
Owner

@ceyhuno @phatblat @Grubas7 Reusable 3.0 has been officially released! 🎉

Thanks a lot to all of you for contributing to this big migration! 🍾
Don't hesitate to RT: https://twitter.com/aligatr/status/798217195595636737

(@ceyhuno I hope I used the right mention, I'm not sure about your Twitter handle)

@ceyhun
Copy link
Collaborator Author

ceyhun commented Nov 14, 2016

(@AliSoftware that's correct. It's me 👍)

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.

5 participants