├── .gitignore ├── README.md ├── dizzle ├── swiftdizzle-Bridging-Header.h ├── swiftdizzle.c └── swiftdizzle.h ├── media └── ex.png ├── swiftdizzle.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── derekselander.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── derekselander.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── swiftdizzle ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift └── swiftdizzleTests ├── Info.plist └── swiftdizzleTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcbkptlist 2 | *.xcuserstate 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # swiftdizzle 2 | Swift method swizzling/method introspection for Swift instance methods 3 | 4 | Why should Objective-C's method Swizzling or C's DYLD interpose, or C's lazy stubs `__DATA.__la_symbol_ptr` get all the introspection fun? **swiftdizzle** is a nice little C function that can introspect pure Swift functions at runtime. 5 | 6 | 7 | ![yoink example](https://github.com/DerekSelander/swiftdizzle/raw/master/media/ex.png) 8 | 9 | 10 | In the above example, take note that `viewDidLoad()` is calling `someFunction()`, but `omagerdFunction()` is called instead. The potential infinite recursion of `omagerdFunction()` calling itself will actually call `someFunction()` instead. 11 | 12 | ## How to use swiftdizzle 13 | 14 | TODO 15 | 16 | ## How does swiftdizzle work? 17 | 18 | TODO 19 | -------------------------------------------------------------------------------- /dizzle/swiftdizzle-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "swiftdizzle.h" 6 | -------------------------------------------------------------------------------- /dizzle/swiftdizzle.c: -------------------------------------------------------------------------------- 1 | // 2 | // swiftdizzle.c 3 | // swiftdizzle 4 | // 5 | // Created by Derek Selander on 2/10/18. 6 | // Copyright © 2018 Razeware. All rights reserved. 7 | // 8 | 9 | #import "swiftdizzle.h" 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | #if __LP64__ 16 | #define FAST_DATA_MASK 0x00007ffffffffff8UL 17 | #else 18 | #define FAST_DATA_MASK 0xfffffffcUL 19 | #endif 20 | 21 | #define FAST_IS_SWIFT (1UL<<0) 22 | 23 | typedef struct class_ro_t { 24 | uint32_t flags; 25 | uint32_t instanceStart; 26 | uint32_t instanceSize; 27 | #ifdef __LP64__ 28 | uint32_t reserved; 29 | #endif 30 | 31 | const uint8_t * ivarLayout; 32 | 33 | const char * name; 34 | void * baseMethodList; // method_list_t 35 | void * baseProtocols; //protocol_list_t 36 | void * ivars; //ivar_list_t 37 | uint8_t * weakIvarLayout; // weakIvarLayout 38 | void *baseProperties; // property_list_t 39 | 40 | } class_ro_t; 41 | 42 | typedef struct class_rw_t { 43 | uint32_t flags; 44 | uint32_t version; 45 | 46 | const class_ro_t *ro; 47 | 48 | void* methods; // redefined from method_array_t 49 | void* properties; // redefined from property_array_t 50 | void* protocols; // redefined from protocol_array_t 51 | 52 | struct dsobjc_class* firstSubclass; 53 | struct dsobjc_class* nextSiblingClass; 54 | 55 | char *demangledName; 56 | 57 | } class_rw_t; 58 | 59 | typedef struct dsswift_class { 60 | struct dsobjc_class *isa; 61 | struct dsobjc_class *superclass; 62 | void *_buckets; 63 | void *maskAndOccupied; 64 | uintptr_t bits; 65 | uint32_t flags; 66 | uint32_t instanceAddressPoint; 67 | uint32_t instanceSize; 68 | uint16_t instanceAlignMask; 69 | uint16_t runtimeReservedBits; 70 | uint32_t classSize; 71 | uint32_t classAddressPoint; 72 | uintptr_t *typeDescriptor; 73 | uintptr_t *ivarDestroyer; 74 | uintptr_t *methods; 75 | } dsswift_class; 76 | 77 | BOOL rebind_swiftClass(const char *replacementClassName, const char *replacementMethod, const char *className, const char *method, BOOL shouldReplaceBoth) { 78 | Class cls = objc_getClass(className); 79 | if (!cls) { 80 | dprintf(STDERR_FILENO, "Couldn't find class for \"%s\"\n", className); 81 | return YES; 82 | } 83 | 84 | Class repl_cls = objc_getClass(replacementClassName); 85 | if (!repl_cls) { 86 | dprintf(STDERR_FILENO, "Couldn't find replacement class for \"%s\"\n", replacementClassName); 87 | return YES; 88 | } 89 | 90 | dsswift_class *swiftcls = (dsswift_class*)cls; 91 | if (!(swiftcls->bits & FAST_IS_SWIFT)) { 92 | dprintf(STDERR_FILENO, "Class \"%s\" is not a swift class\n", className); 93 | return YES; 94 | } 95 | 96 | dsswift_class *repl_swiftcls = (dsswift_class*)repl_cls; 97 | if (!(swiftcls->bits & FAST_IS_SWIFT)) { 98 | dprintf(STDERR_FILENO, "replacement class \"%s\" is not a swift class\n", replacementClassName); 99 | return YES; 100 | } 101 | 102 | 103 | uintptr_t* (^getAddressFromClass)(dsswift_class*, const char*) = ^uintptr_t*(dsswift_class* c, const char *method ){ 104 | 105 | unsigned long methodsAddress = (unsigned long)&c->methods; 106 | unsigned long endAddress = (unsigned long)c + c->classSize - c->classAddressPoint; 107 | size_t size = (endAddress - methodsAddress) / sizeof(uintptr_t*); 108 | 109 | for (int i = 0; i < size; i++) { 110 | Dl_info info = {}; 111 | uintptr_t * ptr = (uintptr_t*)methodsAddress; 112 | dladdr((void *)ptr[i], &info); 113 | if (info.dli_sname == NULL) { 114 | continue; 115 | } 116 | if (strcmp(info.dli_sname, method) == 0) { 117 | return &ptr[i]; 118 | } 119 | } 120 | return NULL; 121 | }; 122 | 123 | uintptr_t *repl_method_addr = getAddressFromClass(swiftcls, replacementMethod); 124 | if (!repl_method_addr) { 125 | dprintf(STDERR_FILENO, "Couldn't find replacement method \"%s\" for class \"%s\"\n", replacementMethod, replacementClassName); 126 | return YES; 127 | } 128 | 129 | uintptr_t *method_addr = getAddressFromClass(repl_swiftcls, method); 130 | if (!method_addr) { 131 | dprintf(STDERR_FILENO, "Couldn't find method \"%s\" for class \"%s\"\n", method, className); 132 | return YES; 133 | } 134 | 135 | 136 | if (repl_method_addr && method_addr) { 137 | uintptr_t tmp = *method_addr; 138 | *method_addr = *repl_method_addr; 139 | 140 | if (shouldReplaceBoth) { 141 | *repl_method_addr = tmp; 142 | } 143 | } 144 | 145 | 146 | return NO; 147 | 148 | } 149 | -------------------------------------------------------------------------------- /dizzle/swiftdizzle.h: -------------------------------------------------------------------------------- 1 | // 2 | // swiftdizzle.h 3 | // swiftdizzle 4 | // 5 | // Created by Derek Selander on 2/10/18. 6 | // Copyright © 2018 Razeware. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | BOOL rebind_swiftClass(const char *replacementClassName, const char *replacementMethod, const char *className, const char *method, BOOL shouldReplaceBoth); 13 | -------------------------------------------------------------------------------- /media/ex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DerekSelander/swiftdizzle/5fc24538f92fde938efff0926649ec1382c60aa6/media/ex.png -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A63427A4202FC39B0098A589 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A63427A3202FC39B0098A589 /* AppDelegate.swift */; }; 11 | A63427A6202FC39B0098A589 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A63427A5202FC39B0098A589 /* ViewController.swift */; }; 12 | A63427A9202FC39B0098A589 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A63427A7202FC39B0098A589 /* Main.storyboard */; }; 13 | A63427AB202FC39B0098A589 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A63427AA202FC39B0098A589 /* Assets.xcassets */; }; 14 | A63427AE202FC39B0098A589 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A63427AC202FC39B0098A589 /* LaunchScreen.storyboard */; }; 15 | A63427B9202FC39C0098A589 /* swiftdizzleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A63427B8202FC39C0098A589 /* swiftdizzleTests.swift */; }; 16 | A63427C7202FC4190098A589 /* swiftdizzle.c in Sources */ = {isa = PBXBuildFile; fileRef = A63427C6202FC4190098A589 /* swiftdizzle.c */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | A63427B5202FC39C0098A589 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = A6342798202FC39B0098A589 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = A634279F202FC39B0098A589; 25 | remoteInfo = swiftdizzle; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | A63427A0202FC39B0098A589 /* swiftdizzle.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = swiftdizzle.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | A63427A3202FC39B0098A589 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | A63427A5202FC39B0098A589 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 33 | A63427A8202FC39B0098A589 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 34 | A63427AA202FC39B0098A589 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | A63427AD202FC39B0098A589 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 36 | A63427AF202FC39B0098A589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | A63427B4202FC39C0098A589 /* swiftdizzleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = swiftdizzleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | A63427B8202FC39C0098A589 /* swiftdizzleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swiftdizzleTests.swift; sourceTree = ""; }; 39 | A63427BA202FC39C0098A589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | A63427C4202FC4190098A589 /* swiftdizzle-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "swiftdizzle-Bridging-Header.h"; sourceTree = ""; }; 41 | A63427C5202FC4190098A589 /* swiftdizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = swiftdizzle.h; sourceTree = ""; }; 42 | A63427C6202FC4190098A589 /* swiftdizzle.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = swiftdizzle.c; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | A634279D202FC39B0098A589 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | A63427B1202FC39C0098A589 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | A6342797202FC39B0098A589 = { 64 | isa = PBXGroup; 65 | children = ( 66 | A63427C3202FC4000098A589 /* dizzle */, 67 | A63427A2202FC39B0098A589 /* swiftdizzle */, 68 | A63427B7202FC39C0098A589 /* swiftdizzleTests */, 69 | A63427A1202FC39B0098A589 /* Products */, 70 | ); 71 | sourceTree = ""; 72 | }; 73 | A63427A1202FC39B0098A589 /* Products */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | A63427A0202FC39B0098A589 /* swiftdizzle.app */, 77 | A63427B4202FC39C0098A589 /* swiftdizzleTests.xctest */, 78 | ); 79 | name = Products; 80 | sourceTree = ""; 81 | }; 82 | A63427A2202FC39B0098A589 /* swiftdizzle */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | A63427A3202FC39B0098A589 /* AppDelegate.swift */, 86 | A63427A5202FC39B0098A589 /* ViewController.swift */, 87 | A63427A7202FC39B0098A589 /* Main.storyboard */, 88 | A63427AA202FC39B0098A589 /* Assets.xcassets */, 89 | A63427AC202FC39B0098A589 /* LaunchScreen.storyboard */, 90 | A63427AF202FC39B0098A589 /* Info.plist */, 91 | ); 92 | path = swiftdizzle; 93 | sourceTree = ""; 94 | }; 95 | A63427B7202FC39C0098A589 /* swiftdizzleTests */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | A63427B8202FC39C0098A589 /* swiftdizzleTests.swift */, 99 | A63427BA202FC39C0098A589 /* Info.plist */, 100 | ); 101 | path = swiftdizzleTests; 102 | sourceTree = ""; 103 | }; 104 | A63427C3202FC4000098A589 /* dizzle */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | A63427C5202FC4190098A589 /* swiftdizzle.h */, 108 | A63427C6202FC4190098A589 /* swiftdizzle.c */, 109 | A63427C4202FC4190098A589 /* swiftdizzle-Bridging-Header.h */, 110 | ); 111 | path = dizzle; 112 | sourceTree = ""; 113 | }; 114 | /* End PBXGroup section */ 115 | 116 | /* Begin PBXNativeTarget section */ 117 | A634279F202FC39B0098A589 /* swiftdizzle */ = { 118 | isa = PBXNativeTarget; 119 | buildConfigurationList = A63427BD202FC39C0098A589 /* Build configuration list for PBXNativeTarget "swiftdizzle" */; 120 | buildPhases = ( 121 | A634279C202FC39B0098A589 /* Sources */, 122 | A634279D202FC39B0098A589 /* Frameworks */, 123 | A634279E202FC39B0098A589 /* Resources */, 124 | ); 125 | buildRules = ( 126 | ); 127 | dependencies = ( 128 | ); 129 | name = swiftdizzle; 130 | productName = swiftdizzle; 131 | productReference = A63427A0202FC39B0098A589 /* swiftdizzle.app */; 132 | productType = "com.apple.product-type.application"; 133 | }; 134 | A63427B3202FC39C0098A589 /* swiftdizzleTests */ = { 135 | isa = PBXNativeTarget; 136 | buildConfigurationList = A63427C0202FC39C0098A589 /* Build configuration list for PBXNativeTarget "swiftdizzleTests" */; 137 | buildPhases = ( 138 | A63427B0202FC39C0098A589 /* Sources */, 139 | A63427B1202FC39C0098A589 /* Frameworks */, 140 | A63427B2202FC39C0098A589 /* Resources */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | A63427B6202FC39C0098A589 /* PBXTargetDependency */, 146 | ); 147 | name = swiftdizzleTests; 148 | productName = swiftdizzleTests; 149 | productReference = A63427B4202FC39C0098A589 /* swiftdizzleTests.xctest */; 150 | productType = "com.apple.product-type.bundle.unit-test"; 151 | }; 152 | /* End PBXNativeTarget section */ 153 | 154 | /* Begin PBXProject section */ 155 | A6342798202FC39B0098A589 /* Project object */ = { 156 | isa = PBXProject; 157 | attributes = { 158 | LastSwiftUpdateCheck = 0920; 159 | LastUpgradeCheck = 1010; 160 | ORGANIZATIONNAME = Razeware; 161 | TargetAttributes = { 162 | A634279F202FC39B0098A589 = { 163 | CreatedOnToolsVersion = 9.2; 164 | LastSwiftMigration = 1010; 165 | ProvisioningStyle = Automatic; 166 | }; 167 | A63427B3202FC39C0098A589 = { 168 | CreatedOnToolsVersion = 9.2; 169 | LastSwiftMigration = 1010; 170 | ProvisioningStyle = Automatic; 171 | TestTargetID = A634279F202FC39B0098A589; 172 | }; 173 | }; 174 | }; 175 | buildConfigurationList = A634279B202FC39B0098A589 /* Build configuration list for PBXProject "swiftdizzle" */; 176 | compatibilityVersion = "Xcode 8.0"; 177 | developmentRegion = en; 178 | hasScannedForEncodings = 0; 179 | knownRegions = ( 180 | en, 181 | Base, 182 | ); 183 | mainGroup = A6342797202FC39B0098A589; 184 | productRefGroup = A63427A1202FC39B0098A589 /* Products */; 185 | projectDirPath = ""; 186 | projectRoot = ""; 187 | targets = ( 188 | A634279F202FC39B0098A589 /* swiftdizzle */, 189 | A63427B3202FC39C0098A589 /* swiftdizzleTests */, 190 | ); 191 | }; 192 | /* End PBXProject section */ 193 | 194 | /* Begin PBXResourcesBuildPhase section */ 195 | A634279E202FC39B0098A589 /* Resources */ = { 196 | isa = PBXResourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | A63427AE202FC39B0098A589 /* LaunchScreen.storyboard in Resources */, 200 | A63427AB202FC39B0098A589 /* Assets.xcassets in Resources */, 201 | A63427A9202FC39B0098A589 /* Main.storyboard in Resources */, 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | }; 205 | A63427B2202FC39C0098A589 /* Resources */ = { 206 | isa = PBXResourcesBuildPhase; 207 | buildActionMask = 2147483647; 208 | files = ( 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXResourcesBuildPhase section */ 213 | 214 | /* Begin PBXSourcesBuildPhase section */ 215 | A634279C202FC39B0098A589 /* Sources */ = { 216 | isa = PBXSourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | A63427A6202FC39B0098A589 /* ViewController.swift in Sources */, 220 | A63427A4202FC39B0098A589 /* AppDelegate.swift in Sources */, 221 | A63427C7202FC4190098A589 /* swiftdizzle.c in Sources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | A63427B0202FC39C0098A589 /* Sources */ = { 226 | isa = PBXSourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | A63427B9202FC39C0098A589 /* swiftdizzleTests.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXSourcesBuildPhase section */ 234 | 235 | /* Begin PBXTargetDependency section */ 236 | A63427B6202FC39C0098A589 /* PBXTargetDependency */ = { 237 | isa = PBXTargetDependency; 238 | target = A634279F202FC39B0098A589 /* swiftdizzle */; 239 | targetProxy = A63427B5202FC39C0098A589 /* PBXContainerItemProxy */; 240 | }; 241 | /* End PBXTargetDependency section */ 242 | 243 | /* Begin PBXVariantGroup section */ 244 | A63427A7202FC39B0098A589 /* Main.storyboard */ = { 245 | isa = PBXVariantGroup; 246 | children = ( 247 | A63427A8202FC39B0098A589 /* Base */, 248 | ); 249 | name = Main.storyboard; 250 | sourceTree = ""; 251 | }; 252 | A63427AC202FC39B0098A589 /* LaunchScreen.storyboard */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | A63427AD202FC39B0098A589 /* Base */, 256 | ); 257 | name = LaunchScreen.storyboard; 258 | sourceTree = ""; 259 | }; 260 | /* End PBXVariantGroup section */ 261 | 262 | /* Begin XCBuildConfiguration section */ 263 | A63427BB202FC39C0098A589 /* Debug */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_ANALYZER_NONNULL = YES; 268 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_MODULES = YES; 272 | CLANG_ENABLE_OBJC_ARC = YES; 273 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_COMMA = YES; 276 | CLANG_WARN_CONSTANT_CONVERSION = YES; 277 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 279 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 280 | CLANG_WARN_EMPTY_BODY = YES; 281 | CLANG_WARN_ENUM_CONVERSION = YES; 282 | CLANG_WARN_INFINITE_RECURSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 285 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 289 | CLANG_WARN_STRICT_PROTOTYPES = YES; 290 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 291 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 292 | CLANG_WARN_UNREACHABLE_CODE = YES; 293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 294 | CODE_SIGN_IDENTITY = "iPhone Developer"; 295 | COPY_PHASE_STRIP = NO; 296 | DEBUG_INFORMATION_FORMAT = dwarf; 297 | ENABLE_STRICT_OBJC_MSGSEND = YES; 298 | ENABLE_TESTABILITY = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu11; 300 | GCC_DYNAMIC_NO_PIC = NO; 301 | GCC_NO_COMMON_BLOCKS = YES; 302 | GCC_OPTIMIZATION_LEVEL = 0; 303 | GCC_PREPROCESSOR_DEFINITIONS = ( 304 | "DEBUG=1", 305 | "$(inherited)", 306 | ); 307 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 308 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 309 | GCC_WARN_UNDECLARED_SELECTOR = YES; 310 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 311 | GCC_WARN_UNUSED_FUNCTION = YES; 312 | GCC_WARN_UNUSED_VARIABLE = YES; 313 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 314 | MTL_ENABLE_DEBUG_INFO = YES; 315 | ONLY_ACTIVE_ARCH = YES; 316 | SDKROOT = iphoneos; 317 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 318 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 319 | }; 320 | name = Debug; 321 | }; 322 | A63427BC202FC39C0098A589 /* Release */ = { 323 | isa = XCBuildConfiguration; 324 | buildSettings = { 325 | ALWAYS_SEARCH_USER_PATHS = NO; 326 | CLANG_ANALYZER_NONNULL = YES; 327 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_COMMA = YES; 335 | CLANG_WARN_CONSTANT_CONVERSION = YES; 336 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INFINITE_RECURSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 345 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 348 | CLANG_WARN_STRICT_PROTOTYPES = YES; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | CODE_SIGN_IDENTITY = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 356 | ENABLE_NS_ASSERTIONS = NO; 357 | ENABLE_STRICT_OBJC_MSGSEND = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu11; 359 | GCC_NO_COMMON_BLOCKS = YES; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 370 | VALIDATE_PRODUCT = YES; 371 | }; 372 | name = Release; 373 | }; 374 | A63427BE202FC39C0098A589 /* Debug */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | CLANG_ENABLE_MODULES = YES; 379 | CODE_SIGN_STYLE = Automatic; 380 | INFOPLIST_FILE = swiftdizzle/Info.plist; 381 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 382 | PRODUCT_BUNDLE_IDENTIFIER = com.selander.swiftdizzle; 383 | PRODUCT_NAME = "$(TARGET_NAME)"; 384 | SWIFT_OBJC_BRIDGING_HEADER = "dizzle/swiftdizzle-Bridging-Header.h"; 385 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 386 | SWIFT_VERSION = 4.2; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Debug; 390 | }; 391 | A63427BF202FC39C0098A589 /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | CLANG_ENABLE_MODULES = YES; 396 | CODE_SIGN_STYLE = Automatic; 397 | INFOPLIST_FILE = swiftdizzle/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = com.selander.swiftdizzle; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SWIFT_OBJC_BRIDGING_HEADER = "dizzle/swiftdizzle-Bridging-Header.h"; 402 | SWIFT_VERSION = 4.2; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | }; 405 | name = Release; 406 | }; 407 | A63427C1202FC39C0098A589 /* Debug */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 411 | BUNDLE_LOADER = "$(TEST_HOST)"; 412 | CODE_SIGN_STYLE = Automatic; 413 | INFOPLIST_FILE = swiftdizzleTests/Info.plist; 414 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 415 | PRODUCT_BUNDLE_IDENTIFIER = com.selander.swiftdizzleTests; 416 | PRODUCT_NAME = "$(TARGET_NAME)"; 417 | SWIFT_VERSION = 4.2; 418 | TARGETED_DEVICE_FAMILY = "1,2"; 419 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swiftdizzle.app/swiftdizzle"; 420 | }; 421 | name = Debug; 422 | }; 423 | A63427C2202FC39C0098A589 /* Release */ = { 424 | isa = XCBuildConfiguration; 425 | buildSettings = { 426 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 427 | BUNDLE_LOADER = "$(TEST_HOST)"; 428 | CODE_SIGN_STYLE = Automatic; 429 | INFOPLIST_FILE = swiftdizzleTests/Info.plist; 430 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 431 | PRODUCT_BUNDLE_IDENTIFIER = com.selander.swiftdizzleTests; 432 | PRODUCT_NAME = "$(TARGET_NAME)"; 433 | SWIFT_VERSION = 4.2; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swiftdizzle.app/swiftdizzle"; 436 | }; 437 | name = Release; 438 | }; 439 | /* End XCBuildConfiguration section */ 440 | 441 | /* Begin XCConfigurationList section */ 442 | A634279B202FC39B0098A589 /* Build configuration list for PBXProject "swiftdizzle" */ = { 443 | isa = XCConfigurationList; 444 | buildConfigurations = ( 445 | A63427BB202FC39C0098A589 /* Debug */, 446 | A63427BC202FC39C0098A589 /* Release */, 447 | ); 448 | defaultConfigurationIsVisible = 0; 449 | defaultConfigurationName = Release; 450 | }; 451 | A63427BD202FC39C0098A589 /* Build configuration list for PBXNativeTarget "swiftdizzle" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | A63427BE202FC39C0098A589 /* Debug */, 455 | A63427BF202FC39C0098A589 /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | A63427C0202FC39C0098A589 /* Build configuration list for PBXNativeTarget "swiftdizzleTests" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | A63427C1202FC39C0098A589 /* Debug */, 464 | A63427C2202FC39C0098A589 /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | /* End XCConfigurationList section */ 470 | }; 471 | rootObject = A6342798202FC39B0098A589 /* Project object */; 472 | } 473 | -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/project.xcworkspace/xcuserdata/derekselander.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DerekSelander/swiftdizzle/5fc24538f92fde938efff0926649ec1382c60aa6/swiftdizzle.xcodeproj/project.xcworkspace/xcuserdata/derekselander.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/xcuserdata/derekselander.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /swiftdizzle.xcodeproj/xcuserdata/derekselander.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swiftdizzle.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | swiftdizzle.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /swiftdizzle/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swiftdizzle 4 | // 5 | // Created by Derek Selander on 2/10/18. 6 | // Copyright © 2018 Razeware. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /swiftdizzle/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /swiftdizzle/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /swiftdizzle/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /swiftdizzle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /swiftdizzle/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // swiftdizzle 4 | // 5 | // Created by Derek Selander on 2/10/18. 6 | // Copyright © 2018 Razeware. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | rebind_swiftClass("swiftdizzle.ViewController", 17 | "$S11swiftdizzle14ViewControllerC12someFunctionyyF", 18 | "swiftdizzle.ViewController", 19 | "$S11swiftdizzle14ViewControllerC15omagerdFunctionyyF", 20 | true) 21 | print("In \(#function) about to call self.someFunction()...") 22 | self.someFunction() 23 | } 24 | 25 | func someFunction() { 26 | print(#function) 27 | } 28 | 29 | func omagerdFunction() { 30 | print(#function) 31 | self.omagerdFunction() 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /swiftdizzleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /swiftdizzleTests/swiftdizzleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swiftdizzleTests.swift 3 | // swiftdizzleTests 4 | // 5 | // Created by Derek Selander on 2/10/18. 6 | // Copyright © 2018 Razeware. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import swiftdizzle 11 | 12 | class swiftdizzleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------