i know this question might be duplicate. i searched and tested a lot of code samples and librarys but still no good results.
the question is i want to do something like this in objective-c (ios): (its the idea , not the exact syntax)
NSString *Cmd=@" if (10>5) NSLog(@"Test"); ";
MyClass.Run(Cmd);
i expect that "Test" appear in Output Log.
after Researches, i Ended Up with these 2 libraries for compile in runtime:
1- libClang framework and clang_Cursor_Evaluate function .
2-objc-eval framework .
i could not do anything with libClang. and left it alone for now.
but with the secound one , i successfully compiled the framework and actualy used it in a simple project, however still no proper output!
#import <Foundation/Foundation.h>
#import "OEEvaluation.h"
void main()
{
Code1:OEEvaluation *evaluation = [OEEvaluation evaluationWithCode:@"retun @\"Hello World!\" ;" delegate:nil];
Code2://OEEvaluation *evaluation = [OEEvaluation evaluationWithCode:@"NSLog(@\"Hello World!\");" delegate:nil];
NSLog([evaluation evaluateSynchronously]);
NSLog(@"Test");
}
no output with Code1 and Code 2 . no (null) , no error, no hint.. nothing at all.
code 1 is the exact sample of the framework
maybe im wrong but i think the solutions i found are the closest Once to the answer between my researches.
now the questions are:
1- what is your suggestion to accomplish this idea (convert a string into an executable line of executable code)?
2-how to get the objc-eval.framework to work?
any tips,tuts, hints, link , sample code and guide will be appreciated. sorry for my bad english. thank you
Aucun commentaire:
Enregistrer un commentaire