Developers are constantly refining their workflow in order to master their craft. There is a plethora of tools available that can help bootstrap a project, increase efficiency, or simply make developers happy. Let’s explore the newly introduced Xcode Source Editor Extensions; an Application Extension that gives developers the power to create custom actions in Xcode’s Editor menu.
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
1. Enhancing Your Workflow with Xcode Source Editor Extensions
By: Jesse Black
Software Engineer
stable|kernel
jesse.black@stablekernel.com
2. @stablekernel
Hi, I’m Jesse Black.
• Programming for over eight years
• Created a Mac App for my family business
• Worked for 3 years with Gramercy Consultants developing iOS and Android apps
• Working for stable|kernel for the past 3 years developing iOS apps, Android apps
and their supporting APIs
3. We’re stable|kernel.
stable|kernel is an Atlanta-based mobile development company
to craft smartly-designed mobile applications that connect brands
directly with their users.
4. Enhancing Your Workflow with Xcode Source Editor Extensions
@stablekernel
Overview
Mac App Extensions
Xcode Source Editor Extensions
Demo: Create Source Editor Extension and debugging it
XC Classes
Example: JSON formatter
Demo: JSON formatter in action
5. Mac App Extensions
@stablekernel
• Mac App Extensions
• Affect the user experience of other apps
• Need to be lightweight and run fast
• Require user interaction in order to be run
• Distribute via host app
6. Why use Xcode Source Editor Extensions
@stablekernel
• Less context switching
• It is too fun to customize your workflow
7. Xcode Source Editor Extensions
@stablekernel
• Differences with general Mac App Extensions
• Extensions are installed by just putting the host application in your
applications folder
• Only works with one type of target application, which is Xcode
• Doesn’t have UI
8. Xcode Source Editor Extensions
@stablekernel
• Allows you to add custom commands under Xcode’s Editor menu
• Commands can manipulate text and text selections
• Users can put bind keyboard shortcuts to invoke your commands
9. Limitations to Xcode Source Editor Extensions
@stablekernel
• Can only start with user interaction
• Lack of ability to integrate into the build process and archive process. It
is for modifying source code while it is being edited.
10. Expectations of Xcode Source Editor Extensions
@stablekernel
• Fast start up
• Fast execution
• Security and Stability
12. Defining Commands
@stablekernel
• Command Identifier
• Class Name
• Command Name
Commands can be defined in the Extension’s plist or by supplying a
dictionary at runtime. Commands provided at runtime override commands
defined in the plist.
15. XC Source Editor Command
@stablekernel
• Modify text, text selection
• Exit early with an error message that is displayed in Xcode
16. XC Source Editor Command Invocation
@stablekernel
• Encapsulates all details needed to fulfill the user’s request
• contentUTI
• usesTabsForIndentation
• indentationWidth
• tabWidth
• buffer
17. XC Source Text Buffer
@stablekernel
• completeBuffer
• lines
• selections
• defined in terms of lines and columns
18. Example: JSON formatter
@stablekernel
• Define minify and prettify commands
• Implement XCSourceEditorCommand’s perform method
• Validate requirements for command
• Get first text selection
• Return error if selected text isn’t valid JSON
• Use JSONSerialization class to format text
• Replace selected text
26. Questions?
Business Inquiries:
Sarah Woodward
Director of Business Development
sarah.woodward@stablekernel.com
Jesse Black
Software Engineer
jesse.black@stablekernel.com
blog.stablekernel.com
@JesseBlack82
http://www.slideshare.net/stablekernel
https://github.com/JesseBlack82/HelloExtensions