1

I have an issue archiving a build under Xcode 10.1 because of protocol conformance

protocol ResetAbleTransform where Self: UIView  {
    func resetTransform()
}

class CardView, ResetAbleTransform {

   func resetTransform()
}

All good except when I do something like this

let card = CardView()
card.isHidden = true  -------> Here Xcode 10.2 builds, 10.1 complains

error: enter image description here

Both build on Swift 4.2. Did they add another version of Swift 4.2 in Xcode 9.2?

Anyone have an idea why? Or better yet, any way I can archive this with 10.1 or do I have to wait for 10.2 to be out of beta?

EDIT: enter image description here

Ace Green
  • 381
  • 5
  • 29
  • 1
    See [Swift protocol with "where Self" clause](https://stackoverflow.com/questions/50913244/swift-protocol-with-where-self-clause). Are you sure you aren't using Swift 5 with Xcode 10.2 beta? – Dávid Pásztor Feb 14 '19 at 14:29
  • I checked out that proposal before and yea I checked I'm still compiling with Swift 4.2 on both – Ace Green Feb 14 '19 at 14:34
  • Apparently its a side effect of that proposal and shouldn't have been possible with 4.2 – Ace Green Feb 14 '19 at 14:36
  • If you’re building with Xcode 10.2, then you’re using the Swift 5 compiler, which is what allows your code to compile. Note that the Swift language build setting only affects the compatibility mode the compiler runs in. Compare https://stackoverflow.com/a/51283128/2976878 – Hamish Feb 14 '19 at 14:43
  • "Note that the Swift language build setting only affects the compatibility mode the compiler runs in" what does that mean specifically? Whats the point of setting the Swift Language to 4.2, if it complies with 5? – Ace Green Feb 14 '19 at 14:45
  • @AceGreen Setting the “Swift Language Version” to 4.2 just tells the Swift 5 compiler to try and mimic the behaviour of the Swift 4.2 compiler in certain places in order to minimise source breakage (for example if a language feature was removed, you’d still be able to use it). This doesn’t affect language features added in Swift 5 however, such as superclass constrained protocols. – Hamish Feb 14 '19 at 14:47
  • So to conclude, no way to make this compile under 10.1? – Ace Green Feb 14 '19 at 14:55
  • @AceGreen No, not unless you [download and use a Swift 5 toolchain](https://swift.org/download/#snapshots) with it (though I’m not sure if that can be used for archival and then presumably submission to the App Store – I’d assume not). Also you may have to use an older Swift 5 snapshot as IIRC the most recent one would have been updated to the latest SDKs and therefore require Xcode 10.2. – Hamish Feb 14 '19 at 15:00
  • On a side not, I was surprised that I was able archive and upload that build with 10.2, and Testflight it with iOS 12.1.x but couldn't submit it for AppStore review. It seems Apple now allows uploads on beta Xcode but not submission – Ace Green Feb 14 '19 at 15:07

0 Answers0