Skip to content

Conversation

jakubvano
Copy link
Member

@jakubvano jakubvano commented Sep 1, 2016

As reported in Swinject#128, injection on storyboard references does not work properly when initial storyboard is created with custom (other than defaultContainer) container. @VladimirBorodko pointed out in this comment that problem is caused by not passing custom container when creating an instance of referenced storyboard.

This fixes the issue, however it introduces stack of storyboards used during instantiation of view controller, which is needed to obtain container of "parent" storyboard when creating storyboard reference. It is a bit too hacky for my taste, and would love if someone could come up with better solution.

@jakubvano
Copy link
Member Author

Last 2 commits should also fix Swinject#125

@yoichitgy
Copy link
Member

yoichitgy commented Sep 2, 2016

Thank you for fixing the issue. It looks good to me. It is very difficult to subclass UIStoryboard for its irregular initializer and storyboard references. I think my implementation using static defaultContainer is also a little bit hacky.

Only one problem I found was unit tests failed on iOS 8.1 devices both in Travis and my local environment (Xcode 7.3.1). Would you check the problem?

@jakubvano
Copy link
Member Author

Described issues manifest when you use storyboard reference for relationship segues (e.g. root view controller is in referenced storyboard) - this feature is only supported in iOS 9.0+. Because of this I had to increase the target version of test bundle to 9.0 ( framework target version remains unchanged)

Not sure how to solve this - one option would be to isolate problematic tests to different test bundle which would be only ran on iOS 9.0 environment. Simpler one would be to run all the tests inside 9.0 environment, but that way we will lose coverage of iOS 8.

@yoichitgy
Copy link
Member

yoichitgy commented Sep 2, 2016

I think we can use #available like this to wrap the iOS9-only tests:

if #available(iOS 9.0, *) {
    // The test code here.
}

It's good to document that the storyboard reference feature works properly only on iOS 9.0+. We can keep supporting and testing iOS 8 except the storyboard reference feature working.

@yoichitgy yoichitgy merged commit c183fd6 into Swinject:master Sep 3, 2016
@yoichitgy yoichitgy added this to the v1.0.0-beta.2 milestone Sep 3, 2016
@yoichitgy
Copy link
Member

Thanks @jakubvano very much for fixing the issue, and adding a comment about the use of NSProcessInfo().isOperatingSystemAtLeastVersion instead of #available.

We might be able to reduce hacky code when we got a nice idea in the future. I introduced the static defaultContainer property for storyboard references and Main.storyboard instantiated by the system with UIMainStoryboardFile key specified in Info.plist. defaultContainer might also be changed to another better way.

@yoichitgy
Copy link
Member

yoichitgy commented Sep 3, 2016

@jakubvano, I usually add merged pull requests to a milestone not to forget mentioning them in its release note. This time, I added this pull request to milestone v1.0.0-beta.2.

@jakubvano jakubvano deleted the referenced_storyboard_injection branch September 5, 2016 07:10
@jakubvano
Copy link
Member Author

jakubvano commented Sep 5, 2016

👍 hopefully I will learn this flow soon enough 😄

@yoichitgy
Copy link
Member

This is just my way, but I put merged pull requests into a milestone representing the next version. When I release the version, I write a release note listing the changes with contributor names.

For example:

Some people prefer writing CHANGELOG when they merge pull requests, but I prefer writing things later. I also do not make CHANGELOG file in Swinject repos because release notes show the changes.

I will write document for release procedure soon (or later😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants