I have found a cool framework tcmportmapper for mapping the ports over NAT written in Objective-C (as a wrapper framework for some C libraries). I would like to use it in an iOS app, but so far I had little success building it with iOS SDK. Do you know some other framework with similar functionality for iOS or maybe some tips how one can compile a framework written for Cocoa for iOS ?
After some research I realized the functionality is actually included in the Bonjour libraries and it pretty much comes down to a single function DNSServiceNATPortMappingCreate. Works like charm, so after all no porting will be necessary I guess.
This question comes from this other one I asked earlier: Calling custom Objective-C from a pyobjc application?
I want to re-use a small part of the app logic from my iPhone app in its server-side component, which runs on OSX. Based on what I was told in the other question, it looks like I need to compile a "framework" for both iOS and OSX from this little piece of app logic.
If we assume that I am able to isolate all the code that is to be in this framework into a single .h/.m pair of files that has no other non-Cocoa dependencies, what would be the easiest way in XCode to build this framework for each architecture and avoid double-coding all this logic on the server?
I tried adding a new OSX framework build target to my iPhone project, but this doesn't get very far and XCode bails out pretty quickly with:
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform
Any help much appreciated, as I am currently dupe-implementing to keep things moving forward, but this is pretty obviously becoming a huge waste of time and source of errors when the implementations become slightly out-of-sync.
Depends on what you used in your custom class. If you did not use anything from UIKit / AppKit then the class is probably going to live well on either platform, otherwise, you’d have to use target conditionals and include separate code specially written for both platforms.
You can have multiple targets in one Xcode project, their Base SDK set separately for the Mac / iDevices.
Adam's comment to my original question answers this question. Although still interested to see if there is a way to do it all from a single XCode project, the solution I have now is plenty good enough for what I wanted to achieve.
Does mono touch allow you to do cross iPhone communication? (iPhones in the same room)
If so, what's the API?
Use the MonoTouch.GameKit API to communicate with other nearby iPhones. It is available in MonoTouch 1.1.1 (released on October 8th).
Here is an introduction to GameKit programming:
http://developer.apple.com/iPhone/library/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html
I would start here (MonoTouch API) and also reference this (MonoTouch Assemblies) which lists System.dll and includes the System.Net.Sockets namespace so some communication seems possible although I don't believe any of the interaction will be built for you. You might however be able to utilize and recompile some existing communication libraries using .NET against MonoTouch for distribution on the iPhone.
This is not a MonoTouch problem, it is a Cocoa Touch problem. Using MonoTouch really requires that you still learn Cocoa Touch as well.
What you want to use is the GameKit framework that is a zero-config local networks over bluetooth. There are no GameKit bindings for MonoTouch yet, so you must look into:
Learn the internals of MonoTouch.
Learn the internals of Objetive-C.
Use what you learned to write C# to Objective-C bindings for the GameKit framework.
As you might imagine, a faster solution is to skip MonoTouch for this use case, and go directly to Cocoa Touch where everything is already in place. Brace yourself and spend a few days learning Objective-C.
Note: This is the opposite direction to most similar questions!
I have an iPhone application which I would like to provide a demo of on the Mac. How hard is it to recompile (or rewrite) iPhone applications into Mac applications, assuming I intend to keep the same screen size, and not worry about making my application look "mac-like"?
Is it possible to distribute the iPhone simulator apple provides in the iPhone SDK with a copy of my application? Asking people to go and install it themselves seems like a major requirement.
On the whole most of the "core" frameworks are present on the Mac too. As a rule of thimb, any class starting NS will be present on the desktop - NSString, NSArray and NSObject etc. That hopefully means that all of your engine code will simply recompile and run.
The same is true of some middleware - all of iPhone Quartz will be present - classes and types starting CG... If you use 3D, there is OpenGL on the desktop but it is full OpenGL rather than the iPhone's OpenGL ES. There are some differences but your code will be pretty easy to port.
Where you will definitely need to recode is the UI. Not only because AppKit is not present but because the UI design you need for iPhone will generally not work on the desktop. The iPhone supports multitouch and does not have (meaningful) overlapping windows. Similarly, if you use any of the iPhone's hardware you will have to reimplement - the accelerometer and GPS are obviously not available on the desktop. In both these cases, the rule of thumb is that classes starting UI... are specific to the iPhone.
If you follow Apple's MVC design guidelines when you write your app, if will keep the UI related code well seperated from the engine code and porting should be easier.
First, you can't distribute the iPhone simulator. That's out of the question. The iPhone SDK agreement states:
You agree not to rent, lease, lend, upload to or host on any website or server, sell, redistribute, or sublicense the SDK, in whole or in part, or to enable others to do so.
You might be able to use parts of your program in the Mac version, but you'll probably have to rewrite UI-related code.
If your app is mostly OpenGL or custom views, probably not too hard at all. If your app using lots of UIKit views, then you will need to rewrite quite a bit to use the Mac standard Cocoa views instead. They are quite different.
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 ^^