Material: Swift 3.0 compliant

Created on 20 Jun 2016  ·  34Comments  ·  Source: CosmicMind/Material

Make Material Swift 3.0 compliant. Maybe as a separate branch?

question

Most helpful comment

Thanks @danieldahan for all your work! Can't wait for the Swift 3 branch :)

All 34 comments

Yes, it will be a separate branch. I am doing 2.3 and then 3. Let's leave this up for now. I would aim to have ti done for the end of the week.

Would really appreciate an update for Swift 3. Eagerly waiting :p

Soon enough :) Testing iCloud support in Graph, and then I am back on to a bunch of Material updates, including this.

I aim to have iCloud support done in the next day.

Thanks @danieldahan for all your work! Can't wait for the Swift 3 branch :)

just posting so that github notifies me when you get time to do this work. Thanks in advance.

Finally finished iCloud yesterday... wow that was some fun work. So I am back on making Material amazing! :)

So this is in the development branch. I had made some updates along the way. Please consult the wiki. I will be making many more updates to get ready for Material 2. So please, if you have any questions, feel free to ask on Gitter.

@danieldahan you closed this but are you sure it's Swift 3.0 compliant? You are talking about Swift 2.3 on the 2.0.0 development branch.

Have you tried the development branch? I had updated every issue it presented to me, minus a couple of warnings that I will fix shortly. Let me know if you find any issues with it.

I didn't try the 2.3 branch, since I thought you would come with a separate 3.0 branch. There are language changes, and to prevent an overload of warnings, you might want to get rid of that. So could you try to build a 3.0 version without warnings. Take the beta 3 version, since this had more library code changes, as well as language changes (e.g. 'where' is replaced with ',' in conditions).

Well Material is a large project and I cannot maintain 2.3, 3.0, and dev, and current. I have to update to the latest of what's available and go from there. So currently, I am supporting all the way up to 3.0, well anything that Xcode betas complain about really.

I just tried with swift 3.
First build gave me this warning:

