 /**
 Print XML-formatted docs for the specified Xcode project
 */
-func print_docs_for_swift_compiler_args(arguments: [String], swiftFiles: [String]) {
-    println("<jazzy>") // Opening XML tag
-
+func docs_for_swift_compiler_args(arguments: [String], swiftFiles: [String]) -> String {
     sourcekitd_initialize()
 
-    // Only create the XPC array of compiler arguments once, to be reused for each request
-    let compilerArgs = (arguments as NSArray).newXPCObject()
+    // Create the XPC array of compiler arguments once, to be reused for each request
+    var xpcArguments = xpc_array_create(nil, 0)
+    for argument in arguments {
+        xpc_array_append_value(xpcArguments, xpc_string_create(argument))
+    }
+
+    var xmlDocs = [String]()
 
     // Print docs for each Swift file
     for file in swiftFiles {
-        // Keep track of XML documentation we've already printed
-        var seenDocs = Array<String>()
-
         // Construct a SourceKit request for getting the "full_as_xml" docs
         let cursorInfoRequest = xpc_dictionary_create(nil, nil, 0)
         xpc_dictionary_set_uint64(cursorInfoRequest, "key.request", sourcekitd_uid_get_from_cstr("source.request.cursorinfo"))
-        xpc_dictionary_set_value(cursorInfoRequest, "key.compilerargs", compilerArgs)
+        xpc_dictionary_set_value(cursorInfoRequest, "key.compilerargs", xpcArguments)
         xpc_dictionary_set_string(cursorInfoRequest, "key.sourcefile", file)
 
         // Send "cursorinfo" SourceKit request for each cursor position in the current file.

        // This is the same request triggered by Option-clicking a token in Xcode,
        // so we are also generating documentation for code that is external to the current project,
        // which is why we filter out docs from outside this file.
        let ranges = possibleDocumentedTokenRanges(file)
        for range in ranges {
            for cursor in range.location..<(range.location + range.length) {
                xpc_dictionary_set_int64(cursorInfoRequest, "key.offset", Int64(cursor))

                // Send request and wait for response

import Foundation
import XPC

// MARK: - Model

struct Section {
    let file: String
    let name: String
    let line: UInt
    let hasSeparator: Bool
    let characterIndex: UInt

    func xmlValue() -> String {
        return "<Section file=\"\(file)\" line=\"\(line)\" hasSeparator=\"\(hasSeparator)\">\(name)</Section>"
    }
}

// MARK: - Helper Functions

/**
Print error message to STDERR
