title: Is there an alternative to initialize() in macOS now that Swift has deprecated it?
body: <p>Objective-C declares a class function, initialize(), that is run once for each class, before it is used. It is often used as an entry point for exchanging method implementations (swizzling), among other things. Its use was deprecated in Swift 3.1.</p>
  
  <p>This is what I used to do:</p>
  
  <pre><code>extension NSView {
      public override class func initialize() {
          // This is called on class init and before `applicationDidFinishLaunching`
      }
  }
  </code></pre>
  
  <p>How can I achieve the same thing without <code>initialize</code>?</p>
  
  <p><strong>I need it for a framework, so requiring calling something in the AppDelegate is a no-go. I need it called before <code>applicationDidFinishLaunching</code>.</strong></p>
  
  <p>I really like <a href="https://stackoverflow.com/a/42824542/64949">this</a> solution. It's exactly what I'm looking for, but it's for iOS. I need it for macOS. Could someone suggest a macOS version of that?</p>
  
  <p>To be specific, I need the equivalent of this, but for macOS:</p>
  
  <pre><code>extension UIApplication {
      private static let runOnce: Void = {
          // This is called before `applicationDidFinishLaunching`
      }()
  
      override open var next: UIResponder? {
          UIApplication.runOnce
          return super.next
      }
  }
  </code></pre>
  
  <p>I've tried overriding various properties on <code>NSApplication</code> with no success.</p>
  
  <p><strong>The solution needs to be in pure Swift. No Objective-C.</strong></p>