alisoftware / dip-ui Goto Github PK
View Code? Open in Web Editor NEWUI Extensions for https://github.com/AliSoftware/Dip
License: MIT License
UI Extensions for https://github.com/AliSoftware/Dip
License: MIT License
I have main UITabBarController with many view controllers. But method didInstantiateFromStoryboard doesn't call (for UITabBarController and view controllers in this tabbarcontroller ). dipTag and container register and added to uiContainers.
Hello,
I saw thread "Swift 3 issues" in Issues page of Dip library and I am wondering whether problems mentioned there applies also to DipUI library. Since I updated library to version 1.0.0, I am experiencing problem when instantiating controller from storyboard with DipUI.
Here is sample code for container controller registration:
container.register(tag: "ViewController") {
ViewController()
} .resolvingProperties { (container, entity) in
entity.viewModel = try! container.resolve() as ViewModel
}
I have storyboard with viewController with dipTag "ViewController". When I try to instantiate VC, following error occurs:
fatal error: attempt to bridge an implicitly unwrapped optional containing nil
in line 46 in AutoInjection.swift in Dip library.
Has any one found solution for this? Or should we wait for Swift 3.1? This method worked with Swift 2.3 and DipUI 0.2.2
Travis lets setup only repos with administrative access, so I can not do that. I've added travis script, but you have to enable integration yourself, @AliSoftware
Hi! I configured my view controller following a guide and I try to resolve an instance of view controller like this:
let viewController = try! container.resolve(tag: "myVC") as TestViewController
I get the instance of TestViewController
, but it doesn’t have outlets and all the stuff that I set in the storyboard. Does DipUI work only when you create all view controllers with segues? Is there any way to resolve instances in code?
Hi,
I need to resolve a UIViewController with runtime arguments to do something like this following:
container.register(.unique) { (id: String, object: MyProtocol?) in try MyViewModel(repository: container.resolve(), id: id, object: object) as MyViewModelProtocol }
container.register(storyboardType: MyUIViewController.self, tag: "MyTag") .resolvingProperties { container, vc in vc.viewModel = try container.resolve(arguments: id, object) as MyViewModelProtocol }
Is it possible?
Thanks.
Would it make sense to have an extension on DependencyContainer
like the following:
extension DependencyContainer {
public func registerViewController<T: StoryboardInstantiatable>(_ scope: ComponentScope = .shared, type: T.Type = T.self, tag: DependencyTagConvertible? = nil, factory: @escaping () throws -> T) -> Dip.Definition<T, ()> {
return register(scope, type: type, tag: tag, factory: factory)
}
}
This would help to not forget to conform to StoryboardInstantiatable
.
Could you provide any working example project?
I've made some one based on README and it seems it doesn't work as expected – my dependencies won't be resolved in sample controller.
Here is a code:
https://github.com/max-potapov/Playground/tree/dip
I've tried in Swift 3.0 project.
"Use Legacy Swift Language version" set to NO
Cartfile:
github "AliSoftware/Dip-UI"
Build log:
/usr/bin/xcrun xcodebuild -project /Users/Stan/tmp/DipUUUI/Carthage/Checkouts/Dip-UI/DipUI/DipUI.xcodeproj -scheme DipUI-iOS -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean buildBuild settings from command line:
BITCODE_GENERATION_MODE = bitcode
CARTHAGE = YES
CODE_SIGN_IDENTITY =
CODE_SIGNING_REQUIRED = NO
ONLY_ACTIVE_ARCH = NO
SDKROOT = iphoneos10.0
=== CLEAN TARGET DipUI-iOS OF PROJECT DipUI WITH CONFIGURATION Release ===
Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
=== BUILD TARGET DipUI-iOS OF PROJECT DipUI WITH CONFIGURATION Release ===
Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
Command line build output:
carthage update --platform iOS
*** Fetching Dip-UI
*** Fetching Dip
*** Downloading Dip.framework binary at "4.6.1"
*** Checking out Dip-UI at "0.2.2"
*** xcodebuild output can be found in /var/folders/q1/6l276hx53m590df28r4rvpv00000gn/T/carthage-xcodebuild.dvMvGI.log
*** Building scheme "DipUI-iOS" in DipUI.xcodeproj
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
A shell task (/usr/bin/xcrun xcodebuild -project /Users/Stan/tmp/DipUUUI/Carthage/Checkouts/Dip-UI/DipUI/DipUI.xcodeproj -scheme DipUI-iOS -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
In my Podfile I set Dip version to 7.0 and Dip-UI version was automatically redused to 0.2.2 version.
When I set Dip-UI version to 2.0, I got an error during pod update
[!] CocoaPods could not find compatible versions for pod "Dip":
In snapshot (Podfile.lock):
Dip (= 7.0.0, >= 4.1.0, ~> 7.0)
In Podfile:
Dip (~> 7.0)
Dip-UI (~> 2.0) was resolved to 2.0, which depends on
Dip (~> 6.0)
Hello! There are couple of modules in my VIPER-designed app. Each of them has separate DependencyContainer and each of them contains UIViewController that is instantiated from Storyboard.
func configureContainers(container rootContainer: DependencyContainer) {
Dip.logLevel = .Errors
DependencyContainer.uiContainers = [rootModule,
homeModule,
dockModule,
settingsModule,
listModule,
previewModule]
...
}
let rootModule = DependencyContainer { container in
let rootController = container.register(.shared, tag: "Root") { RootViewController() }
....
}
When these dependencies are being resolved during app execution, there are a lot of error messages in the console log. Something like:
No definition registered for type: SomeViewController, arguments: (), tag: String("Some").
Check the tag, type you try to resolve, number, order and types of runtime arguments passed to `resolve()` and match them with registered factories for type SomeViewController.
This messages are emitted by these lines in NSObject extension in dipTag setter:
for container in DependencyContainer.uiContainers {
do {
try instantiatable.didInstantiateFromStoryboard(container, tag: tag)
return
} catch { }
}
The reason is in how Dip "finds" proper container for instantiating storyboard object. And it definitely doesn't look too pretty.
It looks like these error messages can be safely ignored, but in my opinion it would be better to get rid of them. They give a wrong idea to the users, who will think that they do something wrong.
Or maybe it's me who does something wrong :)
Спасибо за полезный фреймворк, желаю удачи :)
Hi,
I am following the tutorial, but somehow not getting it to work. Getting these two errors. I am able to jump to definitions to uiContainers and StoryboardInstantiatable, but compiler does not recognises any of the DependencyContainer.extensions and gives these errors.
Thanks In advance
I have followed the exact steps as I use with NSViewController subclasses but the dependencies never get injected into NSSplitViewController subclasses.
I have tested whether the setter for a property (that I called "blah") on NSObject is called when I set a runtime attribute (just like "dipTag"), and it appears that it never gets called and I suspect this is why the dependencies are not injected.
Do you have a workaround for this that you know of? At the moment I'm considering using NSViewController subclasses with a child NSSplitView to get it to work, but that makes it harder to have view controllers associated with the child views.
I know I can access the container in the app delegate as well, but I like keeping the wiring out of the view component if possible
When building via carthage 0.24.0 and Xcode 9 beta4, we get an error.
When using master
all works fine. Maybe a new release or a swift3.2/4.0 would be good.
Hi, I've been using Dip for a week or two with the UI extensions, and it's working great for my NSViewController
s, but I haven't been able to find a way to inject into NSWindowController
s so far.
It conforms to the StoryboardInstantiatable
protocol, and there is a dipTag
on the NSWindowController subclass but it's getting injected into. I also tried using the auto inject class to resolve the dependencies, and that was to no avail also.
I have a workaround in mind, by setting the isInitialController to false and creating the window in my app delegate in order to inject but it's not ideal.
I'm happy to concede that I have made a mistake somewhere, but I can't see it if I have.
Thanks in advance for any help you may be able to provide.
Connor
Edit: I can auto inject using the Injected
class, it was a badly defined dependency, but would like to define the dependencies in the container initialisation.
Further edit: My above edit was incorrect, I still cannot get it to work.
P.S. I love how easy it was to implement, kudos on the framework, and I love the weakSingleton
component scope, it makes sharing my view models really easy.
Hi! In our project we wanted to use different uiContainers for different userStories, but we stuck in some sort of issue.
what happened:
at first we were using one uiContainer and it works like a charm 👍
but then, as we added second container, some stage things start to appear
WE've added second container like
DependencyContainer.uiContainers.append(storyBoardContainer)
btw, first uiContainer was added just like this too.
And then, when controllers from new user story must be initialized, console wrote smth like
No definition registered for type: HotelSearchVC, arguments: (), tag: nil.
Check the tag, type you try to resolve, number, order and types of runtime arguments passed toresolve()
and match them with registered factories for type HotelSearchVC.
BUT! though it wrote this in console, it also resolves injected properties like it was made to.
Then, we tried to use containers like in Readme
DependencyContainer.uiContainers = [storyBoardContainer]
and it starts working like it should.
So, the question is:
Hello,
I've noticed that new version of DipUI was released - "1.0.0", unfortunately I was unable to install it through CocoaPods. Version 0.2.2 pops up as latest. Has anyone experienced it?
BTW Thanks for this nice library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.