Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra constraint to not load injection unless the main bundle is in derived data #52

Merged
merged 4 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/Shared/Injection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -116,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)
Expand All @@ -131,7 +136,6 @@ public class Injection {
swizzleCollectionViews = swizzling
swizzleCollectionViewLayouts = swizzling
self.animations = animations
handler?()
return self
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/iOS+tvOS/UIApplicationDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion Tests/macOS/NSApplicationDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion Vaccine.podspec
Original file line number Diff line number Diff line change
@@ -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.14.1"
s.homepage = "https://github.com/zenangst/Vaccine"
s.license = 'MIT'
s.author = { "Christoffer Winterkvist" => "[email protected]" }
Expand Down