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

💥 Custom Playgrounds 🎯

💥 Custom Playgrounds 🎯

How to use custom frameworks in Playgrounds in Xcode 6 beta 2. Look at the internals of Playgrounds and how BBUToyUnboxer was implemented. Given at SwiftCrunch 2014 in Krakow.

Boris Bügling

July 06, 2014
Tweet

More Decks by Boris Bügling

Other Decks in Technology

Transcript

  1. $ swift Welcome to Swift! Type :help for assistance. 1>

    import ContentfulDeliveryAPI <REPL>:1:8: error: no such module 'ContentfulDeliveryAPI' import ContentfulDeliveryAPI ^
  2. 1> import ContentfulDeliveryAPI 2> var client = CDAClient() client: CDAClient

    = <extracting data from value failed> error: Couldn't lookup symbols: _OBJC_CLASS_$_CDAClient
  3. 3> var handle = dlopen("/Applications/.../Versions/A/ContentfulDeliveryAPI", 2) handle: COpaquePointer = Builtin.RawPointer

    = 0x0000000102e2b6e0 -> 0x00007fff5fc37e50 vtable for ImageLoaderMachOCompressed + 16 4> var client = CDAClient() client: CDAClient = {}
  4. DVTPLAYGROUNDCOMMUNICATION.FRAMEWORK @interface DVTPlaygroundCommunicationListener { NSString *_socketPath; } @interface DVTPlaygroundCommunicationSender ▸

    Uses TCP/IP on the local machine to communicate between Stub and Xcode ▸ But apparently uses Unix domain sockets for the other direction (?)
  5. @interface IDEPlaygroundExecutionSession : NSOperation [...] - (void)cleanupExecutable; - (void)destroyDebugger; -

    (void)_stopListeningForPlaygroundInput; - (void)_interruptExecutingPlaygroundSource; - (void)cancel; - (BOOL)canFinishExecution; [...] @end
  6. @interface IDEPlaygroundExecutionParameters : NSObject [...] - (id)initWithSourceCodeToExecute:(id)arg1 documentFileURL:(id)arg2 documentContentTimestamp:(id)arg3 autoTerminationDelay:(unsigned

    long long)arg4 executionPreparationParameters:(id)arg5 playgroundReportResultBlock:(id)arg6 playgroundExecutionWillFinishBlock:(void)arg7 playgroundExpressionCompleteBlock:(id)arg8 errorHandlerBlock:(void)arg9; @end
  7. 05/07/14 09:43:08,109 Xcode[9202]: toy-unboxing -- Fixed context: { DVTSourceLanguageServiceContextFormatOptionsKey =

    { ... }; DVTSourceLanguageServiceContextTextStorage = ...; IDESourceLangaugeServiceContextBuildSettings = { swiftASTCommandArguments = ( "-module-name", Playground, "-target", "x86_64-apple-macosx10.10", "-sdk", "/Applications/Xcode6-Beta2.app/.../MacOSX10.10.sdk", "-F", "/Applications/Xcode6-Beta2.app/.../Frameworks", "-F", "/Applications/Xcode6-Beta2.app/.../PrivateFrameworks", "-Xfrontend", "-debugger-support", "-c", "/Users/boris/Desktop/MyPlayground.playground" ); }; IDESourceLanguageServiceContextDocument = ...; IDESourceLanguageServiceContextDocumentURL = ...; }
  8. RELEVANT WWDC 2014 SESSIONS ▸ Session 408: Swift Playgrounds ▸

    Session 409: Introduction to LLDB and the Swift REPL