Using MacRuby to Test iPhone Application? - iphone

I have an existing iPhone app, written in Objective-C, that I'd like to add some automated tests to. I've read this article about testing with MacRuby, which sounds great but it's aimed at testing desktop frameworks.
How can I add MacRuby tests to my iPhone app? The Ruby code doesn't recognize my Objective-C classes, and I don't know how to set it up to do that. Do I need to somehow point it at the compiled code or the headers?

rbiphonetest worked for me back in the iPhone OS 2 and 3.x days with regular ruby. It was fairly limited though. I haven't tried it with 4.x or macruby specifically.

MacRuby doesn't run on iOS, nor do I see that happening any time soon. I have been working on a port of Bacon (a Ruby rspec clone) to the Nu language: https://github.com/alloy/NuBacon. I still have to do some cleaning and write a blog post about it, I'll see if I can spare some time today to do so.

Related

iPhone app development without objective C

I have been learning objective C for about 3 weeks and I achived basic concepts but now I am trying to get hands on experience and since I dont own a mac Im trying realy hard with virtualization and have big problems (i succeeded only with snow leopard 10.5 which is version to old for xcode 3.2) nevermind, Im starting to wonder if other solution for iPhone development like phonegap, mobieOne are realy that bad? I know the native development is the best, but if you bulding application that use some menus and displays data from database is there sensible difference?
Consider trying RubyMotion. If you know Ruby of course. http://www.rubymotion.com/
Here's a macbook on eBay for 300$. Im sure its not the greatest computer in the world, but you should absolutely be using objective c for an iphone app.
http://www.ebay.ca/itm/Apple-Macbook-C2D-2-16-1-0-80-SnowLeopard-13-/160841255326?pt=Apple_Laptops&hash=item2572e2c99e#ht_1763wt_1163
Any time you lose in learning the language (which I agree was a bit of a long and frustrating process) you will gain back by using all of apple's documentation and the copious online tutorials. All the resources out there assume that you use Objective C.
I know its a slow process but invest in your future and do it the right way.
check these two:
Sencha Touch
Mono Touch
If you really wanna do serious iOS(could also be Mac OS X) development, you definitely wanna get a mac. You can use hackintosh on your pc, or download iso image of a modified Mac os x and run it on Virtual Machine (e.g: VMWare). However all you can find would be probably still limited. Last time when I looked on internet, I only found image file for snow leopard but soon Apple going to release mountain lion(which means the hacked Mac OS could be two generations behind).
You can use third party tools other than xcode to develop iOS apps. There are tons of them by using different languages such like C#, java, JavaScript,HTML5, but when they get complied and translated into a native iOS app, you will still need to have xcode running on a Mac.
Again, two things. First, I think you'd better have a mac, and if you don't, you need to find a way to get around it and you might not be able to catch the latest technologies(and that changes quite often in iOS!). Second, if you prefer to develop through a third party tool, it's depends on what languages you are most comfortable with. For C#, I recommend MonoTouch, and for JavaScript, I recommend SenchaTouch. You can find a lot of others.

Using MacRuby for developing iPhone apps

I'm looking to build an iPhone app, but I don't have enough time to learn Objective-C. I already know Ruby and discovered MacRuby. Is it possible to build an iPhone app using MacRuby alone, without any knowledge of Objective-C?
An answer to the question has been updated by RubyMotion:
RubyMotion is a revolutionary toolchain for iOS. It lets you quickly
develop and test native iOS applications for iPhone or iPad, all using
the awesome Ruby language you know and love.
This is a dupe of Can you use MacRuby to develop applications for the Mac App Store? (more or less).
Is it possible to build an iPhone app
using MacRuby alone, without any
knowledge of Objective-C?
In short, no.
All of the APIs (system frameworks), documentation, dev tools, examples, and the majority of the development community use Objective-C. You are going to have to know Objective-C through and through to be able to write an app against the iOS or Mac OS X system APIs anyway.
As well, the MacRuby runtime uses the Objective-C garbage collector that ships with Mac OS X. While porting that collector to iOS/ARM is likely not that hard (the source is available), the system frameworks don't support it; it won't work.
MacRuby is not yet ported to iOS.
An Apple engineer revealed on Twitter last September that work is being done to port MacRuby to iOS.
Until such a release sees the light of day, however, you will not be able to use MacRuby to write iOS apps.
Apple recently let it become known that MacRuby is to be included with the next release of OS X. It certainly looks like MacRuby may be on its way to becoming an Apple-blessed means of developing apps for OS X and iOS. One can only hope at this point, but these early indications are promising.

Do I need RubyCocoaBridge or MacRuby or both to develop in Ruby for the iPad?

I've heard both MacRuby and Ruby CocoaBridge discussed in relation to iPhone/iPad development in Ruby. Do I need one or both of these?
Neither of those will work. The only way is with Rhodes. CocoaBridge is sometimes used for testing, but can't run on an iPhone. MacRuby might be able to work one day if they add garbage collection to the iPhone OS, but it doesn't now.
Also, consider iPhone Wax, which uses Lua, a fairly ruby-like language.
As far as I know, there is no way to use Ruby on iPhone or iPad and won't be for the foreseeable future. At least if you want your app in the appstore. See this post
Can you develop native iPhone apps in Ruby?

Availability of older sample code for iPhone 2.2

We've been programming an iPhone application under iPhone OS 3.1, but the client has now decided he wants us to redo the existing codebase to run under 2.2. One of the nice pieces of built-in functionality we used under 3.1 was the UISearchDisplayController functionality for searching UITableViews, but that functionality was not available previously and I'm not sure how to create the equivalent code under 2.2 from scratch.
Long story short, does anyone know where I can obtain earlier sample code? The TableSearch example apparently existed under 2.2 and would likely be very useful to me, but I don't know how to obtain it. When I go to look online at the available Apple sample code, I'm redirected to the latest 3.1 versions, which don't do me any good.
Howard
I didn't have any luck tracking down that sample code either. You could try the wayback machine though.
Btw, just to give you some stats to take to your client. Currently > 75% of iPhone OS users are on 3.0 or better according to 3rd party sources. Writing code for <25% (and decreasing) of a market is generally not a good idea. It sticks you with code that is harder to maintain and test, etc., etc. I'm sure you know all this. Anyway, you should really see if you can convince them to drop 2.2.1 support.

Can you develop native iPhone apps in Ruby?

