robb / Cartography

A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
Other
7.35k stars 525 forks source link

Swift 3.0 Xcode 8.0 errors #240

Closed tryadelion closed 7 years ago

tryadelion commented 7 years ago

When updating to xcode 8.0, i made a clean pod install of Cartography, but i'm getting hundreds of Type 'NSLayoutRelation' has no member 'lessThanOrEqual'

And similar errors.

Any idea on how to fix it?

tryadelion commented 7 years ago

Current cartography pod version : Installing Cartography (1.0.0)

orta commented 7 years ago

I'm afraid I'm unsure, we're running all the unit tests in Xcode 8, and with Swift 3. Could you be using a version of CP that doesn't support Xcode 8? E.g. are you not using the current release candidate?

tryadelion commented 7 years ago

CP? (cartography?) , anyway, to ensure that all pods upgrade nicely, i uninstalled them all, removed all files and folders ,and installed them back, and then i got those errors. there are 50 of them that i can't fix, and there are others that by removing an annotation on CP's source got fixed.

this is my pod result log : Installing Alamofire (3.5.0) Installing Alamofire-SwiftyJSON (0.1.1) Installing Cartography (1.0.0) Installing ImagePicker (1.4.1) Installing MVCarouselCollectionView (1.0.9) Installing SDWebImage (3.8.2) Installing SwiftEventBus (2.1.0) Installing SwiftSpinner (1.0.2) Installing SwiftyJSON (2.4.0) Generating Pods project Integrating client project Sending stats Pod installation complete! There are 9 dependencies from the Podfile and 9 total pods installed.

vfn commented 7 years ago

@tryadelion CP = CocoaPods

I'm not sure you are using Swift 3, because Alamofire 3.5.0 is Swift 2.3. Please check all your dependencies are compatible with Swift 3.0, then try to build your project again.

Also, your version of SwiftJSON is Swift 2.3 compatible https://github.com/SwiftyJSON/SwiftyJSON/releases

...And Alamofire-SwiftJSON does not support Xcode 8 or Swift 3.0: https://github.com/SwiftyJSON/Alamofire-SwiftyJSON

tryadelion commented 7 years ago

My code is converted to Swift 3.0, the dependencies should automatically upgrade to the latest version possible afaik.My Alamofire and SwiftyJson versions shouldn't affect cartography build, right?

Sadly all these Xcode and swift changes are destabilizing and unnecessary, i don't see any positive change.

vfn commented 7 years ago

@tryadelion It can be Xcode getting confused about what version of Swift to use. You cannot have a mix of Swift 2.3 & 3 in the same project.

You should first make sure all your dependencies (Managed by CocoaPods) are set to a version that supports Swift 3, then you perform the migration on your code.

One of the reasons that Alamofire might not be updating is that you project has a minimum target of iOS 8, and Alamofire 4.0.0 that support Swift 3, only supports iOS 9 & 10.

tryadelion commented 7 years ago

I'm checking it up right now.

vfn commented 7 years ago

@tryadelion I might be wrong, but I believe you can get rid of SwiftJSON and Alamofire-SwiftJSON, if you are using SwiftJSON only for JSON object from requests' responses. If that's the case, Alamofire has a response serializer that outputs [AnyHashable: Any] dictionary, that's equivalent to the other 2 libs together.

If you remove these 2 dependencies and can drop support to iOS 8, you should have no problems on migrating to Swift 3

tryadelion commented 7 years ago

will do that. it's still weird because Xcode tells me that my code is already swift 3.0, and the migration was sucessful. i'm 90% lost, but will do as you say. nothing to loose.

vfn commented 7 years ago

Depending on how big you code base is, prepare for hours of painful manual migration. Xcode will do only half of the job for you. I spent the last 2 days migrating one of my project and it was not fun.

I can assure you that Cartography 1.0.0 is working with Xcode 8 & Swift 3.0

tryadelion commented 7 years ago

Okay, thank you very much for your comprehension and help. my codebase is eiffel tower sized.

vfn commented 7 years ago

@tryadelion no problems!

I just checked another dependency of your project and https://github.com/bizz84/MVCarouselCollectionView is really outdated and does not support Swift 3.0

Until you can get these dependencies updated I guess you'll need to keep using Xcode 7 & Swift 2.2 ¯(ツ)

orta commented 7 years ago

👍 great work @vfn