Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Missing generated Bundle.module #4095

Closed
karim-alweheshy opened this issue Feb 1, 2022 · 23 comments · Fixed by #4413
Closed

Missing generated Bundle.module #4095

karim-alweheshy opened this issue Feb 1, 2022 · 23 comments · Fixed by #4413
Labels
type:bug Something isn't working

Comments

@karim-alweheshy
Copy link

karim-alweheshy commented Feb 1, 2022

Describe the bug
Bundle.module is not generated for external SPM dependency

To Reproduce
Steps to reproduce the behavior:

  1. Clone this repo
  2. Run tuist generate
  3. Open workspace
  4. Build project

Expected behavior
Project builds.

Screenshots
Screen Shot 2022-01-27 at 14 41 01
Screen Shot 2022-02-01 at 15 51 51

Desktop (please complete the following information):

  • OS: macOS
  • Version 12.0

Additional context
IS_SPM is a macro added to the dependency's build settings.

@danieleformichelli
Copy link
Collaborator

I think the point is that we are not generating the Bundle.module because the target doesn't have resources, but apparently it might be required anyway in some cases 🤔

Not a big expert of the Bundle generation part, what do you think @kwridan @fortmarek @pepicrft ?

@fortmarek
Copy link
Member

It's worth checking whether we get to this line and what the value of supportsResources. Generally, I think we should generate Bundle.module regardless of whether the dependency has modules. However, if the dependency is dynamic, then we might skip generating it.

For now, you should also be able to override IS_SPM to false with targetSettings (as mentioned here)

@apps4everyone
Copy link
Sponsor Contributor

tried with:

targetSettings: [
            "A_SDK": ["SWIFT_PACKAGE": false],
            "B_SDK": ["SWIFT_PACKAGE": false],
            "C_SDK": ["SWIFT_PACKAGE": false],
]

but didn't worked for me...

@apps4everyone
Copy link
Sponsor Contributor

used like this:

extension Bundle {
    class var current: Bundle {
        return Bundle(for: A_SDK.self)
    }

    class var resolved: Bundle {
        #if SWIFT_PACKAGE
        return Bundle.module
        #else
        return Bundle.current
        #endif
    }
}

@fortmarek
Copy link
Member

Hey @apps4everyone, do you have a reproducible sample? Maybe with the project attached by @KarimAlweheshy?

@danieleformichelli
Copy link
Collaborator

danieleformichelli commented Feb 2, 2022

@apps4everyone for swift the debug flags are passed in SWIFT_ACTIVE_COMPILATION_CONDITIONS, so you should rather set:

targetSettings: [
            "A_SDK": ["SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)"]],
            "B_SDK": ["SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)"]],
            "C_SDK": ["SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)"]],
]

@apps4everyone
Copy link
Sponsor Contributor

@fortmarek thx for you suggestions, unfortunately I can't share the project because the SDK's are internal. But the use only the #if SWIFT_PACKAGE flag which is not custom. (it's from SWIFT)

@danyf90 thx, tested this but didn't worked for me

@apps4everyone
Copy link
Sponsor Contributor

SWIFT_PACKAGE is active but there is no Bundle.module, so with or without targetSettings ["SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)"]] the compilation is failing.

In my opinion the only solution would be to generate this even without resources as suggested before. @danyf90

@apps4everyone
Copy link
Sponsor Contributor

@apps4everyone
Copy link
Sponsor Contributor

apps4everyone commented Feb 4, 2022

this bug is preventing us from migration to Dependencies.swift now for weeks. How much work would i be to generate the Bundle.module by default maybe with an opt out flag?

see migration hint for 3.0: #4068 (comment)

@danieleformichelli
Copy link
Collaborator

@apps4everyone I think it shouldn't be a problem to generate the file anyway, do you want to have a look at it? 🙏

@fortmarek
Copy link
Member

agree, it should be fine to generate the file regardless of whether the module has any resources 👍

@apps4everyone
Copy link
Sponsor Contributor

@danieleformichelli
Copy link
Collaborator

Not sure if tuist will complain because there are no resources, you can try and see if it is enough 🙏

@karim-alweheshy
Copy link
Author

MessageKit has resources.. it's not imported by tuist for some reason

@karim-alweheshy
Copy link
Author

and maybe that's why the .module is not generated

@danieleformichelli
Copy link
Collaborator

danieleformichelli commented Feb 7, 2022

Thanks for pointing out!

I think the problem is that Tuist does not support (yet) automatically imported resources from SPM. It had been implemented at some point, but it has some problems and we had to revert it here and didn't had the time to have a look at it yet.

If you want to give it a try, let us know and we can try to find a solution together!

@apps4everyone
Copy link
Sponsor Contributor

thx for the infos. Looks like we could label this as a bug?

@danieleformichelli danieleformichelli added the type:bug Something isn't working label Feb 7, 2022
@karim-alweheshy
Copy link
Author

Here's a reference to how Apple handles different data in SPM

@Banck
Copy link
Contributor

Banck commented Mar 22, 2022

Just a note: still a bug with tuist 3.0.1

@karim-alweheshy
Copy link
Author

I see the problem here to be more fundamental to adopting tuist.. we will always have to catch up on mirroring SPM behaviors in tuist for current and future versions

Is the tuist team aware about this challenge? What's the plan here?

@danieleformichelli
Copy link
Collaborator

@KarimAlweheshy yes we are aware of that, and we plan to keep updating Tuist when needed

@apps4everyone
Copy link
Sponsor Contributor

sadly no update here, unfortunately way to complex to solve with a PR for none core tuist contributors like me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants