From e12bbc0b84a68855ea4ad14768be2b462298e2e8 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Thu, 15 Nov 2018 19:27:34 +0100 Subject: [PATCH 1/4] Add extra constraint to not load injection unless the main bundle is in derived data --- Source/Shared/Injection.swift | 4 ++++ Vaccine.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Shared/Injection.swift b/Source/Shared/Injection.swift index afef11d..27f6fd3 100644 --- a/Source/Shared/Injection.swift +++ b/Source/Shared/Injection.swift @@ -86,6 +86,10 @@ public class Injection { return true } + if !Bundle.main.bundlePath.lowercased().contains("products/debug") { + return true + } + // Search for injection in the loaded bundles. var result: Bool = false for bundle in Bundle.allBundles { diff --git a/Vaccine.podspec b/Vaccine.podspec index e7f92b6..e4f8a92 100644 --- a/Vaccine.podspec +++ b/Vaccine.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Vaccine" s.summary = "Make your apps immune to recompile-disease." - s.version = "0.14.0" + s.version = "0.15.0" s.homepage = "https://github.com/zenangst/Vaccine" s.license = 'MIT' s.author = { "Christoffer Winterkvist" => "christoffer@winterkvist.com" } From 4be58701e629b8e95b0a4b1bcb453a3edeb6a707 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Thu, 15 Nov 2018 19:32:33 +0100 Subject: [PATCH 2/4] Call handler in defer --- Source/Shared/Injection.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shared/Injection.swift b/Source/Shared/Injection.swift index 27f6fd3..fcf49a4 100644 --- a/Source/Shared/Injection.swift +++ b/Source/Shared/Injection.swift @@ -120,6 +120,7 @@ public class Injection { @discardableResult public static func load(then handler: (() -> Void)? = nil, swizzling: Bool = true, animations: Bool = true) -> Injection.Type { + defer { handler?() } guard !Injection.isLoaded else { return self } #if targetEnvironment(simulator) || os(macOS) @@ -135,7 +136,6 @@ public class Injection { swizzleCollectionViews = swizzling swizzleCollectionViewLayouts = swizzling self.animations = animations - handler?() return self } From 7518f483d25e05d2209b23e75f6f932be828332f Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Thu, 15 Nov 2018 19:32:57 +0100 Subject: [PATCH 3/4] Change version number to 0.14.1 --- Vaccine.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vaccine.podspec b/Vaccine.podspec index e4f8a92..e0d8adb 100644 --- a/Vaccine.podspec +++ b/Vaccine.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Vaccine" s.summary = "Make your apps immune to recompile-disease." - s.version = "0.15.0" + s.version = "0.14.1" s.homepage = "https://github.com/zenangst/Vaccine" s.license = 'MIT' s.author = { "Christoffer Winterkvist" => "christoffer@winterkvist.com" } From 7b3bbbf9268a1782bf2d39940db9388db1d3e52f Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Thu, 15 Nov 2018 19:45:59 +0100 Subject: [PATCH 4/4] Fix tests --- Tests/iOS+tvOS/UIApplicationDelegateTests.swift | 2 +- Tests/macOS/NSApplicationDelegateTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/iOS+tvOS/UIApplicationDelegateTests.swift b/Tests/iOS+tvOS/UIApplicationDelegateTests.swift index 3f9291d..b348dd3 100644 --- a/Tests/iOS+tvOS/UIApplicationDelegateTests.swift +++ b/Tests/iOS+tvOS/UIApplicationDelegateTests.swift @@ -21,6 +21,6 @@ class UIApplicationDelegateTests: XCTestCase { Injection.load(then: applicationDelegate.loadInitialState) applicationDelegate.addInjection(with: #selector(ApplicationDelegateMock.injected(_:))) utilities.triggerInjection() - XCTAssertEqual(applicationDelegate.timesInvoked, 1) + XCTAssertEqual(applicationDelegate.timesInvoked, 2) } } diff --git a/Tests/macOS/NSApplicationDelegateTests.swift b/Tests/macOS/NSApplicationDelegateTests.swift index 4469915..9b6f8fe 100644 --- a/Tests/macOS/NSApplicationDelegateTests.swift +++ b/Tests/macOS/NSApplicationDelegateTests.swift @@ -21,6 +21,6 @@ class NSApplicationDelegateTests: XCTestCase { Injection.load(then: { applicationDelegate.loadInitialState() }) applicationDelegate.addInjection(with: #selector(ApplicationDelegateMock.injected(_:))) utilities.triggerInjection() - XCTAssertEqual(applicationDelegate.timesInvoked, 1) + XCTAssertEqual(applicationDelegate.timesInvoked, 2) } }