Slide 1

Slide 1 text

EXTENDING XCODE ALTCONF 2014 BORIS BÜGLING - @NEONACHO

Slide 2

Slide 2 text

CONTENTFUL coupon: alt-conf-2014

Slide 3

Slide 3 text

AGENDA ▸ Xcode ▸ Use plugins ▸ Develop your own plugin

Slide 4

Slide 4 text

APPCODE? .

Slide 5

Slide 5 text

XCODE

Slide 6

Slide 6 text

Plugins!

Slide 7

Slide 7 text

POSSIBILITIES ▸ Color Schemes ▸ File Templates ▸ Project Templates ▸ Plugins

Slide 8

Slide 8 text

USE PLUGINS

Slide 9

Slide 9 text

HOW DO I EVEN...

Slide 10

Slide 10 text

@_supermarin

Slide 11

Slide 11 text

ALCATRAZ The Xcode package manager http://alcatraz.io Marin, Delisa and Jurre

Slide 12

Slide 12 text

curl -fsSL https://raw.github.com/supermarin/Alcatraz/ master/Scripts/install.sh | sh

Slide 13

Slide 13 text

opens

Slide 14

Slide 14 text

HOW DOES IT WORK? ▸ packages.json contains GitHub URL ▸ Clones the repository ▸ Runs xcodebuild with some parameters

Slide 15

Slide 15 text

SOME COOL PLUGINS

Slide 16

Slide 16 text

CLANGFORMAT

Slide 17

Slide 17 text

FUZZYAUTOCOMPLETE

Slide 18

Slide 18 text

KSIMAGENAMED

Slide 19

Slide 19 text

OMCOLORSENSE

Slide 20

Slide 20 text

POLYCHROMATIC

Slide 21

Slide 21 text

SHOWINGITHUB

Slide 22

Slide 22 text

VVDOCUMENTER-XCODE

Slide 23

Slide 23 text

XCODE_BEGINNING_OF_LINE

Slide 24

Slide 24 text

XCODECOLORS

Slide 25

Slide 25 text

DEVELOP YOUR OWN PLUGIN

Slide 26

Slide 26 text

GETTING STARTED ▸ Clone https://github.com/kattrali/Xcode5-Plugin- Template ▸ Put it into ~/Library/Developer/Xcode/Templates/ Project Templates/Application Plug-in/Xcode5 Plugin.xctemplate

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

PLUGIN TEMPLATE ▸ Xcode 5.1 compatible ▸ Shows a menu item for testing ▸ On build, plugin ends up here: ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ ▸ Just restart and it shows up

Slide 29

Slide 29 text

ONCE YOU BUILD AND RESTART XCODE .

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

LET'S BUILD SOMETHING USEFUL... .

Slide 32

Slide 32 text

GENERAL POINTS

Slide 33

Slide 33 text

COMPATIBILITY UUIDS THIS MIGHT APPEAR IN YOUR SYSTEM.LOG [MT] PluginLoading: Required plug-in compatibility UUID 640F884E-CE55-4B40-87C0-8869546CAB7A for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodsPlugIn.xcplugin' not present in DVTPlugInCompatibilityUUIDs $ defaults read /Applications/Xcode51-DP2.app/Contents/Info DVTPlugInCompatibilityUUID 640F884E-CE55-4B40-87C0-8869546CAB7A ADD THAT UUID TO YOUR PLUGIN'S INFO.PLIST

Slide 34

Slide 34 text

THIS WILL HAPPEN ALL THE TIME

Slide 35

Slide 35 text

