0

I was testing out Xcode 10.2 beta 10P82s. I created a new branch on my current app and when I tried to convert to Swift 5 it asked me to make sure I could build on all targets before I converted. This was strange because there were NO errors when I cleaned and build. But the errors showed up if I went to each file and scrolled down.

One such error is on my extensions.

For example I have the following extension

import Foundation
import UIKit

extension UIView {
    public func createRoundedCorners() {
        layer.cornerRadius = 7
        clipsToBounds = true
    }
}

In various ViewControllers I use this. For example I have a albumArtImageView: UIImageView and in my code I call albumArtImageView.createRoundedCorners().

I get an error:

Value of type 'UIImageView?' has no member 'createRoundedCorners'

In Xcode 10.1 and before this worked.

What has changed? What do I need to do so this works?

RubberDucky4444
  • 2,330
  • 5
  • 38
  • 70
  • Just a wild guess. Does it work if you change your extension to be UIImageView instead of UIView? – Charlie Fish Jan 26 '19 at 18:10
  • @rmaddy Value of type 'UIImageView?' has no member 'createRoundedCorners' – RubberDucky4444 Jan 26 '19 at 18:18
  • @CharlieFish same result – RubberDucky4444 Jan 26 '19 at 18:19
  • 2
    Your error doesn’t match the code you posted. The error is about an optional image view but the code you posted doesn’t show an optional. – rmaddy Jan 26 '19 at 18:28
  • @rmaddy I created another UIImageView just for this. I made an optional UIImageView named foo, unwrapped It and tried to run the extension on it. Same result except the optional "?" is not in the error. I am also not getting autocomplete. I realize autocomplete is not a good indicator but I do not think the issue is with optional aspect I think It has to do with the extensions – RubberDucky4444 Jan 26 '19 at 18:52
  • Sounds to me like a good case for filing a radar. – Charlie Fish Jan 26 '19 at 18:56
  • “Value of type 'UIImageView?' has no member ‘createRoundedCorners’” ... This isn’t telling you it can’t find the extension. It’s telling you that you haven’t unwrapped your optional `UIImageView?`. If you’re successfully unwrapping it, you would _not_ receive the same error (if nothing else, the `?` wouldn’t be there). – Rob Jan 26 '19 at 21:29
  • @Rob I can do more when I’m at my computer next. But why would the same exact code work fine in the current stable release version of Xcode, – RubberDucky4444 Jan 26 '19 at 21:54
  • 1
    No worries. It’s hard to say without reproducible example of the problem. But, like I said, it worked on Xcode 10.2 Beta build 10P82s for me, so I suspect there’s something else going on. I’d also suggest deleting the derived data folder and restarting Xcode (maybe even the computer), so make sure there isn’t something lingering about... – Rob Jan 26 '19 at 21:57
  • @Rob I created a new project in Version 10.2 beta 2 (10P91b) and I created a `UIImageView` a few ways including how I have it in my actual project. I built and ran and absolutely no issues which leads me to believe it might be a bug? If you want I can link to the GitHub of that sample code or the real code – RubberDucky4444 Feb 06 '19 at 18:50
  • Not necessary for me. If it’s now working, I’d suggest you chalk it up to some beta 1 issue (even though I wasn’t able to reproduce the problem in that configuration) and declare success. I’d only worry about it if you can still reproduce the problem in the most recent release. – Rob Feb 06 '19 at 18:55
  • @Rob well it’s only working on the clean simple sample project. I am still unable to get it to work on my actual project and therefore cannot update my code to latest swift – RubberDucky4444 Feb 06 '19 at 18:56
  • I’d suggest creating a [MCVE](https://stackoverflow.com/help/mcve). One way to do this is to copy your project and rip out everything unrelated to this particular problem, until you’ve distilled it down to a reproducible example with just the bare essentials. Or if you can’t reproduce the example in your sample project, you can give up on trying to reproduce it and just recreate your project from scratch and see if that manifests the problem... – Rob Feb 06 '19 at 19:04
  • I’m happy to review any reproducible example of the problem, but I’d rather not go through all of your code. It would be nice if you could prune it back to the bare essentials. – Rob Feb 06 '19 at 19:05

0 Answers0