Search code examples
iosswiftobjective-cxcodetvos

macOS, iOS & tvOS documentation missing imports?


I'm looking into iOS/tvOS docs for GCKeyboard & GCMouse types.

However Apple docs seem to be missing basic info such as what I import to use a type. For example C# docs always show what libraries are needed on MS websites for types. So do Googles Android docs. I'm not seeing this on Apples docs here: https://developer.apple.com/documentation/gamecontroller/gckeyboard

  • Is there an easy way in ObjC or Swift to check where a type is from?
  • Does Apple provide any way to lookup what source file I should import for a type? How do people normally go about these lacking docs with xCode dev work?

Solution

  • Apple do indicate on its doc on which framework the class/object that the document referred to is relevant. See my picture for details. Its has a documentation hierarchy from the framework down to the objects and apis within it.

    enter image description here

    Specifically for GameController framework you’d use the following import

    import GameController
    

    A nice anecdote:

    In older class and objects it is also customary to add the initials of the framework/library as a prefix for the name. In this case GC(i.e game contoller)Keyboard. Or UI(UIKit)ViewController. With newer libraries like SwiftUI and Combine they have stopped using the prefix. The prefix was used due to legacy Objetive-C limitation for namespace.