Xcode 4 plugin development - xcode

I've been looking all over the place but I can't find anything. Does anyone know how to create an Xcode 4 plugin?

As far as I know there is no official way to create Xcode 4 plugins (just like there wasn't one for v3.x).
Here is an openradar on Xcode's lack of plugin support:
Please support the ability for 3rd
parties to extend Xcode via a public
plugin API. Aperture, Visual Studio,
Eclipse, TextMate and other
applications benefit from this
ability. I would like to see more
advanced refactorings, code analysis
(think Resharper by Jetbrains) and
modeling.
Provide plugin API for Xcode 4 (rdar://8622025)
Please dupe this if you want plugins!
Edit: Just stumbled upon this:
Cédric Luthi:
"Xcode 4 does support user-defined
plugins, see CLITool-InfoPlist
for an example of a working Xcode 4
plugin. You just have to add
XC4Compatible (true) in the
Info.plist."
https://github.com/0xced/CLITool-InfoPlist
That being said these GitHub repos might be handy, too:
Xcode4 Plugin-API Documentation (link dead)
Xcode Plugin Template (link updated)
Further more mogenerator's Xmod plugin might be a good starting point.
(Wasn't Xcode-4 compatible yet, last time I checked, though)

Best way to learn is to look at github plugin code (see long list below):
Basically its a plugin bundle.
No main.m No MainMenu.xib
First class loaded by setting NSPrincipalClass in info.plist
in its init: you register for AppKit notifications
See the code samples
some check the mainBundle app id to make sure this is XCode
The XCode Editor window class is DVTSourceTextView
Its a subclass of DVTSourceTextView :NSTextView : NSText
so you can register to listen for its notifications for NSTextView or NSText
such as NSTextViewWillChangeNotifyingTextViewNotification
Because its not an official standard I noticed each sample loads in different ways.
XCODE PLUGIN SAMPLES
compiled by either searching github/web for
'DVTSourceTextView'
This is the Xcode Editor window class name
or
Info-list key
'XC4Compatible'
https://github.com/omz/ColorSense-for-Xcode
https://github.com/ciaran/xcode-bracket-matcher
- uses a ruby parser run as pipe!
https://github.com/joshaber/WTFXcode
https://github.com/0xced/NoLastUpgradeCheck
http://code.google.com/p/google-toolbox-for-mac/downloads/list
see GTMXcode4Plugin
https://github.com/DeepIT/XcodeColors
https://github.com/0xced/CLITool-InfoPlist
https://github.com/sap-production/xcode-ide-maven-integration
https://github.com/ciaran/xcode-bracket-matcher
TO GET TO THE NSTextView that is the console
https://github.com/sap-production/xcode-ide-maven-integration
- (NSTextView *)findConsoleAndActivate {
Class consoleTextViewClass = objc_getClass("IDEConsoleTextView");
NSTextView *console = (NSTextView *)[self findView:consoleTextViewClass inView:NSApplication.sharedApplication.mainWindow.contentView];
if (console) {
NSWindow *window = NSApplication.sharedApplication.keyWindow;
if ([window isKindOfClass:objc_getClass("IDEWorkspaceWindow")]) {
if ([window.windowController isKindOfClass:NSClassFromString(#"IDEWorkspaceWindowController")]) {
id editorArea = [window.windowController valueForKey:#"editorArea"];
[editorArea performSelector:#selector(activateConsole:) withObject:self];
}
}
}
return console;
}

Have a look at this new plugin: https://github.com/sap-production/xcode-ide-maven-integration. Maybe you can derive some concepts for your plugin.

Yesterday ColorSense for Xcode 4 was released on Github. Since the code is really compact spread over just 3 classes, I think you should take a look over there.

Xcode does not have a public plug-in API.
This was the case with earlier versions, and is the case with Xcode 4 as well.

No, Xcode doesn't support plugins, alternatively you may try AppCode, another IDE for iOS/MacOS, it does support plugins development.

Related

Adding multiple Cib / Xib files in Cappuccino

Currently I'm working on a product that uses the Cappuccino Framework and the Objective-J language.
I created my project using this command after installing Cappuccino: capp gen -t NibApplication Myapp
The Problem I'm facing is that I want to keep my code and GUI clean.
By doing so I wanted to split the GUI up in separate Xib / Cib (compiled version Cappuccino can read) and separate controllers, like I do with iOS and Mac apps.
I couldn't find on the internet or on the docs how to do so.
Also, all the examples (including the NibApplication template) contains only 1 xib file.
In short what I'm after is to load a controller, based on a XIB file which holds the window. All the outlets are connected to the controller I loaded.
Is there anyone who knows how to do it?
Thanks in advance and have a nice day!
The typical way to do this is to use a CPWindowController or a CPViewController for each xib you want to load. Here's what it might look like:
var myViewController = [[CPViewController alloc] initWithCibName:"mynib" bundle:[CPBundle mainBundle]];
This would load Resources/mynib.cib from your main bundle. Normally you'd also subclass CPViewController so as to give yourself a convenient spot for your control code.
Fixed it myself! I used this tutorial: http://vimeo.com/8948460
But instead of using atlas I used XCode. Just follow the steps but with XCode and you'll be fine if you want the above to happen.

Xcode 5 Link Document Type

Am following tutorial at
http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app
To link a document type to my application so that my application is responsible for opening up of that document.
XCode 5 works very different... Under your Target, Info tab is a "Document Types" line... am not sure how to use this, is there a sample for me?
Thanks
I'm sure you've either figured this out or moved on, but a little tip for most of these tutorials: you can often download the completed code from the website. I did so, and loaded it up in Xcode 5.0, and it works fine. Here's a screenshot of the plist entries (that's under Resources/ScaryBugs-Info.plist) for Document and Export:
Another way to change the Document types in Xcode is via the Project Info (select the project in the Navigator, then the target in the projects and targets list, then the info tab). Here's a screenshot of what that stuff looked like for me:
Here's another very helpful link straight from apple support. Watch the screenshot they have under Example and literally replicate everything from this screenshot and just change their custom extension from catinfo to pdf, ttf, xml or whatever you like
NOTE: Make sure you test this on actual iphone / ipad and not on simulator.
https://developer.apple.com/library/ios/qa/qa1587/_index.html

Upgrading interface builder document?

After opening an old iOS 6 App Xcode asked me if I wanted to upgrade my IB doc to version 5.0 or skip. I hit skip so I could learn about what it would do first.
Now I'm unable to find a way to re-upgrade the document?
After a little looking around it's located in the file inspector under Interface Builder Document.
You simply change the "Opens in - Xcode 4.6" to "Default (5.0)" and it upgrades your IB doc

Creating MonoTouch Custom Cells using XCode 4 does not work

I was used to creating Custom Cells in MonoTouch using Interface Builder but ever since XCode 4 has this integrated I can't seem to get it to work.
Is this a know issue?
Does anyone know of an article that describes how to go about this? I have plenty of books and found articles about how this works in XCode 3 (Interface Builder) but I am looking at how this works in XCode 4 !!
Also, when creating iPad View Controllers in MonoTouch the files seem to be separated (I get an fHeader.cs and a fHeader.xib file) whereas before the fHeader.cs file was 'part of' the xib file (hierarchically below it). Why is this?
I am using Mono 2.10.9 - XCode 4.2 and Monotouch 5.2.11
Thanks
This has a nice tutorial:
http://blog.arcticmill.com/2012/05/uitableview-with-custom-uitableviewcell.html
Check this tutorial:
http://sabonrai.wordpress.com/2009/08/28/monotouch-sample-code-uitableview/
Normally you create a DataSource Delegate and there you override the GetCell function.
In this function you can create your custom cell.

How do I use the Core Plot framework with Xcode 4?

How do I install the Core Plot framework into Xcode 4?
This older tutorial has instructions on how to install it for Xcode 3, but I could not find any similar instructions for Xcode 4. What do I need to do in order to use this framework with the newer Xcode?
I made one here that followed what I did:
http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html
Hope it helps!
It appears that I was unable to set up core plot project for the reason that I had corrupt example project which code I was using.
This are the steps:
open a project
add quartzcore framework
add other linker flags: -ObjC -all_load
add CorePlot.xcodeproj to existing project (drag and drop)
add sample class (from examples folder, drag and drop)
drag coreplot framework from added CorePlot.xcodeproj to linked frameworks
in IB
drop object and associate it to sample class
drop custom view to window and associate it vith CPTLayerHostingView
connect object and custom view
And hat is that (may sound complicated, but can be done in under a minute)
Steps can be taken in any order, except last few.
Everithing is very similar to instructions at: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application except the way it is done in xcode4 is actually easier.
Here are screenshoots that clarify the above steps: http://www.optimae.biz/data/stackoverflow/coreplot.pdf
Hope this will help someone.

Resources