Hi I'm looking into iPhone development, and Objective-C is not be my preferred language. As far as I can see at this moment Ruby cannot be used to talk to Cocoa Touch at the moment on the iPhone.
So my question is, am I wrong? Can I use Ruby on the iPhone to develop Cocoa Touch applications. And what is the future looking like for Ruby on the iPhone?
Now you can with RubyMotion
In the iPhone OS, mprotect() will fail if you try to use it to mark writable sections of memory as executable. This breaks bridges like RubyCocoa (and probably MacRuby) that use libffi to create Objective-C method handlers at runtime. I believe that this is by design because it was not always the case.
Ultimately, this is more a matter of platform politics than technology, but a technical workaround for this exists. Instead of generating custom method handlers at runtime, precompile a pool of reconfigurable ones that are assigned as needed, essentially making the bridging process entirely data-driven. As far as I know, this is not yet being done in RubyCocoa or MacRuby.
Another significant thing to consider is that the compiled Ruby and RubyCocoa runtimes can be significantly larger than compiled Objective-C apps. If these libraries were available on the iPhone, this wouldn't be an issue, but for now, even if you had RubyCocoa working, you might not want to use it for apps that you distribute.
No, you are correct. Currently, and most likely for the foreseeable future, Ruby will not be an option, at least for AppStore applications. There's no reason you couldn't do this on a Jailbroken phone, but Apple is pretty wed to Objective C for official development.
You are better off as a programmer knowing a number of different languages - think of Objective-C as a good learning opportunity.
I've found that things you learn in other languages often make you a better programmer overall, and give you new insights into other languages you already know.
rhomobile is an option to run ruby code on the iPhone, but it's essentially web app development. A web server runs locally on the iPhone and your ruby code renders to standard client side web technologies (html/css/javascript).
http://rhomobile.com/
Actually, the ruby cocoa bridge isn't awkward at all; things work remarkably smoothly, right down to connecting outlets in IB etc. The resulting code is down right beautiful.
As for iPhone development, if you want an official AppStore application, you're out of luck unfortunately. Apple dictated that iPhone is Obj-C/Cocoa Touch, and there's a clause in the SDK license saying that one of the things they will reject an app for is having a language interpreter/JIT compiler, so you couldn't add a ruby interpreter in your app yourself.
Off topic, but hilariously, this is why Flash for the iPhone is Adobe blowing smoke. They couldn't get a swf player onto the AppStore even if they wanted to, per Apple's license.
Uh, Rhodes (Rhomobile) does allow you to do native apps on the iPhone and all other smartphones. Yes, we do leverage doing rendering via the WebUIView control. But we allow all device capabilities and synchronized local data.
You might want to take a look at shinycocos. It is a child project of cocos2d-iphone, an Objective-C game programming framework for iPhone.
I haven't yet played with it, but from the git README I infer that it bundles Ruby 1.9.1 into your app.
I installed the ruby package from Cydia on my iPod Touch 1G jailbroken on 3.1.3:
Seems to work.
Now as for cocoa-touch that is a whole different story I would assume.
Take a look at http://www.appcelerator.com/products/titanium-mobile/
"Native iPhone and Android apps built with Web technologies."
Sounds good isn't it ? ;-)
No you can not create iOS native app in Ruby.
There is only two options for native apps for mac and iOS:-
Objective C and Swift Programming Language
Tutorials:-
Apple's official tutorial on Objective C
Apple's official tutorial on Swift Programing Language
If you are familiar with Ruby and only want to create iOS apps by Ruby. Ruby Motion, can be a cross-platform option for you, but it is not free.
Cross-Platforms
RubyMotion
Xamarin required .net skills
appcelerator HTML,XML,CSS,JS skills required
phonegap HTML,XML,CSS,JS skills required
I imagine it won't work right now, but I'd imagine that you'll eventually be able to use MacRuby to build iphone apps. Apple are putting a lot of work into it
Here's a link to an ADC article describing how to build normal cocoa apps
You don't have to use Objective-C to write iPhone apps. If you use QuickConnectiPhone, http://sourceforge.net/projects/quickconnect/, you can write it completely in JavaScript, CSS, and HTML and still have an installable application not a web app.
If you know ruby you are probably working with JavaScript already.
To see how to install it, run it, and other ideas go to tetontech.wordpress.com
There's an open-source Ruby-Cocoa bridge you might try to get working. But I gather that there's a bit of an impedance mismatch between Ruby and ObjC that makes it a bit awkward to use.
The Ruby Cocoa bridge probably will not work. Most of the bridges for dynamic languages need to generate executable thunks (either manually or with libffi). More limited bridges (for more static languages) may not have such issues.
In either event, bringing up a bridge is probably going to require becoming more familiar with the Objective C runtime than one would just learning how to write Cocoa Touch apps, which probably defeats the point of doing it in the first place.
Currently isnt true, Apple change their policies, take a look at ShinyCocos, is a ruby bindings for the Cocos2D-iphone game framework.
https://github.com/funkaster/shinycocos
One possible solution would be to create an application wrapping for example the rice library (google it) which includes a ruby-vm. I reckon you would be able to create c++ wrappers that you could expose to ruby, thus making an environment for iphone development with ruby. This probably requires a lot of work though ^^