Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Xcode plugin to Xcode extension

Khoa Pham
November 02, 2018

From Xcode plugin to Xcode extension

My talk at Mobile Era conference 2018 in Oslo

Khoa Pham

November 02, 2018
Tweet

More Decks by Khoa Pham

Other Decks in Technology

Transcript

  1. From Xcode plugin to Xcode extension

  2. About Khoa Pham github.com/onmyway133 github.com/hyperoslo medium.com/@onmyway133

  3. It takes 2 iOS developers to start complaining about Xcode

  4. XcodeWay

  5. Xcode plugin

  6. Alcatraz

  7. XVim

  8. SCXcodeMiniMap

  9. FuzzyAutocompletePlugin

  10. ColorSense-for-Xcode

  11. Techniques • Private frameworks • Objective C Runtime • LLDB

    • Swizzling
  12. class-dump • IDEKit • DVTKit • Xcode.app/Contents/SharedFrameworks/DVTKit.framework

  13. None
  14. DVTBezelAlertPanel class func swizzleMethods() { guard let originalClass = NSClassFromString("DVTBezelAlertPanel")

    as? NSObject.Type else { return } do { try originalClass.jr_swizzleMethod("initWithIcon:message:parentWindow:duration:", withMethod: "xmas_initWithIcon:message:parentWindow:duration:") } catch { Swift.print("Swizzling failed") } }
  15. None
  16. DVTSourceTextView func listenNotification() { NSNotificationCenter.defaultCenter().addObserver( self, selector: #selector(handleSelectionChange(_:)), name: NSTextViewDidChangeSelectionNotification,

    object: nil) } func handleSelectionChange(note: NSNotification) { guard let DVTSourceTextView = NSClassFromString("DVTSourceTextView") as? NSObject.Type, object = note.object where object.isKindOfClass(DVTSourceTextView.self), let textView = object as? NSTextView else { return } self.textView = textView }
  17. IDEWorkspaceWindowController self.IDEWorkspaceWindowControllerClass = objc_getClass("IDEWorkspaceWindowController"); NSArray *workspaceWindowControllers = [self.IDEWorkspaceWindowControllerClass valueForKey:@"workspaceWindowControllers"];

  18. XcodeGhost

  19. Xcode Source Editor extension • Modify contents • Modify current

    text selection • Seperated process protocol XCSourceEditorCommand { func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void) }
  20. App Extension • Share • Photo Editing • Today •

    Finder Sync • Custom Keyboard • File Provider • Document Provider
  21. Resign codesign

  22. XcodeColorSense extension ? • No Notification • No UI modification

  23. Color literal ! #colorLiteral

  24. XcodeWay extension ? • No NSTask • No NSWorkspace •

    No swizzling
  25. AppleScript !

  26. None
  27. • NSUserAppleScriptTask • NSAppleEventDescriptor • ProcessSerialNumber on myOpenFolder(myPath) tell application

    "Finder" activate open myPath as POSIX file end tell end myOpenFolder
  28. App Sandbox

  29. Scripts Directory NSApplicationScriptsDirectory

  30. macOS Mojave • WWDC 2018 - Your Apps and the

    Future of macOS Security • NSAppleEventsUsageDescription
  31. • https://github.com/onmyway133/XcodeWay • https://github.com/onmyway133/XcodeColorSense2 • https://github.com/theswiftdev/awesome-xcode-extensions

  32. Thanks May your code continue to compile