I know RubyMotion is relatively new, but I'd like to find out if it's possible/easy to use OpenGL ES with it before I buy a license to make an iOS game I've been planning for a while.
The reason I'm wondering is that I understand RubyMotion wraps all the Cocoa/Objective-C stuff but OpenGL on iOS is a set of C functions (glBegin(), glEnd(), etc.)
If anyone that purchased RubyMotion could help me out in finding out or point me to a piece of documentation, I'd be extremely grateful. Thank you.
Yes.
They have a working demo in the RubyMotionSample project https://github.com/HipByte/RubyMotionSamples/tree/master/HelloGL
Yes, it is. The official site says so.
Interfacing with C
You do not need to be a C programmer in order to use RubyMotion, however some basic notions, explained in this section, will be required.
Objective-C is a superset of the C language. Objective-C methods can therefore accept and return C types.
Also, while Objective-C is the main programming language used in the iOS SDK, some frameworks are only available in C APIs.
RubyMotion comes with an interface that allows Ruby to deal with the C part of APIs.
Related
I'm relatively new to Swift (I've tinkered with Python and HTML in the past)- but I'm currently working on an app with a group.
This app already exists as a desktop program written in Ada and we were hoping to port it over to Swift and put out an iPhone app.
My understanding is that I can (likely?) turn the Ada into C with a converter, then reference the C in Swift? Is this correct, or have I overlooked something due to not being familiar with the languages?
If correct, how would I go about actually executing this since I have little experience in Swift and C?
This is a pretty loaded question, so thank you for any help or insight!
edit: said desktop application is open source and available for all use- I do not intend on stealing anyone's work
I'm assuming that you can easily pull out the parts of the Ada program that you want to use in the iPhone program. If the code that you want to port over has other dependencies, then you have to make sure that you can get all of these dependencies for iOS as well. This may be extremely difficult for UI toolkits, if you use one.
To call foreign functions in Swift, you usually need to use a bridging header. Your target's bridging header contains C and Objective-C declarations of classes, functions and variables that Swift should be able to call into. As long as the language that you want to call into can export C-compatible bindings (which should be the case of Ada), then you will be able to call these bindings by declaring them in your bridging header.
If the part of the desktop Ada program that you want to use can easily be isolated in a library (static or dynamic), and you are capable of building that library as an ARM Mach-O library, then it's simply a matter of declaring the functions that you want to use from the library in your app's bridging header. You can refer to GNAT User's Guide for Native Platforms: Interfacing to C for the directives to use to expose an Ada function to C, and by exposing it to C, you're also exposing it to Swift. I'd try this first, as maintaining the almost-unmodified Ada source is almost certainly going to be easier than maintaining a mechanically-translated C version of the Ada source.
If that doesn't work, then yes, translating the Ada source to C code will also allow you to reference it from Swift. You will also have to ensure that the functions that you need to call are declared in your bridging header.
It looks like it used to be possible to compile Ada in Xcode when Xcode still supported the GCC compiler. That was removed a while ago.
If there are translators that will translate Ada to C then you could use C natively in an Objective-C iOS app. (Objective-C is a pure superset of C, meaning that all C code is also legal objective-C.)
Swift "plays nice" with C and Objective-C as long as you limit yourself to the types and classes that C and Objective-C understand, but inter-operating between Swift and C/Objective-C is somewhat tricky and tedious. You would have a fair amount of reading and study to do in order to learn how to build an app that uses both, on top of everything else you would need to learn.
Unless you're dealing with many thousands of lines of Ada code it might be better to find somebody who knows both Ada and Swift to translate the code for you, or for you to learn Swift and then translate it yourself.
Unfortunately, There is, at this time, no Ada compiler which targets iOS available to the public.
If you have cash to spend you could contact AdaCore for one, don’t expect it to be cheap though.
Believe me, there are some of us who would like to target iOS with Ada.
I am only aware of two Ada to C compilers, the most powerful one (AdaMagic) is now known as MapuSoft Ada-to-C/C++ changer. You'll need either Windows or Linux execution environment to run translator (Wine, Docker, etc. on macOS). Also, you'll need to limit yourself to Ada 95. AdaMagic is said to support a "subset of Ada 2005", but I am yet to stumble upon this subset. Also you'll need to port the runtime or a part of it. If you disable runtime checks, the amount of runtime required to port becomes lower, so it is up to you how much time you are willing to spend on it.
It has two modes of operation, either targeting C, or C++, I recommend C++ because throw-catch is a better match with modern Objective-C runtime (utilizing C++ ABI behind the scenes) than C setjmp/longjmp.
With some effort you'll get something up and running.
It is a pity Ada developers are so unaware of this option. Maybe somebody could find time to port AdaMagic to EmScripten, iOS, Elbrus or whatever essential target the humanity is missing to start mass Ada adoption.
Others advised producing Swift bindings from bridging headers, but IMO the winning strategy would be to write glue code in Objective-C++ hybrid. Objective-C++ will have access to both Swift code (viewed as external Objective-C classes) and Ada-to-C++ translated code. For instance, it will be able to catch C++ exceptions from Ada and throw Objective-C ones or vice versa.
Another compiler is GNAT CCG aka SPARK2C. It is designed to target embedded devices having no other Ada compiler. It supports recent Ada standards, but is very limited with regards to features requiring runtime. Basicly, there is no runtime. No runtime, no problem. Nothing to port. In this compiler one can return limited record from function (Ada 2005+ feature), but cannot have RAII, tasking, etc. I guess, that are far more strict requirements than Ada 95. GNAT CCG is not yet publicly available, but I expect it to appear before annual Make with Ada, otherwise that would be a very stupid situation.
Another options are Ada-to-Java or Ada-to-.NET, maybe they can work for your application better than others.
I want to learn in reasonable depth iOS socket programing with SWIFT.
I tried:
Apple documentation - its written for C++ and is overcomplicated (I learned Java socket programing in a week, this has so many things that are unnecessary)
Searched the forums on Stack, but looks like everyone is doing something different with CF or NS libraries.
This resource: http://swiftrien.blogspot.com/2015/10/socket-programming-in-swift-part-2.html - simply for me its overcomplicated.
Ray Wenderlich in https://www.raywenderlich.com/3932/networking-tutorial-for-ios-how-to-create-a-socket-based-iphone-app-and-server - is again doing C++ and is using 3rd party
and so on...
Is there some holly grail that has simple syntax like in Java, or am I doomed to work with some C++ things in my Swift code?
Thanks in advance.
Try looking at https://github.com/IBM-Swift/BlueSocket. This a cross platform framework for doing socket level programming in Swift.
I highly recommend you to use a socket framework to start with.
SwiftDSSocket is a framework written in pure Swift and I actively maintain this framework. It has really simple API and documents available as well as Demo.
Just a few questions which I can't find answers to anywhere:
To code games for IOS using Sprite Kit, do you also need to know Objective-C or Swift?
Can you code high quality games without knowing Objective-C or Swift?
Thanks!
SpriteKit is an Apple framework developed for Objective-C / Swift application. So, yes you'll need at least some code basics notions.
"Yes". You might be able to develop game with Unity2D for example, but that would include using another language to write your scripts.
I'll try to expand a little bit previous answer.
SpriteKit is an Apple framework developed for 2D/3D games. It uses Swift or Objective-C. Advantage of using this is that you can be 100% sure that this game will work flawlessly on iOS devices. Disadvantage is that you are locked only to iOS devices. If you have 0 knowledge of Swift or Objective-C, and you wish only to develop for iOS, I would choose Objective-C. It seems a little harder to learn and understand, but compared to Swift to it seems that Objective-C is still (and will be for long time) superior to Swift. Although, it just be my personal preference, because I truly hate Swift. (You can achieve same things in both languages) :)
I started this way, I do not regret.
You can develop games and apps for iOS without knowledge of Objective-C or Swift. You can use programs like Unity, Unreal engine, Corona, Cocos2D/3D. However these programs require learning another language to write your game (c++ or something else). You can also use GameSalad for 2D games. It requires 0 coding, many things are drag and drop, but you do need to understand logic behind it. For example, it wouldn't be programming but it would be coding :)
GameSalad is easy to learn, fun as well, but forget that you will be able to create any serious game logic or more advanced game than 2D platform one. I tried it, but very soon changed to Objective C and XCode.
If you decide to go with learning actual language (which I would strongly suggest), I would recommend either Objective-C or to learn Ionic software. Ionic uses javascript, but when you learn how to make games/apps you can easily distribute it to ANY platform: iOS, Windows mobile, Android...XCode is better software, but learning Ionic has huge advantage, and that is single click to deploy app on any platform.
Good luck.
Do I need to learn and convert my entire codebase to the new Swift language if I want to support ios 8?
No. The APIs available from Swift are exactly the same as the APIs available from Objective-C; you can code against any iOS 8 APIs from either language.
To start writing in Swift, there's an option called Migration. It will convert your existing code into swift code
Migration provides an opportunity to revisit an existing Objective-C
app and improve its architecture, logic, and performance by replacing
pieces of it in Swift. For a straightforward, incremental migration of
an app, you’ll be using the tools learned earlier—mix and match plus
interoperability. Mix-and-match functionality makes it easy to choose
which features and functionality to implement in Swift, and which to
leave in Objective-C.
NO.
Your Swift code can be run alongside your Objective-C code because Swift is built with the same compiler, ARC management and runtime as Objective-C.
I want to start developing for Mac and iPhone. I'm familiar with Objective-C a little and found it pretty complicated. Besides, I'm not sure that it would be worthwhile to learn it.
So it is possible to develop for Mac/iOS without knowing Objective-C, what programming languages do I have to use then? C++, C?
I like Scala, Java, by the way.
You can use c and c++ but you can't make any application without using objective - c. Since you need to use native app controllers and libraries.
Also in starting you find it difficult to learn obj-c because of it's syntaxes but after using them you are going to love it. So don't be scared and learn obj-c.
You can use some frameworks (e.g aapcelerator, phone gap)
but they are unable to give result like native app.
There are many frameworks you can use, like Mono where you can use C# (http://xamarin.com/monotouch) or some frameworks with HTML5 (see Creating native iOS/Android apps from HTML5)
But at the end basic understanding of objective-c and it's architecture will help you.
Why not? !!
But for iOS Native Development, you should learn objective C.
And if you want to develop using any other languages, you should use some other frameworks.
Haven't you heard about Sencha, jqueryMobile ,monotouch etc?
Once you get the hang of it Objective-c is actually quite fun.
Download some iOS samples and step through the code, that will greatly help you.
Or just create an empty project like a "Master/Detail" tableview app and see how it works.