Xcode, is it possible to intercept and modify code during assembly without updating the file? If so, how?

I need a way to intercept the code before it enters the compiler, modify it and let it remain the same in the / file in Xcode.

I thought the build scripts were a kind of thread interception, but that doesn't seem to be the case. Another method could be to run the script both before and after the build. Are there any consequences with this I should know?

----- EDIT -----

Why? I have an idea for an automatic logging system based on specific comment syntax. I want the assembly to be able to parse a specific line and replace it with a logging function, but the code remains unchanged. Is it possible?

----- UPDATE -----

It seems that a custom compiler may be a way forward, or at least a plugin that wraps the current LLVM clang. I studied this. Here's a related question for those interested: a custom Xcode compiler that wraps and passthru for clang

+1
source share
1 answer

"on build" , , Xcode , script. , . Automator , Automator , . 2 : . pre-run ( - ), , .

:

, Objective-C, main.mm(.mm, ++ Objective-C) ++. :

using namespace std // all  (this line is optional)
string s = ""; //      this
cin >> s; //           is C++  (if you omitted the optional line above, the correct code is std::cin >> s;
MainClass mc = //constructor for your "main class" here in Objective-C
if(s == someCertainString){ //hypothetical string and C++ condition checking for a C++ string
    [mc doThisACertainWay:];
}else if(s == someOtherString){ // again, hypothetical string that you need to declare
    [mc doThisADifferentWay];
}

, , , ++ Obj-C. , , , #include <iostream> , ++ / .

( , ), . ++, . ( theDialog), , , . theDialog ( tf). , , . . :

MainClass mc = // constructor here
NSString *str = [self.tf stringValue];
if([str equalsString:someString]){ // hypothetical string and possible error in the condition checking, I'm new to Obj-C
    [mc doThisInACertainWay];
} else {
    [mc doThisInADifferentWay];
}
+2

All Articles