Download
Let's Swift!
xTextHandler
has been rewritten in Swift
. The Objective-C
version can be found in: https://github.com/cyanzhong/xTextHandler-objc
xTextHandler
Xcode Source Editor Extension Tools (Xcode 8 Plugins)
What is it
Xcode Source Editor Extension based tools to improve the text editing experience of Xcode 8
and provide extensions with simple code.
Features
- Multiline Selections
- Multiple Extensions
- Extendable (Example: Dotify)
- Swift 3.0
- Clipboard Text Handling (if no selection is made)
- Regular Expression Matching
- Error handling
- Preferences panel
- JavaScript for text handling
Install from Mac App Store
- Clear DrivedData if you built xTextHandler before
- Install from: https://itunes.apple.com/app/id1163761963
- Open Xcode and select text
- Open
Editor
menu to find extensions - You can set a shortcut (
Key-Binding
) for each extension - If you got nothing after installed, it must be a bug of XcodeKit, you can try build this project
Setup if there's nothing on the Editor menu
Build
- Install
Xcode 8
sudo /usr/libexec/xpccachectl
inmacOS EI Capitan
- Sign every targets (app & extensions) using your developer certificate
- Build & Run
- Choose
Xcode 8
to debug (Or restart Xcode) - Select text
- Open
Editor
menu to find extensions - You can set a shortcut (
Key-Binding
) for each extension
xEncode
- Base64 Encode
- Base64 Decode
- URL Encode
- URL Decode
- Upper Case
- Lower Case
- Escape
- MD5
- SHA1
- SHA256
- QR Code
xRadix
- Hex
- Bin
- Oct
- Dec
xColor
- Hex
- RGB
- Preview
xSearch
- Translate
- Developer
- StackOverflow
- GitHub
- Dash
- Dictionary
xFormat
- JSON
- XML
- CSS
- SQL
Thanks to: vkBeautify
How to write a new Extension
Plist
:
Add definition in <dict>
<key>XCSourceEditorCommandClassName</key>
<string>aClassName</string>
<key>XCSourceEditorCommandIdentifier</key>
<string>test.extension</string>
<key>XCSourceEditorCommandName</key>
<string>Test Extension</string>
</dict>
handler
via commandIdentifier
in class:
Map // Implement your modify strategy using block (you can implement as singleton dict)
// [ "commandIdentifier": handler ]
override func handlers() -> Dictionary<String, xTextModifyHandler> {
return [
"test.extension": { text: String -> String in text }
]
}
regex
:
* Handle with // Override performCommandWithInvocation like that
override func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: (NSError?) -> Void) {
if let handler = self.handlers()[invocation.commandIdentifier] {
xTextModifier.select(invocation: invocation, pattern: "regex", handler: handler)
}
completionHandler(nil)
}