3

I'm simply looking for an online objective-c compiler. At the moment I have only found ideone.com but it shows errors for any Foundation (e.g NSObject) or UIKit (e.g UIView) classes.

Is there an online compiler for objective-c that can handle Foundation and UIKit classes? Failing that, how might I go about doing this myself on my own server?


EDIT:

As it seems there is no existing online compiler. I'm now asking for a how to guide to build my own online objective-c compiler on a server.

It needs to be able to take a file of code, compile it and output any errors and warnings. It must also be able to handle Foundation and UIKit classes by having access to the necessary frameworks.

I don't know any web-development languages so as much help as possible would be great!

Joshua
  • 15,200
  • 21
  • 100
  • 172
  • 1
    Why do you need this? What goal are you trying to accomplish? – Jonathan Grynspan Nov 07 '11 at 17:51
  • I would like to be able to compile code while I'm on the go on my iPad to check for errors or warnings. – Joshua Nov 07 '11 at 17:52
  • 1
    You'd better read the terms of your Apple developer agreement carefully before you try this. – Caleb Nov 07 '11 at 17:54
  • A cool idea but I suspect there's not a great solution framed like this. I'd recommend either using one of those apps that lets you screen-share with your Mac back home, or just getting a MacBook Air (those guys are tiny!). – Ben Zotto Nov 07 '11 at 18:00
  • @Caleb It's not for an app, just for compiling code on the internet. – Joshua Nov 07 '11 at 18:03
  • Just to make it clear: I **don't** want a iOS app, just a web service where I can compile code like ideone.com. – Joshua Nov 07 '11 at 18:06
  • @Joshua, I'm not talking about apps. IIRC there's language in the developer agreement that basically prevents you from sharing access to Apple's developer tools. If you're going to try to build a system that lets you compile code over the web, you should make sure to read and understand that portion of the agreement. – Caleb Nov 07 '11 at 19:40
  • @Caleb When you say 'developer tools' does that mean the Foundation and UIKit frameworks? – Joshua Nov 07 '11 at 19:43
  • @Joshua How you interpret your agreement is between you and Apple. I'm not saying that there's no way to do what you propose, just that before you start you should be aware of the conditions that you agreed to. – Caleb Nov 07 '11 at 19:53
  • @Joshua: Re: your comment on the bounty. If you'd take design suggestions on building your own such thing, I'd open a new question for it as this one really isn't asking that so people probably won't discuss an implementation. But it's an interesting enough project that some folks would probably happily chime in if you framed it as a how-could-I-do-this-myself. – Ben Zotto Nov 10 '11 at 01:43
  • @quixoto Thanks, I have taken your suggestions and have renamed the question and added some more information so it is now more focussed on how to build your own objective-c compiler on a server. – Joshua Nov 10 '11 at 06:44
  • Back in 2010, there was a compiler that did all this stuff and worked under Windows XP/7. It was showing errors/lines and was outputing a Cydia and an .IPA project. So it shouldn't have been a problem in '11 and '12. Sad nobody has been helpful at that time. – Léon Pelletier May 11 '13 at 18:27
  • FYI: http://www.pmbaty.com/iosbuildenv/ That's just doing everything the OP wants. Everything is done from a command-line, so you just catch the process standard output when using it as a web service. 5 minutes job. – Léon Pelletier May 11 '13 at 18:39
  • @LéonPelletier That looks good, but what command can be run from the command-line? – Joshua May 15 '13 at 16:53
  • Sorry didn't notice your message. The compilation process is a command-line. If you create a project using this SDK in Visual Studio, you'll see somewhere in your project (from the template) that a batch of shell commands are executed. This is basically something similar to a gcc compilation on linux, but in Windows, for Objective-C. It compiles using a folder containing IOS libs. It outputs everything you need to create any offline/online IOS compiler service/application. Frighting! And existing since a while. – Léon Pelletier May 23 '13 at 03:02
  • Actually, I just read carefully @Ben Zotto and my solution is the Windows-version and dirty way to achieve what he proposed. Haven't read about how all recent UI elements are compatible with pmbaty product, but you could use a Windows-based IOS development environment like Xamarin to code your stuff. – Léon Pelletier May 23 '13 at 03:12
  • @LéonPelletier Excellent, thanks Leon. Whereabouts in the project can I find the shell commands as I can't seem to see them for looking! – Joshua May 23 '13 at 17:17
  • I've used it two years ago but don't have it anymore. I guess it still works the same. As of 2011, November, according to the website, the author started to use clang/llvm instead of GCC, so search for any command line using it in the template files. Normally, in the project property or configuration, you're supposed to see some command-line used when building the project. If so, then there you go. – Léon Pelletier May 24 '13 at 00:47

4 Answers4

4

This question is interesting, but covers really a pretty broad ground. First step is to hone in on exactly what you're trying to create:

  • Is this something you want to hack together for your own use, or something you'd try to productize for others? The latter will of course have all sorts of concerns and requirements that the former probably doesn't.
  • Do you want the service to be like "online Xcode", able to manage a "project" of files and let you test out changes to individual ones? Or are you really just looking to paste a flat bunch of text (a .m file?) into a form and have the service compile it for you and show you the output?

Assuming you want something pretty rudimentary to start with (a form that can compile Obj-C but have Foundation and UIKit available to the compiler), you'd basically:

  • Have a web front end (PHP could be pretty simply used for this) that would show a form and POST the submission of the text of the form.
  • PHP takes the string of code, generates a temporary .m file on the server disk
  • PHP shells out to gcc, using the same build command as, say, a standard empty Xcode project. You'd need to take all the iOS SDK stuff and put it on your server so GCC could access it.
  • Take the gcc output and inject it into the response page.

How to do the PHP, and how to get the gcc stuff right are a little beyond the scope of this question, and depend on how comfortable you already are with the individual components. (As a commenter pointed out, it's worth being a little careful around any agreements you may have in place around usage of the iOS SDK materials, in particular if anyone besides yourself can use your service.)

Ben Zotto
  • 70,108
  • 23
  • 141
  • 204
  • Answers to your questions. It's something for my own use and **not** something I want to productize. I don't need it to be an online Xcode just to be able to take some text and compile it. What you go onto say is very good but I am not very competent in PHP. If you could point me in the right direction with PHP especially the shell side of things as I have pretty much no knowledge of PHP. – Joshua Nov 11 '11 at 22:02
  • You are going to need a server running Mac OS X, which you can rent for a monthly fee, but it isn't cheap. Compiling a UIKit based app cannot be done on a linux or windows server. The code to do it is relatively simple, but will be time consuming to get it exactly right. You should use @quixoto's instructions as a guide, and research/ask about each component individualy. – Abhi Beckert Nov 12 '11 at 09:31
  • Do I really need a server running Mac OS X just to compile a single file? Why is it not possible to compile a UIKit app on a linux server? – Joshua Nov 12 '11 at 10:42
  • @Joshua: Found this on using PHP to save a form input to a file: http://www.devshed.com/c/a/PHP/PHP-Form-to-Text-File-the-Basics/ Use the `system` command to shell out to gcc: http://php.net/manual/en/function.system.php (Whether and how you can get some form of the iOS toolchain running on a non-OS X system is beyond my knowledge.) – Ben Zotto Nov 12 '11 at 19:55
  • @quixoto Don't worry I've got it all sorted. I ended up saving the uploaded file to a permanent location, compiling it from there with the `shell_exec` command to shell out to `clang` whose command stores any output in a temporary log file. I then read the log file and display it. Here's a quick video: http://idzr.org/zjy5. Thanks very much for all your help! – Joshua Nov 13 '11 at 09:12
2

http://ideone.com/ http://www.compileonline.com/compile_objective-c_online.php or https://compilr.com/ (note : compilr is not free) the website has a objective c compiler. it is not good just test is not problem

click new code > choose objective-c > write your codes and click submit button.

the problem is that many ads in there but it is not important :))

warning if you do not choose private,your code seems on the website

enter image description here enter image description here

İbrahim Özbölük
  • 3,162
  • 23
  • 20
  • Unfortunately, as I've mentioned in my question "it shows errors for any Foundation (e.g NSObject) or UIKit (e.g UIView) classes". – Joshua May 19 '12 at 09:54
1

I know it's not really a full-fledged "web service", but you could use a web-based SSH client (or an app for whatever platform you're using) to SSH in to your mac back home and run clang/gcc from the command line, as well as vim or whatever command line text editor you choose. That's what I tended to do when I forgot to throw my CS projects onto dropbox and needed access from campus.

matthias
  • 2,419
  • 1
  • 18
  • 27
  • This isn't a bad idea but I am really looking for a way to do this on a web server so I don't have to rely on a mac back home. – Joshua Nov 12 '11 at 09:25
  • Just to add my grain of salt on another answer here, this method is working too. The answer could have been: "I used to compile via SSH, but you could have a server with IOS SDK and call it via a web service." If you see it from that angle, the solution is working, and simple. Then for more users, you scale it on several machines. All machines need to do is to compile. That's not really intensive on the CPU. – Léon Pelletier Jun 08 '13 at 17:11
0

What is your goal? To be able to test code snippets?

It's not online and it's not free, but you might check out CodeRunner. It's available through the Mac App Store, and it's like $5 or something. Basically, you can test code snippets in a variety of languages, including Objective-C. (I have no connection whatsoever to CodeRunner, by the way.)

If you are looking for Xcode alternatives to build iOS apps, I don't think you'll find any.

Mark Granoff
  • 16,878
  • 2
  • 59
  • 61
  • CodeRunner's looks good but unfortunately it's for Mac. I **don't** want a iOS app, just a web service where I can compile code like ideone.com. – Joshua Nov 07 '11 at 18:05