Skip to content

Commit

Permalink
Refactor inject(tmpfile: String)
Browse files Browse the repository at this point in the history
Add new condition to match swift classes.

Co-Authored-By: John Holdsworth <[email protected]>
  • Loading branch information
zenangst and johnno1962 committed Mar 27, 2019
1 parent dac61ec commit 2741fcd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions InjectionBundle/SwiftInjection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ public class SwiftInjection: NSObject {
let classMetadata = unsafeBitCast(newClass, to: UnsafeMutablePointer<ClassMetadataSwift>.self)

// Is this a Swift class?
if (classMetadata.pointee.Data & 0x1) == 1 {
// Swift equivalent of Swizzling

let oldSwiftCondition = classMetadata.pointee.Data & 0x1 == 1
let newSwiftCondition = classMetadata.pointee.Data & 0x3 != 0
let isSwiftClass = newSwiftCondition || oldSwiftCondition
if isSwiftClass {
// Swift equivalent of Swizzling
if classMetadata.pointee.ClassSize != existingClass.pointee.ClassSize {
print("💉 ⚠️ Adding or removing methods on Swift classes is not supported. Your application will likely crash. ⚠️")
}
Expand Down

0 comments on commit 2741fcd

Please sign in to comment.