Has anyone got Rails3 development working in Xcode4? [duplicate] - ruby-on-rails

Does Xcode 4 have support for rails projects? If so, to what extent?
UPDATE - Obviously it lets you edit text files. But does it give you any IDE features, e.g. syntax highlighting, navigation to declarations, code completion, etc... ?

In the past Xcode releases many were able to use the Xcode IDE for non-apple projects such as PHP, Rails, etc.
All you had to do was open Xcode organiser and drag your project in there and it worked. Not so with Xcode 4, but the feature has not been removed but in fact improved in my opinion.
In Xcode 4, click File > New > New Workspace.
Give it a name and once on the main editor window simply drag and drop your Rails, PHP, etc project onto the project navigator.
Then you can choose Editor > Syntax Coloring > [Any] for syntax highlighting.
M.

I paid up to intall XCode 4 thinking that it would be simpler to consolidate all my development to a single IDE. XCode is the default because of the built in Mac API docs. I built a few MacRuby (0.10) samples, which parse and run.
Problems are:
XCode insists on using // to comment lines, which then don't parse.
There is no debugging for Ruby files, only for the Objective C wrapper stub.
There is no in-app "run" for rack, rails or scripting type apps.
The syntax parsing is limited to keywords, strings, comments and characters.
XCode doesn't understand .erb or .yaml files are html and ruby.
There were workarounds for 1 and 5 in 3.2 for 1 and 5 but they no longer work with 4 as far as I can see.
On the plus side, the documentation interface to OSX and NextStep is very nice and MacRuby and the UI editor work well together and allow bundling desktop apps which can be distributed standalone or via the app store. I would use it to build ruby apps that use the desktop GUI.
For conventional web or scripting apps you can 'bare edit' rails projects in the 'Workspace' area and then skip to the terminal to run a server or use script/console to debug; but for this NetBeans is still far superior IMHO with in-code debugging and automated tests and workflow.

As I'm unable to respond to the comments I'll just give answering your question a shot: Considering Apple's "what's new" page doesn't seem to list too many groundbreaking changes, I'm guessing Matt Ball's suggestion to go with the guide for Leopard and assuming nothing Rails or Ruby specific is new would be a safe and probably spot-on bet.

Giving a try to xcode 4 with rails. Work fine, except some color syntaxing trouble (with yml or haml file for example). It's great, expecialy the integration of git (to show easyly modified files)

Related

Using Vim instead of (or with) Xcode for iOS development

