3

I am writing a dev tool and I have no experience with Objective-C or Xcode, currently. I am trying make it cross platform and therefore, I will be using the native programming language for each platform that it supports. I am thinking about using Javascript for the user to script in. I am wondering if Objective-C is the best language for this or are there any better options for cross platform development. Though, please bear in mind that I can use different programming languages for the different platforms supported. I am thinking about using a Python and/or Java for the supported desktop platforms including Win, Mac, Linux. And Objective-C for iPhone and iPad.

To summarise my question, how can I use Javascript code in Objective-C, even if that means it uses third party libs. I don't mind it, if its compiled with Objective-C or interpreted. Compiled Javascript is probably preferable for better performance. Btw I only want to use objective-c for iOS.

4
  • Take a look at PhoneGap. Basically you create html apps and then phone gap will convert it to an xcode project. Commented Feb 21, 2014 at 15:42
  • Thanks. Is this the best option if I want to write my code in xcode but I also want to give the user scripting capabilities for Javascript. And those capabilities are not in the compiled app but in my dev tool. thanks Commented Feb 21, 2014 at 15:48
  • No I don't think so. To my knowledge the only way to integrate any javascript into xcode is via the UIWebView component (basically a web browser you drop into your app view). You can then catch the http requests from that webview in your view's viewcontroller. So you could do clever things from your html page in the webview, such as link to a bogus url: xcodeapp/call/myspecialcommand, then in your viewcontroller you inspect the url and see if it contains one of your commands in the url and then run the native code equivalent. Basically no easy way to truly use javascript here. Commented Feb 21, 2014 at 15:52
  • Thanks, I hope there is a better option though. Commented Feb 21, 2014 at 16:03

2 Answers 2

3

Did you see the links below?

1)Using JavaScript From Objective-C

2)Scripting with JavaScript in Cocoa

I think these will help you.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. This looks pretty nice.
Do you know if this will work on iOS? I know that Apple often has restrictions for things like this. Thanks
The first link is apple's programming guide. Means it is supporting.
0

I think these days there is the JavaScriptCore Framework that is provided by Apple.

The Apple documentation on how to use it isn't great but there is a wonderful article by NSHipster that gives step by step instructions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.