├── README.mdown └── xctheos.h /README.mdown: -------------------------------------------------------------------------------- 1 | # Xcode + Theos 2 | ## aka xctheos 3 | 4 | ### Intro 5 | Basically this is a crazy amount of abuse of the C Preprocessor to allow you to write stuff using [Theos / Logos](http://iphonedevwiki.net/index.php/Theos) inside Xcode. 6 | 7 | **Mostly works, but I'm pretty sure I haven't finished this yet. Sorta just fixing things as I go...** 8 | 9 | ### How do I xctheos? 10 | When compiling with theos be sure to add to your Makefile: 11 | ``` 12 | PROJECT_CFLAGS = -DUSE_THEOS 13 | ``` 14 | 15 | ``` 16 | #import "xctheos.h" 17 | 18 | #import 19 | #import 20 | 21 | // Instead of %group stuff 22 | GROUP(stuff) 23 | 24 | // Instead of %hook NSDate 25 | HOOK(NSDate) 26 | 27 | - (NSString *)description { 28 | return @"I'm not sure". 29 | } 30 | 31 | END() 32 | 33 | // OR 34 | 35 | // If you haven't declared a class yet 36 | HOOK_AND_DECLARE(SBApplicationController) 37 | 38 | - (NSString *)description { 39 | return @"Some application controller"; 40 | } 41 | 42 | END() 43 | 44 | END_GROUP() 45 | 46 | CTOR({ 47 | INIT(stuff) 48 | }) 49 | ``` 50 | 51 | In Xcode, you'll want to create a static library as a target, set your Tweak.xmi file as something to compile. In addition you'll want to (in the inspector) set its file type to Objective-C++. 52 | 53 | ### Why? 54 | Because Xcode. Also because I haven't written a plugin for Xcode to use theos as an external preprocessor. 55 | 56 | ### License? 57 | Pretty much the BSD license, just don't repackage it and call it your own please! 58 | 59 | Also if you do make some changes, feel free to make a pull request and help make things more awesome! 60 | 61 | ### Contact Info? 62 | Feel free to follow me on twitter: [@b3ll](https:///www.twitter.com/b3ll)! 63 | 64 | ### Special Thanks 65 | [@DHowett](https://www.twitter.com/dhowett) for writing theos! 66 | -------------------------------------------------------------------------------- /xctheos.h: -------------------------------------------------------------------------------- 1 | // 2 | // xctheos.h 3 | // Xcode|Theos 4 | // 5 | // Created by Adam Bell on 2014-03-24. 6 | // Copyright (c) 2014 Adam Bell. All rights reserved. 7 | // 8 | 9 | #ifdef __OBJC__ 10 | #define _STRING(stuff) #stuff 11 | #define STRING(stuff) _STRING(stuff) 12 | 13 | #define _CONCAT(stuff, otherstuff) stuff ## otherstuff 14 | #define CONCAT(stuff, otherstuff) _CONCAT(stuff, otherstuff) 15 | #define UNIQUE_SUFFIX(stuff) CONCAT(stuff, __COUNTER__) 16 | 17 | #ifdef __LOGOS_H 18 | #define CONFIG(stuff) %config(stuff) 19 | #define INIT(stuff) %init(stuff) 20 | #define GROUP(stuff) %group stuff 21 | #define END_GROUP() %end 22 | #define HOOK(stuff) %hook stuff 23 | #define HOOK_AND_DECLARE(stuff, superclass) %hook stuff 24 | #define NEW(...) %new 25 | #define END() %end 26 | #define ORIG(...) %orig(__VA_ARGS__) 27 | #define ORIG_T(...) %orig(__VA_ARGS__) 28 | #define GET_CLASS(stuff) %c(stuff) 29 | #define SUBCLASS(stuff, superclass) %subclass stuff : superclass 30 | #define END_SUBCLASS() %end 31 | #define CTOR(hax) %ctor hax 32 | #else 33 | #import 34 | 35 | #define CLANG_NO_U _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wobjc-protocol-method-implementation\"") _Pragma("clang diagnostic ignored \"-Wunused-function\"") 36 | #define CLANG_NO_U_END _Pragma("clang diagnostic pop") _Pragma("clang diagnostic pop") 37 | 38 | #define CONFIG(stuff) 39 | #define INIT(stuff) 40 | #define GROUP(stuff) 41 | #define END_GROUP() 42 | #define HOOK(stuff) CLANG_NO_U @interface stuff(UNIQUE_SUFFIX(hax)) @end @implementation stuff (UNIQUE_SUFFIX(hax)) 43 | #define HOOK_AND_DECLARE(stuff, superclass) CLANG_NO_U @interface stuff : superclass @end @implementation stuff 44 | #define NEW(...) 45 | #define END() @end CLANG_NO_U_END 46 | #define ORIG(...) nil 47 | #define ORIG_T(...) 0 48 | #define GET_CLASS(stuff) objc_getClass(STRING(stuff)) 49 | #define SUBCLASS(stuff, superclass) @interface stuff : superclass @end @implementation stuff 50 | #define END_SUBCLASS() @end 51 | #define CTOR(hax) CLANG_NO_U static void inline stuff() hax CLANG_NO_U_END 52 | #endif 53 | #endif 54 | --------------------------------------------------------------------------------