Xcode comes with a lot of things that are essential to building to the iPhone and/or iPad. In fact a lot of it I am not even aware of because it is so 'behind the scenes'.
On the other hand, I have recently been exposed to the advantages of using Vim as an editor. Is there any setup which would make using Vim an efficient option when developing for the iOS platforms? Or would it be so complicated to combine the two as to make this question moot?
In other words, if you have any tips, advice or warnings when using Vim and Xcode together, I am all ears!
Developing for iOS or Mac with Vim can be really powerful and fast, especially if you use TDD or want quick feedback.
But it takes a bit of finagling to get it working. The few important things you need to know are:
Use the xcodebuild command-line tool to run your build and units from some vimscript.
Use the clang_complete plugin to give you full code completion from within vim.
Use the ios.vim and cocoa.vim plugins for navigation.
This is my preferred method of working. In fact, I wrote the ios.vim plugin to make this easier for more people.
I've been there already...
I love vim and regularly use it in my day-by-day C++ development on *nix platforms, but I also like all of Xcode's features which, specially with latest Xcode >= 4.3 and clang backend, give a real plus in terms of auto-completion and symbol referencing.
I think I've found the optimal solution with the great (although not officially supported by Apple) XVim plugin.
Hoping that future Xcode upgrades won't break it (it's still working fine with latest developers' previews of 4.5), this really allows you to keep your fingers moving as you've learned doing in Vim while working with Xcode, which as I said, is for me the optimal solution.
Vim and XCode will co-exist quite well together provided that you aren't trying to edit the same files in Vim and the XCode editor at the same time. If you do then each will give you a warning about the file being modified externally. The terminal version of Vim is a little easier to live with in this particular respect: it will only warn you when you try to save the file, asking are you sure, whereas MacVim, and the XCode editor, will warn you each time you return to the file.
XCode does allow you to select an external application when you open files, by file type. In XCode Preferences, go to the File Types tab, and then file->text->sourcecode. Preferred Editor can be set to an external program such as MacVim; note that Emacs should be already listed as a selection: when Emacs is selected XCode launches Terminal.app with Emacs in a terminal. This Preferred Editor setting has the problem that you'll get a new window with each opened file, which may not match your workflow.
Vim's remote feature might prove useful here, see :help remote. With a little work, and the above Preferred Editor preference, one should be able to send the file to be edited to any instance of Vim, including an existing Vim running within an xterm. I seem to recall that Emacs provides something similar.
But none of this precludes you from using Vim without setting Preferred Editor: just open and edit your project files in Vim as you would normally.
Your workflow might be to use Vim for editing code, and switch to XCode for building the project, but Vim can also run the same build tools that XCode uses, and with a little more work you'll even be able to jump to the lines with errors. XCode relies on gdb for debugging, which can also be used quite well with Vim, via plugin.
Of course Vim can't be expected to replace something like Interface Builder, but just about every other aspect of iOS dev can be achieved with a Vim-only solution.
Or just use Vim to edit your code faster, and continue to use XCode for the rest.
Starting with Xcode 13.0 Beta you can use Vim keybindings in Xcode. It is enabled in settings:
Preferences → Text Editing → Editing → Enable Vim key bindings
Edit (per #fangxing):
The way to toggle what is now called Vim Mode changed:
Menubar → Editor → Vim Mode
Even thought MacVim with YouCompleteMe is my main environment for development on OSX, there are tasks I prefer to do in XCode, like debugging and profiling. For these scenarios I use XVim which adds VIM editing capabilities to XCode.
On XCode 5.1 XVim crashed quite a lot. But it progressed and it now works quite well with XCode 6 so far. But you only get a subset of VIM this way, e.g. you can't split the editor to view two files at the same time. You can enable/disable it quite easy with Shift-Command-X.
(Sorry to post this as answer and not as a comment, but the reputation-system of stackoverflow did not made it possible for me)
I can't recommend YouCompleteMe enough! Beside its code-completion it also shows you syntactic errors on the fly on the affected line without the need of manually triggering your compiler (i.e. very similar to the features of the XCode editor). The description of the YCM creator is quite informative:
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion
engine for Vim. It has several completion engines: an identifier-based
engine that works with every programming language, a semantic,
Clang-based engine that provides native semantic code completion for
C/C++/Objective-C/Objective-C++ (from now on referred to as "the
C-family languages")...
To get it running:
Follow the section 'Mac OS X super-quick installation'
Don't forget to add a .ycm_extra_conf.py file to the root of your project folder
Edit:
Without a plugin like YouCompleteMe, VIM can only do rudimentary word completion (Ctrl-N) which is neither aware of the programming language you're using nor of all the other files belonging to your project. You also don't get a list of the members of an object after you type '.' or '->'. So you miss on a lot of help (and therefore speed) XCode is giving you while typing. Also VIM doesn't warn you like XCode when you make typos or other errors in your code. YouCompleteMe adds exactly those missing features to VIM and makes iOS development in VIM a joy.
You could use xcodebuild to build and run your project, but personally I prefer to work with VIM and XCode at the same time. Both reload documents automatically after they have been modified by the other. Keep XCode for debugging, profiling and deployment.
Using AppCode in parallel with Xcode is just amazing. Code changes sync right away! I am so happy with this setup because I can finally use vim (as an AppCode plugin) when writing iOS apps. AppCode has additional advantages so I really recommend that you check it out. The refactoring tools are also way better IMHO. E.g. it can extract methods that Xcode can't for some reason and if it can not extract a method it will at least tell you why.
There are definitely some advantages using external editors ( however emacs is ten million times better than vim:}).
Stick with Xcode for most stuff, but when you need the power of emacs, or possibly vim ( bulk repetitive editor macros is my main reason), just edit the file using show in finder and open with, or just by switching to your editor navigating to the file from there.
XCode will realise when you switch back that the file has changed.
For plain code, I'd stick with Xcode, it's code completion is based on more knowledge of the code, so beat's emacs or vim's hands down. Continuous code checking is invaluable, and as already mentioned, the direct access to the documentation is awesome ( option click if you haven't already found it).
I like XVim for XCode. Unfortunately, it breaks for XCode 5.1 (some people got Development branch working, but I couldn't).
I ended up switching to AppCode after a trial, I really liked the tab management, refactoring, and code analysis. Code is automatically synced with XCode, so I run both (XCode for build settings, managing asset catalog. AppCode for everything else).
First day I downloaded it, I installed IdeaVim so I could still use some of the Vim keyboard shortcuts.
Though you won't get to full Vi/Vim functionality with the plugin. I find mix usage with native IDE commands is enough to compensate.
According to my opinion Xcode is better solution. It has so many features that you can not find/add in Vim. Some of them are:
Interface Builder (to create good lookin interfaces in less time)
ARC (Automatic Reference Counting—memory management)
Automated process for managing code signing and app store submission
The list is very long and Apple always encourages you to use Xcode, not any other IDE.

IDE with refactoring support for Ruby on Rails

I am a java developer and use the Eclipse IDE for developing java code. I use the built-in refactoring features a lot, since good refactoring support from the IDE helps to speed up and leads to higher code quality. I would not like to miss it and use a simple text editor instead. Now I am looking for an IDE for Ruby on Rails with good refactoring capabilities.
Basic refactorings
Wanted basic refactoring methods include:
Extract method
Extract variable
Rename (class, method, variable etc.)
and so on.
Aptana Studio 3, RadRails 2, RubyMine 3 and Netbeans 7
So far I've tried Aptana Studio 3 and was quite disappointed regarding its refactoring capabilities. Aptana RadRails 2 seemed much better for refactoring ruby code, but it lacks other nice features that the newer Aptana Studio 3 offers. Since Aptana Studio 3 seems to be RadRails' successor I would expect that it has at least the same refactorings as the older RadRails 2, but it does not. Using an old unmaintained IDE does not seem a good option. Receiving updates for the IDE should still be possible.
I've read that Jetbrains RubyMine 3 has decent ruby refactoring capabilities, but it costs money. I am rather looking for a free one. Netbeans 7 seems not to support Ruby on Rails anymore.
Are there good IDEs with refactoring support?
That confuses me, it seems like modern IDEs drop (refactoring) support for Ruby on Rails.
What are nowadays (Jan 2012) the most powerful IDEs for refactoring Ruby on Rails code?
Update: Netbeans 7
As suggested by Jörg W Mittag I've tried Netbeans 7 with the ruby plugin provided by the community. I have to say that this combination is much better than Aptana RadRails 2 or Aptana Studio 3 for developing Ruby on Rails apps. The integration of css and html for views is well done and the integration of rails tests into the JUnit Netbeans view comes in handy.
However, the refactoring support seems to be too basic. It supports rename, move, copy and safely delete of methods. It does not support to select lines of code and extract a method out of it nor the similar behaviour for extracting variables.
Update: RubyMine 3
dynex suggested to use RubyMine. I've just played around with it and think its suitability as an Ruby on Rails IDE is at least as good as Netbeans'. The refactor capabilities are by far the best I've seen in a Ruby on Rails IDE so far.
From what I've discovered it features renaming, moving, copying, safe deletion, method extractation, variable introduction, constant introduction, field introduction, parameter introduction, inlining, pulling members up, pushing members doen, module extraction and superclass extraction.
My conclusion is that from the set of IDEs I tested RubyMine was the only one with decent refactoring capabilities. RubyMine costs money, but it seems worth it. The free ones cannot compete regarding refactorings.
Thanks for all answers and comments.
RubyMine was my choice and I use refactoring once in a while. When using 'rename' it's never complete, but better than global-search-replace. Extraction etc works well.
Overall it's a great tool, albeit a memory hog, but I use it all the time now, especially for debugging.
I know, it costs money, but I wanted to put in a good word for them anyway...
Netbeans 7 seems not to support Ruby on Rails anymore
That's not true. Quite the opposite actually. Yes, Oracle dropped support for the Ruby on Rails plugin and gave maintenance over to the Ruby community. But the plugin is still available from the same place it was before, the community is still using the same infrastructure to develop, maintain and distribute the plugin as before. And since most of the people who originally wrote the plugin work for Google now, they can now again work on the code, now that it is no longer owned by the company that is suing their employer.
Thanks for this question firstly, coming from java platform I was not comfortable with the text editors or IDEs available for RoR. I just started using RubyMine for 2 days now and yes it has a reasonable support for refactoring compared to text mate editor. Apart from the other features mentioned here I like code formatting, column selection mode (especially for .haml files), I use Ctrl+Tab to browse between the tabs (as in Netbeans) and of course find usages. I am not yet comfortable with the git integration part yet, need to explore that. If I find anything amazing will update my post.

Thinking of moving from TextMate to vim for Rails dev. What do I need?

I do Ruby on Rails development pretty much exclusively. I currently develop in OS X using TextMate. I have a virtual machine running to emulate as closely as possible the environment my app will be deployed into, and I mount the code on a Samba share into OS X from the VM guest. From there I open with TextMate and code away.
I'm beginning to think that with the proper plugins and time spent learning, I could be much more productive in vim directly on the VM. Right now my TextMate is basically stock, though I do find the ProjectPlus plugin indispensable. What I'm looking for are some suggestions of vim resources and plugins (if that's the right terminology) to closely emulate the features I am unwilling to give up in TextMate. Or at least, compelling reasons why I should be willing to give them up. Here's a short list:
Ability to have a (preferably) collapsible project tree visible either at all times or easily toggle-able.
Ability to see SCM status at a glance, either within this project tree (preferable) or otherwise. (I use git almost exclusively if this makes any difference.)
Being able to view a side-by-side diff from within vim would be great too
Ability to search through the entire project at will (I suppose :stop; grep -nr; fg; would accomplish this, unless there's a better way to do it.)
Code completion, if possible
The NERD Tree plugin gives you a collapsible project tree. Personally, I find that the netrw plugin is more than sufficient, and this usually comes installed with Vim. Whereas the NERD tree feels as though it tries to emulate the behaviour of other IDEs (and TextMate's project drawer), I feel that the netrw plugin does things the Vim way. I suggest you try both out, and see which one you prefer.
The fugitive plugin provides a git interface to Vim (See Vimcasts: parts 1, 2, 3, 4 and 5).
The ack plugin is great for searching an entire project. You'll want to read up on Vim's quickfix list to get the most out of this.
TextMate's word completion is triggered with esc, and shift-esc. In Vim, you get similar autocomplete functionality using ctrl-n and ctrl-p in insert mode. Check :help ins-completion for (much!) more info.
I am running a series of screencasts about learning Vim over at vimcasts.org. My background is with TextMate, but I've been using Vim fulltime for a while now. As I write this, I'm only 6 episodes in, but I do plan on covering each of the points you've raised in future episodes. I'll try and come back to edit this answer with links to the screencasts as they become available.
And snipMate : TextMate-style snippets for Vim
I'm currently in a similar position to you (moving from TextMate to Vim)
One really good resource is this:
http://robots.thoughtbot.com/post/166073596/intro-rails-vim
Good luck with it!
For file navigation is simply love CommandT
This functions very much the same as the beloved commandT function in textmate.
You might want to start with my Ruby/Rails related vimfiles which includes support for rvm and git.
This screencast is great as well http://blip.tv/file/1372096
I do use VIM and i specially like how to rotate from model/view and controller related..
Check out the blog post: From Textmate to VIM for Rails coders.
The comments there may also valuable for you.
All of the other answers plus:
Ability to have a (preferably) collapsible project tree visible either at all times or easily toggle-able.
The project.vim plugin doesn't really work like TextMate's Project drawer but it's close.
With NERDTree, you can setup bookmarks and make it work a little like a project drawer.
:help mkview and :help mksession can help, too.
Ability to see SCM status at a glance, either within this project tree (preferable) or otherwise. (I use git almost exclusively if this makes any difference.)
vcscommand.vim provides the same set of commands for multiple SCMs, it works with Git, SVN, Mercurial…
You can use the aforementioned fugitive plugin to display the Git status in the status line, :help fugitive-statusline.
Being able to view a side-by-side diff from within vim would be great too
fugitive provides the :Gdiff command that does just that.
A recently released plugin called Gitv tries to emulate GitK in Vim. I like it a lot and the author is very responsive. In the tree view, hit <CR> to open a previous commit in another window and D to see a double diff.
Code completion, if possible
There are a few solutions, if you don't need it to be automatic <C-x><C-o>, <C-n> and <C-p> will be more than enough, if you want "autocompletion" you may try these few plugins. My favorite is autocomplpop.
Search an entire project here.
Code completion: Normally done with ctrl-X then ctrl-O while in insert mode.
Git Integration: git.vim
Project Tree: Nerdtree.vim
Good luck
I published an extended post on this topic today, in which I explain how to replicate 100 features from Textmate within VIM. It's the product of a great deal of hours research.
For example I explain:
How to replicate a Project Drawer
How to manage tabs
How to do Rails specific commands (Lets face it: A lot of Textmate users are Rails programmers)
How to do find and replaces
How to do project wide searches
Read Original Article: Textmate To VIM

Creating Plain .rb Files with Aptana RadRails

I have just bought a MacBook for some ruby development and like the look of Aptana Studio as a really nice IDE.
The question I have, however, is that I want to know (before getting too deep into it, and potentially wasting time) is can I create plain old .rb files without the rails framework attached? Also, can I execute the ruby file straight from the IDE, or will I have to use Terminal?
As I said, I am only just learning Ruby and I am working through some books I have bought, and while I do wish to get into rails soon, I feel its important to learn the language properly, before asking rails to do a lot of stuff for me.
Any other thoughts on best practices and other potential IDE's would also be appreciated.
For just fooling around with Ruby I suggested an editor, the command line, and IRB. You will have more fun and learn more, quicker.
After that, get into IDEs and Rails and all the complexity that comes with them.
I'd recommend Netbeans (Ruby Edition obviously) or Jetbrain's RubyMine over Aptana. I've had issues with Aptana and Ruby when I tried it. Rubymine is still in public preview release status, but it will be a paid product when it's released in a month or so. It's developed by the same people who made IntelliJ IDEA. Netbeans actually works very well with ruby and rails and it's free. Both allow you to execute ruby from within the IDE and have rails support.
I've also found irb very useful, Netbeans allows you to run irb from within the IDE as well. Having code completion and inline documentation helpful when starting out.
Yes, you can create plain old ".rb" files inside RadRails or Aptana Studio, and they don't have to be inside a Rails project or "attached to the rails framework". You can also run or debug a ruby script inside the IDE by right-clicking the file or inside the editor and choosing one of the Run As > Ruby Application or Debug as > Ruby Application entries. With Studio 3 you can even run them from an embedded Terminal view. RadRails 2.x had a Rails Shell where you could run or debug files from a command-line interface as well.
As the developer on RadRails, I'm a bit biased - but I would agree that users should be pretty familiar with using the command line whether they decide to use an IDE for daily programming or not. And of course, having an interactive REPL like irb to play with is another useful tool in getting started. Heck, you can even just use the online one first before installing ruby: http://tryruby.org/

What IDE to use for developing in Ruby on Rails on Windows? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What Ruby IDE do you prefer?
I've generally been doing stuff on Microsoft .NET out of college almost 2 years ago. I just started looking at Ruby on Rails. So what editor should I use? I'm using Notepad++ right now but can I get debugging etc. somehow?
Try both NetBeans and RadRails for maybe a week each, then you can find which works best for you. The best advice is to learn your tool. If you are not checking out something new about your editor, something that could potentially save you time (regexp, etc) then you are doing yourself a huge disservice.
I have been using Eclipse/Aptana/RadRails and unlike Gaius have been pretty happy with it.
I recommend the Eclipse IDE for Java Developers from Eclipse Downloads: http://www.eclipse.org/downloads/
Then grab Aptana Studio, following these instructions.
When Eclipse restarts Aptana will have a view, click on rad rails and you are good to go. Just make sure you have ruby installed already, or it becomes a pain to resolve.
Aptana Studio
I use it for all web development - HTML, CSS, PHP, JavaScript, Rails...
EDIT: For full disclosure, I'm biased toward Aptana and RadRails as I know a few members of the original RadRails dev team.
rubyMine is the most full featured IDE for Rails at the current time (2012).
Personally, for rails development I had used Eclipe for several months and then netBeans for several weeks and rubyMine is clearly better than them.
It's great in all the areas that count - code views, search and replace, source control management, testing, debugging and it's got features like viewing a model dependency diagram that are really neat.
It isn't free - cost about $50-$100. This has recently become a key positive criteria for me. Too many "free" products that I invest thousands of hours getting proficient in eventually die and stop being developed but paid products pay for continued development. I've become weary of investing a lot of time and energy into such products only to have them wither and die. Given the hundreds of thousands of dollars one earns from rails development a $100 tool is a bargain.
Despite how much I love rubyMine I still use vim along side it. Sometimes my tasks works better with vim, sometimes with rubyMine.
I've been very happy with E. It's pretty lightweight and supports TextMate snippets and commands, which means you get access to a huge set of Rails-specific helpers.
However, it is decidedly an editor and not an IDE, so you won't get debugging, built in console, etc. But I've found that for Rails projects I prefer a light editor and a shell (like Console) for tests, debugging, etc.
I've been using Aptana/Eclipse/RadRails, but if I were to do it again, I'd definitely try NetBeans. Aptana has been a major headache.
I've never used IronRuby, but that might make you feel more at home.
The Netbeans IDE is a good, all around editor for many languages. I'm pretty sure the 6.5 beta has support for Ruby on Rails, along with Javascript and a few other web languages. It's worth checking out (Netbeans.org).
Sapphire in Steel integrates with Visual Studio.
I mainly code ColdFusion or PHP (and JS/CSS/xHTML), but have dabbled in a bit of RoR. RadRails/Apatana has been great for me, because it's built on Eclipse, which I was already using for my other work. It also integrates with Subversion via the Subclipse plugin.
The Eclipse platform is so extensible that it's worth investing a bit of time in to learn, but then again I like having a single IDE rather than having to switch between different apps.
I briefly looked at Netbeans, but TBH Eclipse just felt better for me, and Aptana itself is great when you come to do anything in JavaScript.
YMMV...
I use Emacs on Windows.
Installing and configuring it to work with rails is a pain though.
I found Geany to be a lightweight alternative (which works on linux as well with little modification), although I am checking out Gedit for features that not present or implemented as well in Geany.

Resources