`“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.``

I'm using cocoapods, so I tried setting 'Use Legacy Swift Language Version: NO' in the pods project. That gives me a gazillion errors.
If I switch to 'Use Legacy Swift Language Version: YES', then I only get about 6 errors which relate to code changes in swift 3.

I'd suggest you need to create a separate 3.0 branch with a view to dropping 2.3 support fairly quickly.
The changes seem fairly minor. Things like:

bezierPath.CGPath -> bezierPath.cgPath

also, there seem to be duplicates in some of the extension definitions. I don't know if that is allowed in 2.3, but 3.0 complains

e.g. public func resize(toWidth w: CGFloat) -> UIImage? {exists in Material+UIImage.swift and also Material+UIImage+Resize.swift

@ConfusedVorlon Good to know. I will take a look now.

@danieldahan something odd here; I just tried downloading the material project, and it seems to build fine.

This is what I'm using for my podfile:

pod 'Material', :git => 'https://github.com/CosmicMind/Material.git', :branch => 'development'

@danieldahan I have pinned down at least part of the issue. There are files in the cocoapod which are not included in the Material framework project.

e.g. AnimateKeyframe.swift

this might need nothing more than cleaning out some obsolete files...

Great! I have been updating it. I noticed the Beta Xcode doesn't clean files nicely. I am double checking on the latest Xcode beta 3 once its done downloading.

I got it to build by removing

-AnimateKeyframe
-Material+UIImage+Resize.swift
-Material+UIImage+TintColor.swift

I'm guessing at least the last two of those were refactored into Material+UIImage

I suspect this isn't an issue of xcode cleaning files, but rather the pod trying to compile every file in the folder where the material project only compiles the files which are included in the project.

Yes, those should all have been removed. And the AnimateKeyframe file is now KeyframeAnimation. I am making an update once I verify on Xcode beta 3, which I am in the process of doing. Thank you! I will update you in a moment.

I'm confused, and still having a hard time believing that a 2.3 Material will work well in my Xcode 8 beta 3 project.
I use Xcode beta (1, 2, and now 3) since a month now. I cannot use carthage or cocoa pods in my project (not supported according to the release notes). So I made a Framework project with Material, and patched it to work with 3.0. So I'm confused when you say you compiled it with cocoa pods. Are you sure it uses the 3.0 compiler? Anyway, apart from lots of library naming changes, there are language changes as well. You cannot apply the 3.0 language changes if it also should work for work 2.3.
Bottomline is like to know if I can take your 2.3 development branch to incorporate in my 3.0 project without having to spend lots and lots of time to get it building properly. Sorry to be nuisance, and I can wait some longer time, though I like the way you're progressing continually.

@ariedoelman So it was my mistake with the 2.3 and 3.0. When I started correcting the issues with Swift, I was updating everything. I actually didn't aim to do 2.3 or 3.0. So this means that I actually updated to 3.0, as anything 2.3 would have been covered. I am downloading the latest beta 3 and installing it to make further changes.

Ideally I should have branched off and made separate branches for each version. Unfortunately, it didn't work out that way, and Material is a lot to maintain when spread across many branches like that.

So I am sticking with a single development branch that will have everything up to date, including Swift 3.0. That said, I am also updating Material to 2.0 as I am reworking issues, and updating the API, as well as, adding new features.

Give me a moment to verify everything in Xcode 8 beta 3.

Thanks @danieldahan. You're doing a great job.
I like the way you also renew names of classes and functions to a more concise and to-the-point name. That's a good process, so that names speak for themselves. While I am on that subject, might I suggest you use the attribute '@available' in combination with 'renamed: ' for this as well. E.g. '@available(*, unavailable, renamed: "MyRenamedProtocol")'.
The reason I'm asking is because I use your classes quite often, and find myself in the position that the compiler complains about unknown class- or variable names. I then have to delve in your source code to get an idea what happened.

@ariedoelman Thank you! Yes, I plan to implement better practices going forward. Keep the suggestions coming, as I am learning quite a bit when it comes to maintaining open source projects.

@ariedoelman Should all be fine now for Swift 3.0 on the development branch.

Congratz @danieldahan! It's running smoothly on Xcode 8 beta 3 and Swift 3.0 under the development branch. Thanks!

My pleasure :)

@danieldahan I think there may still be a couple of files in the pod that are still on swift 2.3

  1. install pod
  2. build (everything is splendid)
  3. close workspace
  4. reopen workspace

Xcode now 'discovers' some files that are on swift 2.3 and offers to convert them to 3.0
If you run through the wizard, it will show you what it wants to change

thanks.

I don't get the same notices. What I do notice, is that on all my projects I needed to go through the wizard, and then it would do the cleanup needed even if the project was already in Swift 3. Also, make sure you are running the latest.

@ConfusedVorlon I had the same issues but I don't think it's related to this specific pod. It seems that it's fixed since I've updated to Xcode 8 Beta 3. Are you on this version too or still on Beta 2?

slow response here - I'm on beta 3. I still see the offer to upgrade whenever I open my project!

@ConfusedVorlon I believe you have to run it at least once. Regardless if you download the latest Material. I had to do it once, and it didn't make any changes except for some project updates to my running project. Have you ran it once before?

Uncomment this line to define a global platform for your project

platform :ios, '9.0'

target ‘MyProject' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for MyProject
pod 'Material', :git => 'https://github.com/CosmicMind/Material.git', :branch => 'development'
end

@danieldahan I think you need to re-open this issue: Xcode 8 Beta 6 was released yesterday with some new issues to fix.

Feel free to ask if you need any help with a PR? I can submit one.

Hey @Tulleb its already in progress by @danieldahan
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sovata8 picture sovata8  ·  15Comments

craigpearce5 picture craigpearce5  ·  14Comments

timoschwarzer picture timoschwarzer  ·  16Comments

ijameelkhan picture ijameelkhan  ·  23Comments

tato469 picture tato469  ·  17Comments