From 1833160daf21abb580cb9eea6f84dd35f40c73e6 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Thu, 10 Aug 2017 20:41:40 +0300 Subject: [PATCH 01/17] implemented ability to add arguments to inject them to UIViewControllers --- Sources/SwinjectStoryboardExtensions.swift | 85 ++++++++++++++++++++ SwinjectStoryboard.xcodeproj/project.pbxproj | 8 ++ 2 files changed, 93 insertions(+) create mode 100644 Sources/SwinjectStoryboardExtensions.swift diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift new file mode 100644 index 0000000..1d66365 --- /dev/null +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -0,0 +1,85 @@ +// +// SwinjectStoryboardExtensions.swift +// SwinjectStoryboard +// +// Created by Malkevych Bohdan on 10.08.17. +// Copyright © 2017 Swinject Contributors. All rights reserved. +// + +import Swinject + +#if os(iOS) || os(OSX) || os(tvOS) + extension Container { + /// Adds a registration of the specified view or window controller that is configured in a storyboard. + /// + /// - Note: Do NOT explicitly resolve the controller registered by this method. + /// The controller is intended to be resolved by `SwinjectStoryboard` implicitly. + /// + /// - Parameters: + /// - controllerType: The controller type to register as a service type. + /// The type is `UIViewController` in iOS, `NSViewController` or `NSWindowController` in OS X. + /// - name: A registration name, which is used to differenciate from other registrations + /// that have the same view or window controller type. + /// - initCompleted: A closure to specifiy how the dependencies of the view or window controller are injected. + /// It is invoked by the `Container` when the view or window controller is instantiated by `SwinjectStoryboard`. + + public func storyboardInitCompletedArg(_ controllerType: C.Type, + name: String? = nil, initCompleted: @escaping (Resolver, C, Arg) -> ()) { + var arg: Arg! + let factory = { (_: Resolver, controller: Controller, + argLocal: Arg) -> Container.Controller in + arg = argLocal + return controller + } + + let option = SwinjectStoryboardOption(controllerType: controllerType) + + let wrappingClosure: (Resolver, Controller) -> () = { r, c in + initCompleted(r, c as! C, arg) + } + _register(Controller.self, factory: factory, name: name, option: option) + .initCompleted(wrappingClosure) + } + } +#endif + +extension SwinjectStoryboard { + + #if os(iOS) || os(tvOS) + + private func injectDependency(to viewController: UIViewController, arg: Arg) { + guard !viewController.wasInjected else { return } + defer { viewController.wasInjected = true } + + let registrationName = viewController.swinjectRegistrationName + + // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. + // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. + // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { + let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) + typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) } + } else { + fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") + } + + for child in viewController.childViewControllers { + injectDependency(to: child) + } + } + + public func instantiateViewController(withIdentifier identifier: String, + arg: Arg) -> UIViewController { + SwinjectStoryboard.pushInstantiatingStoryboard(self) + let viewController = super.instantiateViewController(withIdentifier: identifier) + SwinjectStoryboard.popInstantiatingStoryboard() + + injectDependency(to: viewController, arg: arg) + + return viewController + } + + #endif + +} diff --git a/SwinjectStoryboard.xcodeproj/project.pbxproj b/SwinjectStoryboard.xcodeproj/project.pbxproj index 08217fc..3679310 100644 --- a/SwinjectStoryboard.xcodeproj/project.pbxproj +++ b/SwinjectStoryboard.xcodeproj/project.pbxproj @@ -81,6 +81,9 @@ 98978E6A1DFC354B0046B966 /* UnavailableItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98978E671DFC354B0046B966 /* UnavailableItems.swift */; }; 98D562821CDB173500DECDC0 /* SwinjectStoryboard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98D562781CDB173500DECDC0 /* SwinjectStoryboard.framework */; }; 98D5629E1CDB19AB00DECDC0 /* SwinjectStoryboard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98D562941CDB19AB00DECDC0 /* SwinjectStoryboard.framework */; }; + B92E951F1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B92E951E1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift */; }; + B92E95201F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B92E951E1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift */; }; + B92E95211F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B92E951E1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift */; }; CD2C63AA1D7864840075BC14 /* SwinjectStoryboard+StoryboardReference.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2C63A91D7864840075BC14 /* SwinjectStoryboard+StoryboardReference.swift */; }; CD2C63AB1D7864840075BC14 /* SwinjectStoryboard+StoryboardReference.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2C63A91D7864840075BC14 /* SwinjectStoryboard+StoryboardReference.swift */; }; CD2C63AD1D786C1F0075BC14 /* RelationshipReference1.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD2C63AC1D786C1F0075BC14 /* RelationshipReference1.storyboard */; }; @@ -254,6 +257,7 @@ 98D562CA1CDB1E8800DECDC0 /* tvOS-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "tvOS-Base.xcconfig"; sourceTree = ""; }; 98D562CB1CDB1E8800DECDC0 /* tvOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "tvOS-Framework.xcconfig"; sourceTree = ""; }; 98D562CC1CDB1E8800DECDC0 /* tvOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "tvOS-StaticLibrary.xcconfig"; sourceTree = ""; }; + B92E951E1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwinjectStoryboardExtensions.swift; sourceTree = ""; }; CD2C63A91D7864840075BC14 /* SwinjectStoryboard+StoryboardReference.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwinjectStoryboard+StoryboardReference.swift"; sourceTree = ""; }; CD2C63AC1D786C1F0075BC14 /* RelationshipReference1.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference1.storyboard; sourceTree = ""; }; CD2C63AE1D786CD70075BC14 /* RelationshipReference2.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference2.storyboard; sourceTree = ""; }; @@ -456,6 +460,7 @@ 98978E671DFC354B0046B966 /* UnavailableItems.swift */, 985904091CDB0AA700275E4A /* SwinjectStoryboard.h */, 9859040B1CDB0AA700275E4A /* Info.plist */, + B92E951E1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift */, ); path = Sources; sourceTree = ""; @@ -906,6 +911,7 @@ 983DFF0B1CDB440800D39731 /* Box.swift in Sources */, 983DFEBE1CDB414900D39731 /* _SwinjectStoryboardBase.m in Sources */, 983DFEB41CDB410D00D39731 /* ViewController+Swinject.swift in Sources */, + B92E951F1F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -943,6 +949,7 @@ 983DFF0C1CDB440800D39731 /* Box.swift in Sources */, 983DFEC41CDB415300D39731 /* _SwinjectStoryboardBase.m in Sources */, 983DFEB51CDB410D00D39731 /* ViewController+Swinject.swift in Sources */, + B92E95201F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -981,6 +988,7 @@ 983DFF0D1CDB440800D39731 /* Box.swift in Sources */, 983DFEBF1CDB414900D39731 /* _SwinjectStoryboardBase.m in Sources */, 983DFEB61CDB410D00D39731 /* ViewController+Swinject.swift in Sources */, + B92E95211F3CCEAD0051FD3E /* SwinjectStoryboardExtensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 20085623afa367956d0153b5e8e871f224f6eaf9 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Thu, 10 Aug 2017 20:45:06 +0300 Subject: [PATCH 02/17] updated pod spec --- SwinjectStoryboard.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwinjectStoryboard.podspec b/SwinjectStoryboard.podspec index 8bff22e..14d19d0 100644 --- a/SwinjectStoryboard.podspec +++ b/SwinjectStoryboard.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.homepage = "https://github.com/Swinject/SwinjectStoryboard" s.license = 'MIT' s.author = 'Swinject Contributors' - s.source = { :git => "https://github.com/Swinject/SwinjectStoryboard.git", :tag => s.version.to_s } + s.source = { :git => "https://github.com/SeductiveMobile/SwinjectStoryboard.git", :tag => s.version.to_s } core_files = 'Sources/*.swift' umbrella_header_file = 'Sources/SwinjectStoryboard.h' # Must be at the end of 'source_files' to workaround CococaPods issue. From e182cbe875b40355892ed45013edbacf9faba190 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Thu, 10 Aug 2017 20:51:47 +0300 Subject: [PATCH 03/17] fixed acces control --- Sources/SwinjectStoryboard.swift | 44 +++++++++++++++++++++- Sources/SwinjectStoryboardExtensions.swift | 41 -------------------- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index 7d6e83d..d5bc225 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -87,7 +87,7 @@ public class SwinjectStoryboard: _SwinjectStoryboardBase, SwinjectStoryboardProt return viewController } - private func injectDependency(to viewController: UIViewController) { + fileprivate func injectDependency(to viewController: UIViewController) { guard !viewController.wasInjected else { return } defer { viewController.wasInjected = true } @@ -158,3 +158,45 @@ public class SwinjectStoryboard: _SwinjectStoryboardBase, SwinjectStoryboardProt } #endif + + +extension SwinjectStoryboard { + + #if os(iOS) || os(tvOS) + + private func injectDependency(to viewController: UIViewController, arg: Arg) { + guard !viewController.wasInjected else { return } + defer { viewController.wasInjected = true } + + let registrationName = viewController.swinjectRegistrationName + + // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. + // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. + // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { + let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) + typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) } + } else { + fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") + } + + for child in viewController.childViewControllers { + injectDependency(to: child) + } + } + + public func instantiateViewController(withIdentifier identifier: String, + arg: Arg) -> UIViewController { + SwinjectStoryboard.pushInstantiatingStoryboard(self) + let viewController = super.instantiateViewController(withIdentifier: identifier) + SwinjectStoryboard.popInstantiatingStoryboard() + + injectDependency(to: viewController, arg: arg) + + return viewController + } + + #endif + +} diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index 1d66365..2f0c60b 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -42,44 +42,3 @@ import Swinject } } #endif - -extension SwinjectStoryboard { - - #if os(iOS) || os(tvOS) - - private func injectDependency(to viewController: UIViewController, arg: Arg) { - guard !viewController.wasInjected else { return } - defer { viewController.wasInjected = true } - - let registrationName = viewController.swinjectRegistrationName - - // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. - // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. - // https://github.com/Swinject/Swinject/issues/10 - if let container = container.value as? _Resolver { - let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) } - } else { - fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") - } - - for child in viewController.childViewControllers { - injectDependency(to: child) - } - } - - public func instantiateViewController(withIdentifier identifier: String, - arg: Arg) -> UIViewController { - SwinjectStoryboard.pushInstantiatingStoryboard(self) - let viewController = super.instantiateViewController(withIdentifier: identifier) - SwinjectStoryboard.popInstantiatingStoryboard() - - injectDependency(to: viewController, arg: arg) - - return viewController - } - - #endif - -} From 6c8dddda8d5fa2190ae86b4daebaec3cb583bed4 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Fri, 11 Aug 2017 14:10:00 +0300 Subject: [PATCH 04/17] added 3 arguments to SwinjectStoryboard --- Sources/SwinjectStoryboard.swift | 71 ++++++++++++++++++++++ Sources/SwinjectStoryboardExtensions.swift | 45 +++++++++++++- 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index d5bc225..0ffb4e7 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -186,6 +186,53 @@ extension SwinjectStoryboard { } } + private func injectDependency(to viewController: UIViewController, arg1: Arg1, arg2: Arg2) { + guard !viewController.wasInjected else { return } + defer { viewController.wasInjected = true } + + let registrationName = viewController.swinjectRegistrationName + + // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. + // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. + // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { + let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) + typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2) } + } else { + fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") + } + + for child in viewController.childViewControllers { + injectDependency(to: child) + } + } + + private func injectDependency(to viewController: UIViewController, + arg1: Arg1, arg2: Arg2, arg3: Arg3) { + guard !viewController.wasInjected else { return } + defer { viewController.wasInjected = true } + + let registrationName = viewController.swinjectRegistrationName + + // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. + // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. + // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { + let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) + typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2, arg3) } + } else { + fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") + } + + for child in viewController.childViewControllers { + injectDependency(to: child) + } + } + + //MARK: - instantiateViewController with Args + public func instantiateViewController(withIdentifier identifier: String, arg: Arg) -> UIViewController { SwinjectStoryboard.pushInstantiatingStoryboard(self) @@ -197,6 +244,30 @@ extension SwinjectStoryboard { return viewController } + public func instantiateViewController(withIdentifier identifier: String, + arg1: Arg1, arg2: Arg2) -> UIViewController { + SwinjectStoryboard.pushInstantiatingStoryboard(self) + let viewController = super.instantiateViewController(withIdentifier: identifier) + SwinjectStoryboard.popInstantiatingStoryboard() + + injectDependency(to: viewController, arg1: arg1, arg2: arg2) + + return viewController + } + + public func instantiateViewController(withIdentifier identifier: String, + arg1: Arg1, arg2: Arg2, arg3: Arg3) -> UIViewController { + SwinjectStoryboard.pushInstantiatingStoryboard(self) + let viewController = super.instantiateViewController(withIdentifier: identifier) + SwinjectStoryboard.popInstantiatingStoryboard() + + injectDependency(to: viewController, arg1: arg1, arg2: arg2, arg3: arg3) + + return viewController + } + + + #endif } diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index 2f0c60b..2317726 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -32,11 +32,52 @@ import Swinject return controller } - let option = SwinjectStoryboardOption(controllerType: controllerType) - let wrappingClosure: (Resolver, Controller) -> () = { r, c in initCompleted(r, c as! C, arg) } + register(factory: factory, name: name) + } + + public func storyboardInitCompletedArgs(_ controllerType: C.Type, + name: String? = nil, + initCompleted: @escaping (Resolver, C, Arg1, Arg2) -> ()) { + var arg1: Arg1! + var arg2: Arg2! + let factory = { (_: Resolver, controller: Controller, + argLocal1: Arg1, argLocal2: Arg2) -> Container.Controller in + arg1 = argLocal1 + arg2 = argLocal2 + return controller + } + + let wrappingClosure: (Resolver, Controller) -> () = { r, c in + initCompleted(r, c as! C, arg1, arg2) + } + register(factory: factory, name: name) + } + + public func storyboardInitCompletedArgs(_ controllerType: C.Type, + name: String? = nil, + initCompleted: @escaping (Resolver, C, Arg1, Arg2, Arg3) -> ()) { + var arg1: Arg1! + var arg2: Arg2! + var arg3: Arg3! + let factory = { (_: Resolver, controller: Controller, + argLocal1: Arg1, argLocal2: Arg2, argLocal3: Arg3) -> Container.Controller in + arg1 = argLocal1 + arg2 = argLocal2 + arg3 = argLocal3 + return controller + } + + let wrappingClosure: (Resolver, Controller) -> () = { r, c in + initCompleted(r, c as! C, arg1, arg2, arg3) + } + register(factory: factory, name: name) + } + + private func register(factory: FactoryType, name: String?) { + let option = SwinjectStoryboardOption(controllerType: controllerType) _register(Controller.self, factory: factory, name: name, option: option) .initCompleted(wrappingClosure) } From fa8cd96742b12d684dec003642bc5bf0485ec243 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Fri, 11 Aug 2017 14:29:35 +0300 Subject: [PATCH 05/17] fixed bugs connected to passing 3 arguments to VC --- Sources/SwinjectStoryboard.swift | 42 +++++++--------------- Sources/SwinjectStoryboardExtensions.swift | 13 +++---- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index 0ffb4e7..8c9409a 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -169,10 +169,7 @@ extension SwinjectStoryboard { defer { viewController.wasInjected = true } let registrationName = viewController.swinjectRegistrationName - - // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. - // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. - // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller @@ -191,13 +188,10 @@ extension SwinjectStoryboard { defer { viewController.wasInjected = true } let registrationName = viewController.swinjectRegistrationName - - // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. - // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. - // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2) -> Container.Controller let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2) } } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") @@ -214,13 +208,10 @@ extension SwinjectStoryboard { defer { viewController.wasInjected = true } let registrationName = viewController.swinjectRegistrationName - - // Xcode 7.1 workaround for Issue #10. This workaround is not necessary with Xcode 7. - // If a future update of Xcode fixes the problem, replace the resolution with the following code and fix storyboardInitCompleted too. - // https://github.com/Swinject/Swinject/issues/10 + if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller + typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2, Arg3) -> Container.Controller let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2, arg3) } } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") @@ -235,39 +226,32 @@ extension SwinjectStoryboard { public func instantiateViewController(withIdentifier identifier: String, arg: Arg) -> UIViewController { - SwinjectStoryboard.pushInstantiatingStoryboard(self) - let viewController = super.instantiateViewController(withIdentifier: identifier) - SwinjectStoryboard.popInstantiatingStoryboard() - + let viewController = loadViewController(with: identifier) injectDependency(to: viewController, arg: arg) - return viewController } public func instantiateViewController(withIdentifier identifier: String, arg1: Arg1, arg2: Arg2) -> UIViewController { - SwinjectStoryboard.pushInstantiatingStoryboard(self) - let viewController = super.instantiateViewController(withIdentifier: identifier) - SwinjectStoryboard.popInstantiatingStoryboard() - + let viewController = loadViewController(with: identifier) injectDependency(to: viewController, arg1: arg1, arg2: arg2) - return viewController } public func instantiateViewController(withIdentifier identifier: String, arg1: Arg1, arg2: Arg2, arg3: Arg3) -> UIViewController { + let viewController = loadViewController(with: identifier) + injectDependency(to: viewController, arg1: arg1, arg2: arg2, arg3: arg3) + return viewController + } + + private func loadViewController(with identifier: String) -> UIViewController { SwinjectStoryboard.pushInstantiatingStoryboard(self) let viewController = super.instantiateViewController(withIdentifier: identifier) SwinjectStoryboard.popInstantiatingStoryboard() - - injectDependency(to: viewController, arg1: arg1, arg2: arg2, arg3: arg3) - return viewController } - - #endif } diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index 2317726..a41ff20 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -35,7 +35,9 @@ import Swinject let wrappingClosure: (Resolver, Controller) -> () = { r, c in initCompleted(r, c as! C, arg) } - register(factory: factory, name: name) + let option = SwinjectStoryboardOption(controllerType: controllerType) + _register(Controller.self, factory: factory, name: name, option: option) + .initCompleted(wrappingClosure) } public func storyboardInitCompletedArgs(_ controllerType: C.Type, @@ -53,7 +55,9 @@ import Swinject let wrappingClosure: (Resolver, Controller) -> () = { r, c in initCompleted(r, c as! C, arg1, arg2) } - register(factory: factory, name: name) + let option = SwinjectStoryboardOption(controllerType: controllerType) + _register(Controller.self, factory: factory, name: name, option: option) + .initCompleted(wrappingClosure) } public func storyboardInitCompletedArgs(_ controllerType: C.Type, @@ -73,13 +77,10 @@ import Swinject let wrappingClosure: (Resolver, Controller) -> () = { r, c in initCompleted(r, c as! C, arg1, arg2, arg3) } - register(factory: factory, name: name) - } - - private func register(factory: FactoryType, name: String?) { let option = SwinjectStoryboardOption(controllerType: controllerType) _register(Controller.self, factory: factory, name: name, option: option) .initCompleted(wrappingClosure) } + } #endif From ab284825dd93141eb160600c44e6aff8573fd0cb Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Fri, 11 Aug 2017 14:43:21 +0300 Subject: [PATCH 06/17] Updated Readme --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index e5ff2dc..1ebe4b1 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,30 @@ container.register(Animal.self) { _ in Cat(name: "Mimi") } If you implicitly instantiate `UIWindow` and its root view controller, the registrations setup for "Main" storyboard can be shared with the referenced storyboard since `defaultContainer` is configured in `setup` method. +### Arguments +if you want pass some arguments you can do in this way: + +1) Register VC +```swift +let container = SwinjectStoryboard.defaultContainer +container.storyboardInitCompleted(AnimalViewController.self) { r, c, arg1: Int, arg2: SomeValue in + c.animal = r.resolve(Animal.self) + c.countAnimals = arg1 + c.someValue = arg2 +} +container.register(Animal.self) { _ in Cat(name: "Mimi") } +``` + +2) Resolve VC +```swift +let sb = SwinjectStoryboard.create( + name: "Animals", bundle: nil, container: container) +let firstArg: Int = 5 +let secondArg: SomeValue = SomeValue() +let catController = sb.instantiateViewController(withIdentifier: "SomeIdentifier", arg1: firstArg, arg2: secondArg) as! AnimalViewController +``` + + ## Credits SwinjectStoryboard is inspired by: From f582e1b7190a3a4d504b361a076a7323c4f697a9 Mon Sep 17 00:00:00 2001 From: Malkevych Bohdan Date: Fri, 11 Aug 2017 14:51:02 +0300 Subject: [PATCH 07/17] Fixed readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ebe4b1..497579f 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ container.register(Animal.self) { _ in Cat(name: "Mimi") } If you implicitly instantiate `UIWindow` and its root view controller, the registrations setup for "Main" storyboard can be shared with the referenced storyboard since `defaultContainer` is configured in `setup` method. ### Arguments -if you want pass some arguments you can do in this way: +if you want to pass some arguments, you can do it in such way: 1) Register VC ```swift From 7cfd87ea1993d0ad48c859c517ca92814857afdf Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Mon, 30 Jul 2018 23:42:23 +0300 Subject: [PATCH 08/17] Fixed arguments retaining while using 'storyboardInitCompletedArgs' family methods. --- Sources/SwinjectStoryboardExtensions.swift | 46 ++++++---------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index a41ff20..fa413f3 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -25,62 +25,40 @@ import Swinject public func storyboardInitCompletedArg(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg) -> ()) { - var arg: Arg! - let factory = { (_: Resolver, controller: Controller, - argLocal: Arg) -> Container.Controller in - arg = argLocal - return controller - } - - let wrappingClosure: (Resolver, Controller) -> () = { r, c in + let factory = { (r: Resolver, c: Controller, + arg) -> Container.Controller in initCompleted(r, c as! C, arg) + return c } + let option = SwinjectStoryboardOption(controllerType: controllerType) _register(Controller.self, factory: factory, name: name, option: option) - .initCompleted(wrappingClosure) } public func storyboardInitCompletedArgs(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg1, Arg2) -> ()) { - var arg1: Arg1! - var arg2: Arg2! - let factory = { (_: Resolver, controller: Controller, - argLocal1: Arg1, argLocal2: Arg2) -> Container.Controller in - arg1 = argLocal1 - arg2 = argLocal2 - return controller - } - - let wrappingClosure: (Resolver, Controller) -> () = { r, c in + let factory = { (r: Resolver, c: Controller, + arg1: Arg1, arg2: Arg2) -> Container.Controller in initCompleted(r, c as! C, arg1, arg2) + return c } + let option = SwinjectStoryboardOption(controllerType: controllerType) _register(Controller.self, factory: factory, name: name, option: option) - .initCompleted(wrappingClosure) } public func storyboardInitCompletedArgs(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg1, Arg2, Arg3) -> ()) { - var arg1: Arg1! - var arg2: Arg2! - var arg3: Arg3! - let factory = { (_: Resolver, controller: Controller, - argLocal1: Arg1, argLocal2: Arg2, argLocal3: Arg3) -> Container.Controller in - arg1 = argLocal1 - arg2 = argLocal2 - arg3 = argLocal3 - return controller - } - - let wrappingClosure: (Resolver, Controller) -> () = { r, c in + let factory = { (r: Resolver, c: Controller, + arg1: Arg1, arg2: Arg2, arg3: Arg3) -> Container.Controller in initCompleted(r, c as! C, arg1, arg2, arg3) + return c } + let option = SwinjectStoryboardOption(controllerType: controllerType) _register(Controller.self, factory: factory, name: name, option: option) - .initCompleted(wrappingClosure) } - } #endif From f9267d202f0e90fd093f68aab1d14e6aa25acab0 Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Tue, 31 Jul 2018 00:11:53 +0300 Subject: [PATCH 09/17] Fixed missed argument type. --- Sources/SwinjectStoryboardExtensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index fa413f3..bd5108f 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -26,7 +26,7 @@ import Swinject public func storyboardInitCompletedArg(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg) -> ()) { let factory = { (r: Resolver, c: Controller, - arg) -> Container.Controller in + arg: Arg) -> Container.Controller in initCompleted(r, c as! C, arg) return c } From ffd633009abd247c06d62a6c66132e9f94d5ca81 Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Tue, 31 Jul 2018 02:05:12 +0300 Subject: [PATCH 10/17] Fix compilation on OSX --- Cartfile.resolved | 4 +- Sources/SwinjectStoryboard.swift | 16 ++-- SwinjectStoryboard.xcodeproj/project.pbxproj | 81 +++++++------------- 3 files changed, 36 insertions(+), 65 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 9a803c0..db37aa7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1 @@ -github "Quick/Nimble" "v6.1.0" -github "Quick/Quick" "v1.1.0" -github "Swinject/Swinject" "2.1.0" +github "Swinject/Swinject" "2.4.1" diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index 8c9409a..07c211a 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -98,8 +98,8 @@ public class SwinjectStoryboard: _SwinjectStoryboardBase, SwinjectStoryboardProt // https://github.com/Swinject/Swinject/issues/10 if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller) -> Container.Controller - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController) } + typealias FactoryType = (Resolver, Container.Controller) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -172,8 +172,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg) -> Container.Controller - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) } + typealias FactoryType = (Resolver, Container.Controller, Arg) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -191,8 +191,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2) -> Container.Controller - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2) } + typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -211,8 +211,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2, Arg3) -> Container.Controller - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2, arg3) } + typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2, Arg3) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2, arg3) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } diff --git a/SwinjectStoryboard.xcodeproj/project.pbxproj b/SwinjectStoryboard.xcodeproj/project.pbxproj index 3679310..6df209c 100644 --- a/SwinjectStoryboard.xcodeproj/project.pbxproj +++ b/SwinjectStoryboard.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 55640989210FCFD600AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; 983DFEA51CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA61CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA71CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; @@ -112,24 +113,6 @@ CD6073911EBB3E8C00BE2167 /* Storyboard1.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073901EBB3E8C00BE2167 /* Storyboard1.storyboard */; }; CD6073931EBB3F1400BE2167 /* RelationshipReference2.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073921EBB3F1400BE2167 /* RelationshipReference2.storyboard */; }; CD6073951EBB3F6200BE2167 /* RelationshipReference1.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073941EBB3F6200BE2167 /* RelationshipReference1.storyboard */; }; - CDA864931EA9F17A00293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864921EA9F17A00293FEC /* Swinject.framework */; }; - CDA864951EA9F19400293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864941EA9F19400293FEC /* Swinject.framework */; }; - CDA864971EA9F1A000293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864961EA9F1A000293FEC /* Swinject.framework */; }; - CDA8649A1EA9F1B600293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864981EA9F1B600293FEC /* Nimble.framework */; }; - CDA8649B1EA9F1B600293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864991EA9F1B600293FEC /* Quick.framework */; }; - CDA864A41EA9F22900293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864981EA9F1B600293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864A51EA9F22900293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864991EA9F1B600293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864A81EA9F23200293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864921EA9F17A00293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864AB1EA9F25C00293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864AA1EA9F25C00293FEC /* Quick.framework */; }; - CDA864AE1EA9F27100293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864AA1EA9F25C00293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B01EA9F27200293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864941EA9F19400293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B21EA9F28E00293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B11EA9F28E00293FEC /* Nimble.framework */; }; - CDA864B31EA9F29100293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B11EA9F28E00293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B61EA9F29E00293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B41EA9F29E00293FEC /* Nimble.framework */; }; - CDA864B71EA9F29E00293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B51EA9F29E00293FEC /* Quick.framework */; }; - CDA864B91EA9F2A600293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B41EA9F29E00293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864BA1EA9F2A600293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B51EA9F29E00293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864BB1EA9F2AA00293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864961EA9F1A000293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -163,9 +146,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - CDA864A41EA9F22900293FEC /* Nimble.framework in CopyFiles */, - CDA864A51EA9F22900293FEC /* Quick.framework in CopyFiles */, - CDA864A81EA9F23200293FEC /* Swinject.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -175,9 +155,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - CDA864B31EA9F29100293FEC /* Nimble.framework in CopyFiles */, - CDA864AE1EA9F27100293FEC /* Quick.framework in CopyFiles */, - CDA864B01EA9F27200293FEC /* Swinject.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -187,15 +164,13 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - CDA864B91EA9F2A600293FEC /* Nimble.framework in CopyFiles */, - CDA864BA1EA9F2A600293FEC /* Quick.framework in CopyFiles */, - CDA864BB1EA9F2AA00293FEC /* Swinject.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 55640987210FCFCC00AFFA8F /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/iOS/Swinject.framework; sourceTree = ""; }; 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Container+SwinjectStoryboard.swift"; sourceTree = ""; }; 983DFEA01CDB410D00D39731 /* Storyboard+Swizzling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Storyboard+Swizzling.swift"; sourceTree = ""; }; 983DFEA11CDB410D00D39731 /* SwinjectStoryboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwinjectStoryboard.swift; sourceTree = ""; }; @@ -281,15 +256,6 @@ CD6073901EBB3E8C00BE2167 /* Storyboard1.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard1.storyboard; sourceTree = ""; }; CD6073921EBB3F1400BE2167 /* RelationshipReference2.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference2.storyboard; sourceTree = ""; }; CD6073941EBB3F6200BE2167 /* RelationshipReference1.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference1.storyboard; sourceTree = ""; }; - CDA864921EA9F17A00293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/iOS/Swinject.framework; sourceTree = ""; }; - CDA864941EA9F19400293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/Mac/Swinject.framework; sourceTree = ""; }; - CDA864961EA9F1A000293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/tvOS/Swinject.framework; sourceTree = ""; }; - CDA864981EA9F1B600293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = ""; }; - CDA864991EA9F1B600293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = ""; }; - CDA864AA1EA9F25C00293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = ""; }; - CDA864B11EA9F28E00293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = ""; }; - CDA864B41EA9F29E00293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/tvOS/Nimble.framework; sourceTree = ""; }; - CDA864B51EA9F29E00293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/tvOS/Quick.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -297,7 +263,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA864931EA9F17A00293FEC /* Swinject.framework in Frameworks */, + 55640989210FCFD600AFFA8F /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -305,8 +271,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA8649A1EA9F1B600293FEC /* Nimble.framework in Frameworks */, - CDA8649B1EA9F1B600293FEC /* Quick.framework in Frameworks */, 985904111CDB0AA700275E4A /* SwinjectStoryboard.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -315,7 +279,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA864951EA9F19400293FEC /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -323,8 +286,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA864B21EA9F28E00293FEC /* Nimble.framework in Frameworks */, - CDA864AB1EA9F25C00293FEC /* Quick.framework in Frameworks */, 98D562821CDB173500DECDC0 /* SwinjectStoryboard.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -333,7 +294,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA864971EA9F1A000293FEC /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -341,8 +301,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDA864B61EA9F29E00293FEC /* Nimble.framework in Frameworks */, - CDA864B71EA9F29E00293FEC /* Quick.framework in Frameworks */, 98D5629E1CDB19AB00DECDC0 /* SwinjectStoryboard.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -613,15 +571,7 @@ CDA864911EA9F17900293FEC /* Frameworks */ = { isa = PBXGroup; children = ( - CDA864B41EA9F29E00293FEC /* Nimble.framework */, - CDA864B51EA9F29E00293FEC /* Quick.framework */, - CDA864B11EA9F28E00293FEC /* Nimble.framework */, - CDA864AA1EA9F25C00293FEC /* Quick.framework */, - CDA864981EA9F1B600293FEC /* Nimble.framework */, - CDA864991EA9F1B600293FEC /* Quick.framework */, - CDA864961EA9F1A000293FEC /* Swinject.framework */, - CDA864941EA9F19400293FEC /* Swinject.framework */, - CDA864921EA9F17A00293FEC /* Swinject.framework */, + 55640987210FCFCC00AFFA8F /* Swinject.framework */, ); name = Frameworks; sourceTree = ""; @@ -667,6 +617,7 @@ 985904021CDB0AA700275E4A /* Frameworks */, 985904031CDB0AA700275E4A /* Headers */, 985904041CDB0AA700275E4A /* Resources */, + 5564098A210FCFDF00AFFA8F /* ShellScript */, ); buildRules = ( ); @@ -894,6 +845,24 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 5564098A210FCFDF00AFFA8F /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Swinject.framework", + ); + outputPaths = ( + "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Swinkect.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 985904011CDB0AA700275E4A /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1084,10 +1053,12 @@ "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = Sources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboard"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_TREAT_WARNINGS_AS_ERRORS = NO; }; name = Debug; }; @@ -1103,9 +1074,11 @@ "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = Sources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboard"; + SWIFT_TREAT_WARNINGS_AS_ERRORS = NO; }; name = Release; }; From 679e157889193073b9d130881409d10ab22620f9 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 31 Jul 2018 11:22:03 +0300 Subject: [PATCH 11/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99a87dd..5f90a8f 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ if you want to pass some arguments, you can do it in such way: 1) Register VC ```swift let container = SwinjectStoryboard.defaultContainer -container.storyboardInitCompleted(AnimalViewController.self) { r, c, arg1: Int, arg2: SomeValue in +container.storyboardInitCompletedArgs(AnimalViewController.self) { r, c, arg1: Int, arg2: SomeValue in c.animal = r.resolve(Animal.self) c.countAnimals = arg1 c.someValue = arg2 From 8543be2b06fb0138164f5d9cfb0d20e0691a9fad Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Tue, 31 Jul 2018 11:24:08 +0300 Subject: [PATCH 12/17] Added Nimble and Quick to Cartfile. --- Cartfile | 2 ++ Cartfile.resolved | 2 ++ Sources/SwinjectStoryboardExtensions.swift | 9 +++------ SwinjectStoryboard.xcodeproj/project.pbxproj | 14 +++++++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Cartfile b/Cartfile index 5dec7e5..29dd252 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1,3 @@ github "Swinject/Swinject" ~> 2.0 +github "Quick/Nimble" +github "Quick/Quick" diff --git a/Cartfile.resolved b/Cartfile.resolved index db37aa7..f910353 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1,3 @@ +github "Quick/Nimble" "v7.1.3" +github "Quick/Quick" "v1.3.1" github "Swinject/Swinject" "2.4.1" diff --git a/Sources/SwinjectStoryboardExtensions.swift b/Sources/SwinjectStoryboardExtensions.swift index bd5108f..796df8d 100644 --- a/Sources/SwinjectStoryboardExtensions.swift +++ b/Sources/SwinjectStoryboardExtensions.swift @@ -25,8 +25,7 @@ import Swinject public func storyboardInitCompletedArg(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg) -> ()) { - let factory = { (r: Resolver, c: Controller, - arg: Arg) -> Container.Controller in + let factory = { (r: Resolver, c: Controller, arg: Arg) -> Container.Controller in initCompleted(r, c as! C, arg) return c } @@ -38,8 +37,7 @@ import Swinject public func storyboardInitCompletedArgs(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg1, Arg2) -> ()) { - let factory = { (r: Resolver, c: Controller, - arg1: Arg1, arg2: Arg2) -> Container.Controller in + let factory = { (r: Resolver, c: Controller, arg1: Arg1, arg2: Arg2) -> Container.Controller in initCompleted(r, c as! C, arg1, arg2) return c } @@ -51,8 +49,7 @@ import Swinject public func storyboardInitCompletedArgs(_ controllerType: C.Type, name: String? = nil, initCompleted: @escaping (Resolver, C, Arg1, Arg2, Arg3) -> ()) { - let factory = { (r: Resolver, c: Controller, - arg1: Arg1, arg2: Arg2, arg3: Arg3) -> Container.Controller in + let factory = { (r: Resolver, c: Controller, arg1: Arg1, arg2: Arg2, arg3: Arg3) -> Container.Controller in initCompleted(r, c as! C, arg1, arg2, arg3) return c } diff --git a/SwinjectStoryboard.xcodeproj/project.pbxproj b/SwinjectStoryboard.xcodeproj/project.pbxproj index 6df209c..1152cf8 100644 --- a/SwinjectStoryboard.xcodeproj/project.pbxproj +++ b/SwinjectStoryboard.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 55640989210FCFD600AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; + 5564098D21104F6200AFFA8F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098B21104F6200AFFA8F /* Quick.framework */; }; + 5564098E21104F6200AFFA8F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098C21104F6200AFFA8F /* Nimble.framework */; }; 983DFEA51CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA61CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA71CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; @@ -171,6 +173,8 @@ /* Begin PBXFileReference section */ 55640987210FCFCC00AFFA8F /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/iOS/Swinject.framework; sourceTree = ""; }; + 5564098B21104F6200AFFA8F /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = ""; }; + 5564098C21104F6200AFFA8F /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = ""; }; 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Container+SwinjectStoryboard.swift"; sourceTree = ""; }; 983DFEA01CDB410D00D39731 /* Storyboard+Swizzling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Storyboard+Swizzling.swift"; sourceTree = ""; }; 983DFEA11CDB410D00D39731 /* SwinjectStoryboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwinjectStoryboard.swift; sourceTree = ""; }; @@ -263,6 +267,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5564098E21104F6200AFFA8F /* Nimble.framework in Frameworks */, + 5564098D21104F6200AFFA8F /* Quick.framework in Frameworks */, 55640989210FCFD600AFFA8F /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -571,6 +577,8 @@ CDA864911EA9F17900293FEC /* Frameworks */ = { isa = PBXGroup; children = ( + 5564098C21104F6200AFFA8F /* Nimble.framework */, + 5564098B21104F6200AFFA8F /* Quick.framework */, 55640987210FCFCC00AFFA8F /* Swinject.framework */, ); name = Frameworks; @@ -853,9 +861,13 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/iOS/Swinject.framework", + "$(SRCROOT)/Carthage/Build/iOS/Quick.framework", + "$(SRCROOT)/Carthage/Build/iOS/Nimble.framework", ); outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Swinkect.framework", + "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Swinject.framework", + "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Quick.framework", + "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Nimble.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; From c144701f6c6026e39567e5b9dd13bb0f65f5ef9f Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Tue, 31 Jul 2018 11:54:44 +0300 Subject: [PATCH 13/17] Fixed OSX Compilation. --- Sources/SwinjectStoryboard.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index e38f132..68a0b83 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -104,8 +104,9 @@ public class SwinjectStoryboard: _SwinjectStoryboardBase, SwinjectStoryboardProt // https://github.com/Swinject/Swinject/issues/10 if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller) -> Any - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController) as Any } as Container.Controller? + typealias FactoryType = ((Resolver, Container.Controller)) -> Any + + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory((self.container.value, viewController)) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -214,8 +215,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg) -> Any - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg) as Any } as Container.Controller? + typealias FactoryType = ((Resolver, Container.Controller, Arg)) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory((self.container.value, viewController, arg)) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -233,8 +234,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2) -> Any - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2) as Any } as Container.Controller? + typealias FactoryType = ((Resolver, Container.Controller, Arg1, Arg2)) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory((self.container.value, viewController, arg1, arg2)) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } @@ -253,8 +254,8 @@ extension SwinjectStoryboard { if let container = container.value as? _Resolver { let option = SwinjectStoryboardOption(controllerType: type(of: viewController)) - typealias FactoryType = (Resolver, Container.Controller, Arg1, Arg2, Arg3) -> Any - let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory(self.container.value, viewController, arg1, arg2, arg3) as Any } as Container.Controller? + typealias FactoryType = ((Resolver, Container.Controller, Arg1, Arg2, Arg3)) -> Any + let _ = container._resolve(name: registrationName, option: option) { (factory: FactoryType) in factory((self.container.value, viewController, arg1, arg2, arg3)) as Any } as Container.Controller? } else { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } From cac17fb72ec79bc45fd7741de65d9433421309b0 Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Tue, 31 Jul 2018 12:45:58 +0300 Subject: [PATCH 14/17] Fixed tests. --- SwinjectStoryboard.xcodeproj/project.pbxproj | 55 ++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/SwinjectStoryboard.xcodeproj/project.pbxproj b/SwinjectStoryboard.xcodeproj/project.pbxproj index 6169a2a..8ba5c2b 100644 --- a/SwinjectStoryboard.xcodeproj/project.pbxproj +++ b/SwinjectStoryboard.xcodeproj/project.pbxproj @@ -10,6 +10,15 @@ 55640989210FCFD600AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; 5564098D21104F6200AFFA8F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098B21104F6200AFFA8F /* Quick.framework */; }; 5564098E21104F6200AFFA8F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098C21104F6200AFFA8F /* Nimble.framework */; }; + 5564098F2110658E00AFFA8F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098C21104F6200AFFA8F /* Nimble.framework */; }; + 556409902110658E00AFFA8F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098B21104F6200AFFA8F /* Quick.framework */; }; + 556409912110658E00AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; + 556409922110664700AFFA8F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098C21104F6200AFFA8F /* Nimble.framework */; }; + 556409932110664800AFFA8F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098B21104F6200AFFA8F /* Quick.framework */; }; + 556409942110664800AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; + 556409952110664E00AFFA8F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098C21104F6200AFFA8F /* Nimble.framework */; }; + 556409962110664E00AFFA8F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5564098B21104F6200AFFA8F /* Quick.framework */; }; + 556409972110664E00AFFA8F /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55640987210FCFCC00AFFA8F /* Swinject.framework */; }; 983DFEA51CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA61CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; 983DFEA71CDB410D00D39731 /* Container+SwinjectStoryboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFE9F1CDB410D00D39731 /* Container+SwinjectStoryboard.swift */; }; @@ -109,24 +118,6 @@ CD6073911EBB3E8C00BE2167 /* Storyboard1.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073901EBB3E8C00BE2167 /* Storyboard1.storyboard */; }; CD6073931EBB3F1400BE2167 /* RelationshipReference2.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073921EBB3F1400BE2167 /* RelationshipReference2.storyboard */; }; CD6073951EBB3F6200BE2167 /* RelationshipReference1.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD6073941EBB3F6200BE2167 /* RelationshipReference1.storyboard */; }; - CDA864931EA9F17A00293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864921EA9F17A00293FEC /* Swinject.framework */; }; - CDA864951EA9F19400293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864941EA9F19400293FEC /* Swinject.framework */; }; - CDA864971EA9F1A000293FEC /* Swinject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864961EA9F1A000293FEC /* Swinject.framework */; }; - CDA8649A1EA9F1B600293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864981EA9F1B600293FEC /* Nimble.framework */; }; - CDA8649B1EA9F1B600293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864991EA9F1B600293FEC /* Quick.framework */; }; - CDA864A41EA9F22900293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864981EA9F1B600293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864A51EA9F22900293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864991EA9F1B600293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864A81EA9F23200293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864921EA9F17A00293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864AB1EA9F25C00293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864AA1EA9F25C00293FEC /* Quick.framework */; }; - CDA864AE1EA9F27100293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864AA1EA9F25C00293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B01EA9F27200293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864941EA9F19400293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B21EA9F28E00293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B11EA9F28E00293FEC /* Nimble.framework */; }; - CDA864B31EA9F29100293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B11EA9F28E00293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864B61EA9F29E00293FEC /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B41EA9F29E00293FEC /* Nimble.framework */; }; - CDA864B71EA9F29E00293FEC /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA864B51EA9F29E00293FEC /* Quick.framework */; }; - CDA864B91EA9F2A600293FEC /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B41EA9F29E00293FEC /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864BA1EA9F2A600293FEC /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864B51EA9F29E00293FEC /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CDA864BB1EA9F2AA00293FEC /* Swinject.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDA864961EA9F1A000293FEC /* Swinject.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FF492DA61EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m in Sources */ = {isa = PBXBuildFile; fileRef = FF492DA21EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m */; }; FF492DA71EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m in Sources */ = {isa = PBXBuildFile; fileRef = FF492DA21EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m */; }; FF492DA81EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m in Sources */ = {isa = PBXBuildFile; fileRef = FF492DA21EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m */; }; @@ -282,15 +273,6 @@ CD6073901EBB3E8C00BE2167 /* Storyboard1.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard1.storyboard; sourceTree = ""; }; CD6073921EBB3F1400BE2167 /* RelationshipReference2.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference2.storyboard; sourceTree = ""; }; CD6073941EBB3F6200BE2167 /* RelationshipReference1.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RelationshipReference1.storyboard; sourceTree = ""; }; - CDA864921EA9F17A00293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/iOS/Swinject.framework; sourceTree = ""; }; - CDA864941EA9F19400293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/Mac/Swinject.framework; sourceTree = ""; }; - CDA864961EA9F1A000293FEC /* Swinject.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swinject.framework; path = Carthage/Build/tvOS/Swinject.framework; sourceTree = ""; }; - CDA864981EA9F1B600293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = ""; }; - CDA864991EA9F1B600293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = ""; }; - CDA864AA1EA9F25C00293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = ""; }; - CDA864B11EA9F28E00293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = ""; }; - CDA864B41EA9F29E00293FEC /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/tvOS/Nimble.framework; sourceTree = ""; }; - CDA864B51EA9F29E00293FEC /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/tvOS/Quick.framework; sourceTree = ""; }; FF492DA21EDA490F0081A4A7 /* SwinjectStoryboard+SetUp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SwinjectStoryboard+SetUp.m"; sourceTree = ""; }; FF492DAF1EDA65D90081A4A7 /* NSStoryboard+Swizzling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSStoryboard+Swizzling.h"; sourceTree = ""; }; FF492DB01EDA65D90081A4A7 /* NSStoryboard+Swizzling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSStoryboard+Swizzling.m"; sourceTree = ""; }; @@ -315,6 +297,9 @@ buildActionMask = 2147483647; files = ( 985904111CDB0AA700275E4A /* SwinjectStoryboard.framework in Frameworks */, + 5564098F2110658E00AFFA8F /* Nimble.framework in Frameworks */, + 556409902110658E00AFFA8F /* Quick.framework in Frameworks */, + 556409912110658E00AFFA8F /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -330,6 +315,9 @@ buildActionMask = 2147483647; files = ( 98D562821CDB173500DECDC0 /* SwinjectStoryboard.framework in Frameworks */, + 556409922110664700AFFA8F /* Nimble.framework in Frameworks */, + 556409932110664800AFFA8F /* Quick.framework in Frameworks */, + 556409942110664800AFFA8F /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -345,6 +333,9 @@ buildActionMask = 2147483647; files = ( 98D5629E1CDB19AB00DECDC0 /* SwinjectStoryboard.framework in Frameworks */, + 556409952110664E00AFFA8F /* Nimble.framework in Frameworks */, + 556409962110664E00AFFA8F /* Quick.framework in Frameworks */, + 556409972110664E00AFFA8F /* Swinject.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1155,6 +1146,7 @@ ); INFOPLIST_FILE = Tests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; }; @@ -1170,6 +1162,7 @@ ); INFOPLIST_FILE = Tests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; }; @@ -1219,8 +1212,10 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/Mac", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = Tests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; @@ -1234,8 +1229,10 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/Mac", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = Tests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; @@ -1291,8 +1288,10 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/tvOS", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = Tests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; }; @@ -1306,8 +1305,10 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/tvOS", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = Tests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.el-eleven.SwinjectStoryboardTests"; PRODUCT_NAME = "$(PROJECT_NAME)Tests"; }; From 33f45f123ac1f5649ed78c5e0305ac91afef83f9 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 2 Aug 2018 23:52:06 +0300 Subject: [PATCH 15/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f90a8f..92a0ab7 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ if you want to pass some arguments, you can do it in such way: 1) Register VC ```swift let container = SwinjectStoryboard.defaultContainer -container.storyboardInitCompletedArgs(AnimalViewController.self) { r, c, arg1: Int, arg2: SomeValue in +container.storyboardInitCompletedArgs(AnimalViewController.self) { (r, c, arg1: Int, arg2: SomeValue) in c.animal = r.resolve(Animal.self) c.countAnimals = arg1 c.someValue = arg2 From 14ae7ecf601d0299acf0a9d20d81163a0f0db938 Mon Sep 17 00:00:00 2001 From: Andrey Bogushev Date: Fri, 21 Sep 2018 16:02:57 +0300 Subject: [PATCH 16/17] Update dependency version on 'Swinject'. --- SwinjectStoryboard.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwinjectStoryboard.podspec b/SwinjectStoryboard.podspec index 63a22df..2154150 100644 --- a/SwinjectStoryboard.podspec +++ b/SwinjectStoryboard.podspec @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' - s.dependency 'Swinject', '~> 2.4' + s.dependency 'Swinject', '~> 2.5' s.requires_arc = true end From 38846651191fae6c58290820879cb12d955c50b6 Mon Sep 17 00:00:00 2001 From: riznyk7 Date: Wed, 11 Sep 2019 15:50:35 +0300 Subject: [PATCH 17/17] swift 4.2 syntax update --- Sources/SwinjectStoryboard.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwinjectStoryboard.swift b/Sources/SwinjectStoryboard.swift index 557a05c..2dc7f08 100644 --- a/Sources/SwinjectStoryboard.swift +++ b/Sources/SwinjectStoryboard.swift @@ -231,7 +231,7 @@ extension SwinjectStoryboard { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } - for child in viewController.childViewControllers { + for child in viewController.children { injectDependency(to: child) } } @@ -250,7 +250,7 @@ extension SwinjectStoryboard { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } - for child in viewController.childViewControllers { + for child in viewController.children { injectDependency(to: child) } } @@ -270,7 +270,7 @@ extension SwinjectStoryboard { fatalError("A type conforming Resolver protocol must conform _Resolver protocol too.") } - for child in viewController.childViewControllers { + for child in viewController.children { injectDependency(to: child) } }