-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Xcode 6 GM #34
Comments
Will have a look, wanted to play a bit more with SourceKit anyway. |
Any news on Beta3 support? |
This issue is still open and I haven't found a workaround for Xcode6-Beta3. If anyone has any experience writing XPC clients, we could connect to SourceKitService directly without relying on I looked into it briefly and it appears that |
Just briefly looking at it, it looks like |
Thanks for looking at it, @zwaldowski. Whichever API it's using, we should be able to connect to it. Here's an SourceKit XPC logging dump of Xcode6-Beta3: https://gist.github.com/jpsim/e5398e40047492d85966 Hopefully looking at that will help us connect to SourceKitService. |
If you create a target and link against dispatch_queue_t q = dispatch_queue_create("com.dizzytechnology.XPCTest.gcd", 0);
xpc_connection_t conn = xpc_connection_create("com.apple.SourceKitService", q);
xpc_connection_set_event_handler(conn, ^(xpc_object_t object) { });
xpc_connection_resume(conn);
xpc_object_t dict = xpc_dictionary_create(0, 0, 0);
xpc_dictionary_set_bool(dict, "ping", true);
xpc_connection_send_message_with_reply(conn, dict, dispatch_get_global_queue(0, 0), ^(xpc_object_t object) {
if (xpc_get_type(object) == XPC_TYPE_ERROR) {
const char *string = xpc_dictionary_get_string(object, XPC_ERROR_KEY_DESCRIPTION);
NSLog(@"error: %s", string);
} else {
NSLog(@"Hello from SourceKit! They were nice enough to send us an empty dictionary! %@ %@", conn, dict);
}
}); A quick look at disassembly pseudo-code indicates:
|
This is really great, @zwaldowski! I've managed to reproduce your setup and the ping works. Now it shouldn't be too hard to call "source.request.docinfo" from here. |
Any status on this issue? |
@Zappel I haven't worked on this since the last comment 2 weeks ago. The biggest challenge now is to create an XPC client that connects to |
I dived a bit in the assembly of #import <Foundation/Foundation.h>
void sourcekitd_initialize();
uint64_t sourcekitd_uid_get_from_cstr(const char *);
xpc_object_t sourcekitd_send_request_sync(xpc_object_t);
int main(int argc, const char * argv[])
{
sourcekitd_initialize();
xpc_object_t request = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_uint64(request, "key.request", sourcekitd_uid_get_from_cstr("source.request.docinfo"));
// Use this parameter to parse from file
xpc_dictionary_set_string(request, "key.sourcefile", "/Users/guillaume/Projets/jazzy/sample/Musician.swift");
// Or this one to parse from string
// xpc_dictionary_set_string(request, "key.sourcetext", "//\n// Musician.swift\n// JazzyApp\n//\n\n/**\n Musician models jazz musicians.\n From Ellington to Marsalis, this class has you covered.\n*/\nclass Musician {\n /**\n The name of the musician. i.e. \"John Coltrane\"\n */\n var name: String\n\n /**\n The year the musician was born. i.e. 1926\n */\n var birthyear: UInt\n\n /**\n Initialize a Musician.\n Don't forget to have a name and a birthyear.\n\n @warning Jazz can be addicting.\n Please be careful out there.\n\n @param name The name of the musician.\n @param birthyear The year the musician was born.\n\n @return An initialized Musician instance.\n */\n init(name: String, birthyear: UInt) {\n self.name = name\n self.birthyear = birthyear\n }\n}");
xpc_object_t result = sourcekitd_send_request_sync(request);
if (xpc_get_type(result) == XPC_TYPE_ERROR) {
const char *string = xpc_dictionary_get_string(result, XPC_ERROR_KEY_DESCRIPTION);
NSLog(@"error: %s", string);
} else {
NSLog(@"%@", result);
}
} I'm using 3 functions directly from the sourcekit framework to work around guessing the format of the messages. Another win when using these is having the nice logging output when I'm a bit frustrated as I could not figure out what to put in the array of |
Perhaps we should update the title to Beta 5? |
You can also do it via FFI: require 'pathname'
require 'ffi'
module LibC
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :malloc, [:size_t], :pointer
attach_function :free, [:pointer], :void
end
module XPC
extend FFI::Library
ffi_lib '/usr/lib/system/libxpc.dylib'
# [array of string, array of xpc_object_t, size_t], xpc_object_t
attach_function :dictionary_create, :xpc_dictionary_create, [:pointer, :pointer, :size_t], :pointer
# [xpc_object_t, string, uint64_t], void
attach_function :dictionary_set_uint64, :xpc_dictionary_set_uint64, [:pointer, :string, :uint64], :void
# [xpc_object_t, string, string], void
attach_function :dictionary_set_string, :xpc_dictionary_set_string, [:pointer, :string, :string], :void
# [xpc_object_t, string], string
attach_function :dictionary_get_string, :xpc_dictionary_get_string, [:pointer, :string], :string
# [xpc_object_t], xpc_type_t
attach_function :get_type, :xpc_get_type, [:pointer], :pointer
# [xpc_object_t], void
attach_function :release, :xpc_release, [:pointer], :void
# [xpc_object_t], xpc_object_t
attach_function :retain, :xpc_retain, [:pointer], :pointer
# [xpc_object_t], string
attach_function :copy_description, :xpc_copy_description, [:pointer], :string
module Type
extend FFI::Library
ffi_lib '/usr/lib/system/libxpc.dylib'
attach_variable :error, :_xpc_type_error, :pointer
end
module ErrorKey
extend FFI::Library
ffi_lib '/usr/lib/system/libxpc.dylib'
attach_variable :description, :_xpc_error_key_description, :string
end
end
module SourceKitD
extend FFI::Library
developer_dir = Pathname(`xcode-select -p`.chomp)
dt_toolchain_dir = developer_dir + 'Toolchains' + 'XcodeDefault.xctoolchain'
ffi_lib dt_toolchain_dir + 'usr' + 'lib' + 'sourcekitd.framework' + 'sourcekitd'
attach_function :sourcekitd_initialize, [], :void
sourcekitd_initialize
attach_function :uid_get_from_cstr, :sourcekitd_uid_get_from_cstr, [:string], :uint64
# [xpc_object_t], xpc_object_t
attach_function :send_request_sync, :sourcekitd_send_request_sync, [:pointer], :pointer
end
source = <<SOURCE
//
// Musician.swift
// JazzyApp
//
/**
Musician models jazz musicians.
From Ellington to Marsalis, this class has you covered.
*/
class Musician {
/**
The name of the musician. i.e. \"John Coltrane\"
*/
var name: String
/**
The year the musician was born. i.e. 1926
*/
var birthyear: UInt
/**
Initialize a Musician.
Don't forget to have a name and a birthyear.
@warning Jazz can be addicting.
Please be careful out there.
@param name The name of the musician.
@param birthyear The year the musician was born.
@return An initialized Musician instance.
*/
init(name: String, birthyear: UInt) {
self.name = name
self.birthyear = birthyear
}
}
SOURCE
request = XPC.dictionary_create(nil, nil, 0)
XPC.dictionary_set_uint64(request, "key.request", SourceKitD.uid_get_from_cstr("source.request.docinfo"))
XPC.dictionary_set_string(request, "key.sourcetext", source)
result = SourceKitD.send_request_sync(request)
if XPC.get_type(result) == XPC::Type.error
error = XPC.dictionary_get_string(result, XPC::ErrorType.description)
puts "error: #{error}"
else
desc = XPC.copy_description(result)
puts desc
LibC.free(desc)
end
XPC.release(request)
XPC.release(result) # not entirely sure about this one |
I'm making small incremental progress on this issue, thanks to the efforts of everyone on this thread. In a proof-of-concept project, we can now extract documentation information for Swift source files, SDK modules, Swift frameworks... but not Objective-C frameworks. This last one is the last holdout. If you'd like to give it a shot you can fork the SourceKitten sample project and try to make approach #3 work. |
@jpsim Looking at the debugging output for approach #2 (parsing Foundation) and trying to play around with it, |
You're quite right, although running Also, command-clicking on an objective-c USR from Swift in Xcode does trigger relevant sourcekit logs. It might be necessary for us to build a swiftmodule from Objective-C in order to run docinfo on it. That's the next thing I'm trying. |
Good news: we've regained the ability to generate a Swift interface from an Objective-C header! See the SourceKitten project for details. Bad news: we don't have USR's for the swift tokens in the generated Swift interface. But there's still hope. I think if we pass in the USR in the request, the equivalent Swift token will be "highlighted" in SourceKit's response. But nonetheless, this was the major hurdle to getting jazzy back on track, so I hope to be able to bring it back up and running in the next few days. |
Hi, |
I guess at this point it's probably best just to wait for GM next week? As it doesn't seem like we'll be getting a beta 7. |
Work that we do to support beta 6 will likely be transferable to GM, at the very least partially, so we'll keep working with the latest beta until then. |
Good point. And I spoke too soon, we have a beta 7 now. :) |
Thanks you all. Impatient to test it ! |
Eagerly waiting for the fixes. any estimate when this will be made available? |
I want it too.. The apple template style documentation is so good .. |
Hi everyone, a status update is long overdue. Here's where we are:
Roadmapjazzy's goal is to be a cross-language documentation tool, which allows generating mixed Objective-C/Swift documentation from projects written in Objective-C, Swift or a mix of both. Here's a tentative roadmap including planned features for each release:
0.1.0
0.2.0
0.3.0
Final thoughtsBecause jazzy uses internal Apple tools, there's an up-front investment in reverse engineering that we have to make. But once that's done, the payoff will be huge since we won't have to maintain a complex parser. Around 0.1.0, I'll make an effort to clean up and document the codebase (oh, the irony) so others can more easily contribute. Until then, thanks for your patience! |
👍 I'll take a look at SourceKitten (great name btw) this week, I started to dig into the sourcekitd_* functions a while ago. |
The march of progress continues! Documentation comments can now be extracted from any project that Xcode 6 can build. See this branch of SourceKitten and this sample output gist. Now it's a question of integrating this back into jazzy. Thanks for your patience. |
I don't have much to provide in the form of help, but I love what you guys are doing and the work going into this project. |
I see an exciting flurry of activity! Does that mean that Jazzy for Xcode 6.0/6.1 is coming soon? |
Hi everyone, thanks so much for your patience. jazzy 0.0.5 was just released! As a demo, I've generated Alamofire 1.1.0's docs, visible here: http://static.realm.io/jazzy_demo/Alamofire/ If you've been hoping to contribute to jazzy, now's a great time to start. Try it with your project and see what works, what doesn't. Please file issues when you find scenarios that don't work. Areas of focus that I'd encourage others to provide feedback and fixes are in the front-end HTML and updating the Big thanks to @segiddins for setting up a good ruby foundation with integration tests, rubocop and better encapsulation. Also a big thanks to everyone in this issue for your help, support and patience as we worked on getting jazzy back on track. |
Unfortunately, the approach we took with Xcode 6 Betas 1 & 2 no longer work with Beta 3.
This still works:
but this no longer works:
Seems to be an issue with
sourcekitd-test
's XPC connection withSourceKitService
, but I'm unsure how to fix it. If anyone has any ideas, I'd ❤️ to hear from you!The text was updated successfully, but these errors were encountered: