Interpret Objective-C scripts at run time on iPhone?

Do I need to load an object c script at run time and run it against classes / methods / objects / functions in the current iPhone application?

BASIC NOTE: The main reason I would like to do this is to allow me to quickly prototype the application, and then, after I finished the main prototyping phase, take the scripts I wrote and compiled them instead during build. I never plan on sending an application using an object c-interpreter.

I ask that I played with the iPhone wax , a lua interpreter that can be embedded in the iPhone application, and it works very well, in the sense that any object / method / function that is publicly available in Objective-C code automatically connects and available in lua.

This allows you to quickly prototype applications by simply creating the core of your application as lua files that are in the user docs directory. Just reload the application and you can test the changes in your lua files without rebuilding the application in Xcode - a big time saver!

But, having Apples at its disposal the latest 3.1.3 SDKs, it seemed to me that the safest way to do this type of rapid prototyping would be if you could use Objective-C as interpreted code ... Thus, the worst case scenario, you could just compile it into your application before its release. I heard that the lua source can be compiled into bytecode and linked at build time, but I think the safest thing would be if the source script was in lens c, not lua. So your source is always in lens c, whatever.

This makes me wonder (I searched, but didn't come up with anything) if there are examples of how to embed Objective-C Interpreter in an iPhone app? This will allow you to quickly prototype your application against the current classes that are embedded in your binary, and when you are going to deploy your application, instead of running the classes through the application interpreter, you compile them.

With iPad and OS 4, bluetooth and virtual keyboards can work with iPhones and iPads ... This will make this type of rapid prototyping something more useful, at least for dev time. If you have an interpreter built into your application and, for example, it is on an iPad, you can encode the interpreter during the journey without Xcode. And to me, the most useful way to return the source code to the state approved by the "apple" would be if the scripts were Objective C.

+6
objective-c objective-c-runtime iphone interpreter runtime
source share
8 answers

There is a basic Objective-C interpreter:

Check publication:

Is there an Objective-C Interpreter for Mac?

also:

http://forrst.com/posts/Beginnings_of_a_Objective_C_Interpreter-Tdl

+1
source share

Objective-C is actually just C with runtime and some syntactic sugar. This is a built-in language (I don’t think there are ready-made translators for C, although I can be wrong).

Xcode had a function called ZeroLink to speed up compilation time, but removed it in Xcode 3 because it caused too many errors.

+3
source share

This is not entirely impossible, but it would not be easy to do. Objective-C is usually not an interpreted language. This is not insurmountable - interpretation or compilation is just an implementation choice in most cases. For example, Ruby is traditionally considered an interpreted scripting language, but MacRuby compiles it into code in the same way as Objective-C. Thus, one could write an interpreter for Objective-C, but no one did. You have to write it yourself.

In addition, rules prohibit translators other than the Apple Javascript interpreter. So far this has not been applied in any way, but if you are trying to become a very straight arrow, then, unfortunately, the interpreted code is not used either.

+3
source share

Well, there are a couple of worthwhile points:

  • Why interpret Objective-C code when you can compile it? I understand the idea of β€‹β€‹β€œrapid prototyping,” but part of the reason for doing this, for example, in Lua, is because Lua is a much more complex language than Objective-C. I don't know if the interpretation of Objective-C will have that much bonus.
  • If you want to have plugins or dynamically loaded modules in your application, you can always compile them as a separate package and load them using NSBundle or a similar mechanism.
  • All that said, I do not know any Objective-C translator. You may have to write your own. I'm not sure if this will violate Apple's rules or not: it will be Objective-C code, but I thought that they have rules against the interpreted code. (I suppose they never assumed a hypothetical scenario in which Objective-C was interpreted.)
+2
source share

Ch is a commercial C / C ++ interpreter. This is done by SoftIntegration.

+1
source share

Not on an iPhone, but on a Simulator, you can do this using the Dynamic Code Embed Tool
http://dyci.github.com/

There is also another tool that works a little differently, but allows you to use the same functionality
http://injectionforxcode.com/

+1
source share

You should take a look at cycript . You can connect to applications, replace methods on the fly, change variables, you-name-it. It is a hybrid language between Objective-C and JavaScript. You will need to jailbreak your iDevice to install it.

+1
source share

Take a look at the documentation for objc_msgSend() and other parts of the Objective-C Runtime Reference . You can essentially parse the text and send it at run time.

0
source share

All Articles