25

I updated to Xcode 8 beta 5, and now get the following error on a class that inherits from UIView:

Method does not override any method from its superclass

override public func intrinsicContentSize() -> CGSize
{
   ...
}

Is there a workaround?

2 Answers 2

58

Please check the latest reference. (You can easily find it just putting the word "intrinsicContentSize" in the searchbar of Apple's developer site.)

Declaration

var intrinsicContentSize: CGSize { get }

intrinsicContentSize has become a computed property, so you need to override it in this way:

override open var intrinsicContentSize: CGSize {
    get {
        //...
        return someCGSize
    }
}

Or simply:

override open var intrinsicContentSize: CGSize {
    //...
    return someCGSize
}
5
  • Is there any resource that lists the recent changes?
    – GoldenJoe
    Aug 11, 2016 at 5:45
  • 1
    @GoldenJoe, there is iOS 9.3 to iOS 10.0 API Differences. But it's a huge list and I'd rather use seachbar than check the Diffs.
    – OOPer
    Aug 11, 2016 at 7:58
  • Thanks, did you just search for "iOS Diffs" or something to find this? It is huge, but it's nice to browse the things you use frequently.
    – GoldenJoe
    Aug 11, 2016 at 17:25
  • 1
    @GoldenJoe, Diffs can be found in iOS Developer Library(current) or [Guides and Sample Code](future version), with Resource Type "Release Notes". Please check.
    – OOPer
    Aug 11, 2016 at 18:25
  • Read the source file of UIView class you will see how it has been changed. Nov 30, 2016 at 17:22
7

While transitioning from one version of Xcode to another, there is different ways to find out why your code does not compile anymore. Here are a few resources for intrinsicContentSize:

  1. You can search for intrinsicContentSize from developer.apple.com.
  2. You can search for intrinsicContentSize straight from Apple Developer API Reference page for UIView.
  3. You can open the iOS 10.0 API Diffs for UIKit page and search for instances of intrinsicContentSize with your browser's find menu (shortcut: cmd + F).
  4. You can search for intrinsicContentSize from Xcode's Documentation and API Reference (path: Help > Documentation and API Reference, shortcut: shift + cmd + 0).
  5. You can also right-click on any UIView initializer in your Xcode code (for example, UIView()), select Jump to Definition and then perform a search for intrinsicContentSize.

These searches will show you that intrinsicContentSize, with Swift 3 and iOS 10, is no more a method but a computed property of UIView that has the following declaration:

var intrinsicContentSize: CGSize { get }


As a consequence, you will have to replace your intrinsicContentSize() method implementation with the following code snippet:

override public var intrinsicContentSize: CGSize {
    return ...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.