I have a project from 2 years ago that I'd like to bring back into action in xcode.
Is there a simple way to do away with the old style memory management I have in there with retain/releases and use the new .. ARM?
And this is a 32bit app using the QTKit and QuickTime frameworks - can this become a 64bit app that I can put on the App Store one day if it works well?
Also I realise that my app is one enormous .h and .m file - i'd like to break it into smaller files to make it easier to read and find what i am doing - any tips on how to do that?
Thanks guys!
Adam
Use the Xcode menu item Edit->Refactor->Convert To Objective-C ARC which can automatically convert everything to ARC.
You can also use Edit->Refactor->Convert to Modern Objective-C syntax to update the code to use the new array/dictionary/number literal syntax.
For breaking out one file into many, Xcode's built-in refacting support is pretty terrible. You can try out Jetbrains Appcode which has much better support for this kind of thing.
Related
Is there an IDE which specifically supports Objective-C and has linked with Cocoa Touch (optionally Cocoa) build tools for easy writing, building and running of programs?
I am looking to switch from XCode because XCode is buggy and crashes when I load files which has thousands of lines of code. Also the beautifier isn't good. It's not that performant.
It doesn't need to come with Interface Builder. I just need to write Objective-C in the IDE. More like Aptana if you have been a web developer.
Jetbrains have AppCode http://www.jetbrains.com/objc/. it is an IntelliJ based alternative for Xcode but depends on an installed Xcode for IB and CoreData.
Only for writing Obj-C Code, you can use any text editor.
You can not draw any UI like IB, but you can code to construct any of the UI elements.
However I would suggest to use BBEdit.
Or if you wish you can go for any C / C++ / Java IDE. But it wont compile for compiling you need to to switch back to XCode.
Or you can compile through terminal by giving the following command.
xcodebuild -project "delta.xcodeproj" -target "delta" -configuration Release OBJROOT="/Users/anoop/desktop/delta" SYMROOT="/Users/anoop/desktop/delta"
I feel your pain but even if you find an IDE other than XCode you will find yourself coming back to XCode to do something anyway such as the Interface Builder, etc.
Also, unfortunately, AppCode also not perfect. There are scenarios it doesn't cover yet that might hinder you from migrating or cause you to do heavy hacks to get it to work.
However, I have a project with hundreds of files including source files and it works fine for me. I do admit that it crashes from time to time but there is nothing you can do about it. Maybe try refactoring your project to reduce the size of your source files. I did find having large text files can cause it to go bonkers. But it is a good practice anyway to have small class files. Maybe what you are describing is a code smell of bloated classes?
I'm not meaning to offend you or anything. It's just another perspective for you to look at. Use it or don't use it.
I'm a newbie to Xcode, Objective-C and iOS programming (fully comfortable in R however, so familiar with programming concepts). I'm working my way through building my first app using a couple of books.
I have botched some or most connections due to misunderstanding the concept at first, and I think also renaming objects and variables has caused confusion (connections = targets and actions as I understand it). In Xcode,
is there a way to remove/clear all these at once?
is there a tool to find the orphaned objects (ones that still need either a target or action)?
is there a tool to summarize all of them? They don't really appear in raw code any place, right? They are embedded in the .xib if I understand correctly.
I'm on OSX 10.7.2 and Xcode 4.2.1 Thanks!
Depending on how deep you are in the project, you could simply create a brand new project and copy your code from the old to the new (and recreate your XIB's; the new ones would have no botched connections).
Or, you'd have to go into each of your XIB files (they're text) and you can delete the connections en masse there (look for entries like IBToOneOutletInfo, IBActionInfo, etc.). Best to do this from within Xcode though, with the built in Interface Builder (just click on the "X"s next to the connections and actions for each object to officially disconnect them).
I need to be able to compress file in an iPhone/iPad application. I know there are a few libraries out there that have this problem solved and are easy to integrate in an application, but I was wondering if there is something already implemented in Cocoa. It would help me a lot if I did not need to integrate external libraries in my project.
Do you mean something in iOS / objective-c ? If so, you do know that most objects you are using is an 'external library' i.e. the Foundation framework?
There is, shipped with every iPhone, libz which is the library for zipping / unzipping. You just include it as if it were any other framework.
However, the chances that you will, first time, use it as bug free as an existing library that's been tested for years by hundreds of other developers is slim.
Personally, I would easily choose adding a library over writing my own for something like this - it's been done before, you're just wasting time re-writing it. Try ZipArchive for a one-liner to unzip files etc. Just copy the source code into your app and press build :)
I don't think there is something like that in cocoa inbuild .. but you should have a look here - https://bitbucket.org/kolpanic/zipkit/wiki/Home
I think Xcode is a good IDE, but having used Eclipse for Java development in the past I am quite underwhelmed by XCode's code completion and error/warning feedback. (Most of the time, XCode seems to simply try to match the beginning of a text fragment to "words" in the same document, without even using type information to try to determine the appropriateness of a suggested completion.)
Does anyone have ideas or tricks to make XCode approach Eclipse's cleverness, or to realistically develop Cocoa apps with other IDE:s than XCode?
EDIT: Worth keeping an eye on this: code.google.com/p/objectiveclipse/
The good news is, Apple’s working on the problem. One of the goals of the clang compiler project is to create a reusable parser which can be used for better code completion and refactoring support. Indications are that this has borne fruit in the latest Snow Leopard seeds.
Quite simply: no.
You can do almost everything by hand using your favorite text editor but it's not at all recommended. Try designing interfaces without Interface Builder for example.
My advice would be to just stick with Xcode and learn its way of doing things. Yes, it will be different and sometimes might not be "better" in your Eclipsed eyes. Console yourself in the fact that Apple's managed to release some great products using Xcode.
My personal experience is that, each time I use Xcode, I find a new trick which I can add to my bag. Xcode is far more full-featured than what you might think at first (or second) glance.
I've long voiced my rants about what's wrong with Xcode (and what's not wrong with Xcode). But you really don't want to use another tool. And without breaking NDA: Xcode 3.2 with SnowLeopard: Hooray. (Compared to what we have; not compared to what we might want.)
That said, to your original question about code completion, I personally turn off auto-completion in favor of on-demand completion. I find it far more useful and less distracting. In the Code Sense panel, set "Automatically Suggest" to "Never" and make sure the other two options are selected ("Show arguments in pop-up list" and "Insert argument placeholders...") This will do completion in a pop-up box when you hit Escape, making it easy to scroll through looking for what you want. I find that I have to type a lot less this way, especially for methods that are not unique for many characters. 80% of the time, it's highlighting the right thing already.
I have certainly felt your pain — as an experienced Java developer and frequent Eclipse user, I've wished for the same features myself. Unfortunately, I'm not aware of anything that fits the bill. I don't think there was any satisfactory resolution to this SO question, either.
However, I think you'll be quite happy with the improvements to Xcode code completion coming in Snow Leopard — it's vastly smarter about filtering the list of possible completions. Also, there are new conveniences for coding, such as inserting a starting bracket when you forgot one, etc. To my knowledge, there is still no predictive compiling like Eclipse, though.
Is anyone aware of an IDE other than Eclipse that supports predictive compiling and warning/error reporting? Does Eclipse itself support the feature for languages other than Java, such as C++? I'm led to wonder whether the fact that Java is built with independent .java files rather than .h and .c/.cpp/.m files makes it simpler to predictively compile. Also, anything compiled with gcc requires a little more care and attention than the comparatively simpler javac command. Any thoughts?
Check out JetBrains' new IDE called "App Code". It's still in the Early Access Program, but even with the Early Access bugs it is hands-down better than xcode 4.
http://www.jetbrains.com/objc/
emacs and/or vim
Xcode does have some context awareness, when you are sending a message to an object it will generally have the "ESC" list pull up meaningful arguments.
One thing I strongly recommend is looking into text macros. These are not really type aware, but they can save a ton of typing - for instance, after #implementation type "init" and then hit control-. (period) to activate the text macro. It will fill out a whole init method for you. You can create your own, or override the existing macros.
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy getting to grips with a new language, platform and paradigm.
One thing is though, having been using Visual Studio with R# for so long I've kind of been spoiled with the coding tools such as refactorings and completion etc and as far as I can tell Xcode has some fairly limited built in support for this stuff.
On that note, does anyone know if any add-ins or whatever are available for the Xcode environment which add coding helpers such as automatically generating implementation skeletons from a class interface definition etc?
I suspect there aren't but I suppose it can't help to ask.
You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion.
The good news is that Xcode 3 and later come with superb auto-completion and template support. By default, you have to explicitly request completion by hitting the escape key. (This actually works in all NSTextViews; try it!) If you want to have the completions appear automatically, you can go to Preferences -> Code Sense and set the pop-up to appear automatically after a few seconds. You should find good completions for C and Objective-C code, and pretty good completions for C++.
Xcode also has a solid template/skeleton system that you can use. You can see what templates are available by default by going to Edit -> Insert Text Macro. Of course, you don't want to insert text macros with the mouse; that defeats the point. Instead, you have two options:
Back in Preferences,go to Key Bindings, and then, under Menu Key Bindings, assign a specific shortcut to macros you use often. I personally don't bother doing this, but I know plenty of great Mac devs who do
Use the CompletionPrefix. By default, nearly all of the templates have a special prefix that, if you type and then hit the escape key, will result in the template being inserted. You can use Control-/ to move between the completion fields.
You can see a full list of Xcode's default macros and their associated CompletionPrefixes at Crooked Spin.
You can also add your own macros, or modify the defaults. To do so, edit the file /Developer/Library/Xcode/Specifications/{C,HTML}.xctxtmacro. The syntax should be self-explanatory, if not terribly friendly.
Unfortunately, if you're addicted to R#, you will be disappointed by your refactoring options. Basic refactoring is provided within Xcode through the context menu or by hitting Shift-Apple-J. From there, you can extract and rename methods, promote and demote them through the class hierarchy, and a few other common operations. Unfortunately, neither Xcode nor any third-party utilities offer anything approaching Resharper, so on that front, you're currently out of luck. Thankfully, Apple has already demonstrated versions of Xcode in the works that have vastly improved refactoring capabilities, so hopefully you won't have to wait too long before the situation starts to improve.
I'm excited to say that JetBrains have decided to make a decent IDE for Objective-C coders.
It's called AppCode and it's based on their other tools like RubyMine and Resharper. It's not native Cocoa, but has loads of raw refactoring power.
http://www.jetbrains.com/objc/index.html
I've started using it for my main Objective C project and I'm already in love. It's still in it's infancy, but for code editing and refactoring it already blows Xcode away.
Update
It's now at a totally usable speed. I've switched over to it full time and it still blows my mind how amazing refactoring and coding is compared with Xcode. It just handles so much for you - auto importing, almost infinite customisation. It makes Xcode look like a toy.
Xcode has refactoring for C and Objective-C built in. Just select what you'd like to refactor, choose "Refactor..." from either the menu bar or the contextual menu, and you'll get a window including the available refactorings and a preview area.
Xcode doesn't currently have a public plug-in API; if there are specific types of plug-ins you'd like Apple to enable, file enhancement requests in the Bug Reporter. That way Apple can count and track such requests.
However, there are third-party tools like Accessorizer and mogenerator (the latest release is mogenerator 1.10) that you can use to make various development tasks faster. Accessorizer helps you create accessor methods for your classes, while mogenerator does more advanced code generation for Core Data managed object classes that are modeled using Xcode's modeling tools.
Just so people know, Accessorizer does more than just generate accessors (both 1.0 and properties for 2.0) it also generates Core Data code for persisting non-standard attributes, your NSSet accessors for custom to-many relationships.
In fact, Accessorizer will help provide you with the init, keypath, keyed-archiving, indexed accessors, accessors for unordered collections such as NSSet, copyWithZone, KVO, key-validation, singleton overrides, dealloc, setNilForKey, non-standard attribute persistence (Core Data), locking, headerdoc, convert method to selector, NSUndoManager methods and more.
I found some xtmacro files in Xcode.app package:
/Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Contents/Resources
Installed Xcode ver. 3.2.5.