YOUR ONLY FRIENDS... $ tail -f /var/log/system.log $ rm -rf ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/* ▸ Debug from the command line with lldb... ▸ or with a second instance of Xcode

Slide 36

Slide 36 text

HEADERS Use class-dump yourself, or just grab https://github.com/luisobo/Xcode5-RuntimeHeaders

Slide 37

Slide 37 text

WHAT WE ARE LOOKING FOR ▸ How to detect if the user types in the editor? ▸ How to hide the debug pane?

Slide 38

Slide 38 text

grep -ri editor *

Slide 39

Slide 39 text

@interface IDEWorkspaceWindowController : NSWindowController [...] @property(readonly) IDEEditorArea *editorArea; [...] @end

Slide 40

Slide 40 text

@interface IDEEditorArea : IDEViewController [...] - (void)toggleDebuggerVisibility:(id)arg1; - (void)activateConsole:(id)arg1; @property BOOL showDebuggerArea; [...] @end

Slide 41

Slide 41 text

- (void)toggleDebuggersIfNeeded { for (NSWindowController *workspaceWindowController in [objc_getClass("IDEWorkspaceWindowController") workspaceWindowControllers]) { id editorArea = [workspaceWindowController editorArea]; if ([editorArea showDebuggerArea]) { [editorArea toggleDebuggerVisibility:nil]; } } }

Slide 42

Slide 42 text

@interface NSObject (ShutUpWarnings) -(id)editorArea; -(BOOL)showDebuggerArea; -(void)toggleDebuggerVisibility:(id)arg; -(NSArray*)workspaceWindowControllers; @end

Slide 43

Slide 43 text

GREPPING THROUGH _SUBTREEDESCRIPTION grep -i source * [ AF O P LU ] h=--- v=--- NSClipView 0x7f822e93e990 f=(35,0,885,662) b=(0,637,-,-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms [ AF O LU ] h=-&- v=-&- DVTSourceTextView 0x7f822c723f00 f=(0,0,885,1339) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms [ A LU ] h=--- v=--- DVTMessageBubbleView 0x7f822eb5c080 f=(638,975,247,12) b=(-) TIME drawRect: min/mean/max 0.23/0.42/0.68 ms

Slide 44

Slide 44 text

DVTSourceTextView

Slide 45

Slide 45 text

- (void)swizzleDidChangeTextInSourceTextView { [[objc_getClass("DVTSourceTextView") new] yl_swizzleSelector:@selector(didChangeText) withBlock:^void(id sself) { [self toggleDebuggersIfNeeded]; [sself yl_performSelector:@selector(didChangeText) returnAddress:NULL argumentAddresses:NULL]; }]; }

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

@interface NSObject (YOLO) -(void)yl_performSelector:(SEL)aSelector returnAddress:(void *)result argumentAddresses:(void *)arg1, ...; -(void)yl_swizzleSelector:(SEL)originalSelector withBlock:(id)block; @end

Slide 49

Slide 49 text

- (void)swizzleDidChangeTextInSourceTextView { [[objc_getClass("DVTSourceTextView") new] yl_swizzleSelector:@selector(didChangeText) withBlock:^void(id sself) { [self toggleDebuggersIfNeeded]; [sself yl_performSelector:@selector(didChangeText) returnAddress:NULL argumentAddresses:NULL]; }]; }

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

SHIP IT { "name": "My Life-Changing Xcode Plugin", "url": "https://github.com/me/xcode-life-changing-plugin", "description": "Makes Xcode stop, collaborate and listen." } Send a pull request to the Alcatraz packages repo https://github.com/supermarin/alcatraz-packages

Slide 52

Slide 52 text

USING DTRACE ▸ Powerful dynamic tracing framework ▸ Can be used to log any objc_msgSend() ▸ Useful for seeing call trees of a specific class ▸ http://chen.do/blog/2013/10/22/reverse-engineering- xcode-with-dtrace/

Slide 53

Slide 53 text

THANK YOU!

Slide 54

Slide 54 text

BIG APPLAUSE FOR ALTCONF AND THE VOLUNTEERS!

Slide 55

Slide 55 text

https://github.com/kattrali/xcode-devtools https://coderwall.com/p/-mgtww

Slide 56

Slide 56 text

alcatraz.io

Slide 57

Slide 57 text

https://github.com/neonichu/extending-xcode/ https://github.com/neonichu/BBUDebuggerTuckAway/

Slide 58

Slide 58 text

Roulettathon San Francisco Three Random Pods Nine Hours ALL The Fun Saturday, 7th of June 2014 at 10am at Layer HQ Space is limited! This event is graciously hosted by Layer. cocoapods-roulette was developed by Heiko Behrens and Marcel Jackwerth at UIKonf. Background image by Conor Ogle.

Slide 59

Slide 59 text

http://podroulette.com/roulettathon-sf/