RxFlow icon indicating copy to clipboard operation
RxFlow copied to clipboard

Bundle returning target reference instead of module reference

Open eroth opened this issue 6 years ago • 13 comments

Hi, first off—thanks creating RxFlow! I'm using it for the first time and it looks pretty good so far. I'm running into a weird issue that seems to be linked to returning a view controller as a NextFlowItem in a flow. If I try to load a nib programmatically at any initial stage of the view controller lifecycle (viewDidLoad, viewWillAppear, and viewDidAppear) and attempt to get a reference to our module's bundle by using Bundle(for: type(of: self)) (self being the view controller) a reference to our app's target is returned instead of our framework module.

Example: From my flow function that returns NextFlowItems from a Step enum case:

private func navigateToMyNextScreen() -> NextFlowItems {
    // Create view controller, add view model, and push it with the nav controller
    let nextFlowItem = NextFlowItem(nextPresentable: myViewController, nextStepper: myViewController)
    return NextFlowItems.one(flowItem: nextFlowItem)
}

Output of at viewDidLoad, viewWillAppear, and viewDidAppear in myViewController from Bundle(for: type(of: self)).resourcePath: "/Users/[...]/Library/Developer/CoreSimulator/Devices/01802E25-FD20-43A8-9729-831B620F0281/data/Containers/Bundle/Application/310DB524-2ACA-4FD6-9168-9A0102D43239/[...].app"

However, if I just return NextFlowItems.none from navigateToMyNextScreen() (i.e., the view controller isn't registered):

private func navigateToMyNextScreen() -> NextFlowItems {
    // Create view controller, add view model, and push it with the nav controller
    return NextFlowItems.none
}

And the correct bundle resourcePath is given: Output at viewDidLoad, viewWillAppear, and viewDidAppear in myViewController from Bundle(for: type(of: self)).resourcePath: "/Users/[...]/Library/Developer/Xcode/DerivedData/[...]-flzbuuwuhjeoxpeasujpzylznujt/Build/Products/Debug-iphonesimulator/[...].framework"

This issue appears similar to https://github.com/jverkoey/iOS-Framework/issues/107, although from my understanding in Swift 4 type(of: self) is supposed to be equivalent to Obj-C [self class].

We're using RxFlow a little differently from the sample projects, so not sure if that could be causing it. As we're testing it out on a greenfield feature inside a mature app, we're not initializing it with the app's UIWindow; instead, we're using it in one tab of a UITabViewController and it's only one flow. The flow returns a UINavigationController as its root property which is then added to the tab that's displayed. We also have multiple frameworks that we use in the same project, but RxFlow is only being used inside one framework.

Is there anything you can think of in either RxFlow or our use case that could cause this to occur? It's easy enough to work around but was wondering what was causing it, as it's a rather weird bug. Thanks!

eroth avatar Mar 15 '18 12:03 eroth

Hi @eroth, thanks for your message.

I did some tests (according to different syntaxes I found on StackOverflow) and I always have the same result (the bundle from the .app). I have no other clue to help you.

What is your workaround ?

twittemb avatar Mar 15 '18 17:03 twittemb

Thanks for looking into it! Our workaround is just to hardcode the bundle identifier string and use that when getting a reference to the bundle we want. I’ll see if I can reproduce this issue in a sample project.

On Mar 15, 2018, at 17:08, Thibault Wittemberg [email protected] wrote:

Hi @eroth, thanks for your message.

I did some tests (according to different syntaxes I found on StackOverflow) and I always have the same result (the bundle from the .app). I have no other clue to help you.

What is your workaround ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

eroth avatar Mar 15 '18 19:03 eroth

hi @eroth

Can I close this issue, as this seems to be an issue not related to RxFlow in particular and since you have a workaround ?

thanks.

twittemb avatar Mar 20 '18 14:03 twittemb

@twittemb,

Hi, if it's ok with you do you mind if it stays open a little longer? I wanted to see if I could repro it in a project that I could make publicly available. It does only occur when we use RxFlow.

Thanks, Evan

eroth avatar Mar 20 '18 21:03 eroth

Of course it's ok with me. If you find the cause of this issue it is something I definitely want to know 👍

twittemb avatar Mar 20 '18 21:03 twittemb

Great, thanks—I’ll try and put together a project by this weekend.

On Mar 20, 2018, at 9:20 PM, Thibault Wittemberg [email protected] wrote:

Of course it's ok with me. If you find the cause of this issue it is something I definitely want to know 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RxSwiftCommunity/RxFlow/issues/42#issuecomment-374760811, or mute the thread https://github.com/notifications/unsubscribe-auth/ABw_sTzv0nx8rybxOYW3ShCm0pYzQXj3ks5tgXKggaJpZM4SsFd8.

eroth avatar Mar 20 '18 21:03 eroth

Hi there

Any updates about this issue ?

Thanks.

twittemb avatar Apr 03 '18 12:04 twittemb

Hi, I started to put together a project to repro it but haven't finished yet. I don't want to keep the issue open too long, so if you'd feel better closing it please feel free to. I should be able to finish it by this weekend, though.

eroth avatar Apr 03 '18 20:04 eroth

No It is ok to leave it open. No rush.

See ya 👍

twittemb avatar Apr 03 '18 20:04 twittemb

@twittemb Hi, thanks for your patience! I've put together a sample project demonstrating the crash we were experiencing. It's up at https://github.com/eroth/RxFlowCrash. I've indicated in the README what to do to replicate the crash. Please let me know if you have any questions!

eroth avatar Apr 08 '18 17:04 eroth

Hi

Thanks for your feedback. I'll take a look as soon as I have a little time.

Bye.

twittemb avatar Apr 09 '18 12:04 twittemb

Sounds good—thanks!

On Apr 9, 2018, at 13:32, Thibault Wittemberg [email protected] wrote:

Hi

Thanks for your feedback. I'll take a look as soon as I have a little time.

Bye.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

eroth avatar Apr 09 '18 19:04 eroth

Hi, any update on this?

eroth avatar Jun 18 '18 09:06 eroth

This issue has not received any recent updates. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please leave a comment below and auto-close will be canceled.

github-actions[bot] avatar Jun 06 '23 11:06 github-actions[bot]

This issue has automatically been closed due to inactivity.

github-actions[bot] avatar Jun 22 '23 00:06 github-actions[bot]