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

Pull in protocol info from other projects/targets, without generating for those projects/targets #1324

Open
jamesormond opened this issue Apr 15, 2024 · 3 comments

Comments

@jamesormond
Copy link

jamesormond commented Apr 15, 2024

tl;dr

If my local Xcode project contains ProtocolA that confirms to ProtocolB in a different local Xcode project, how can I generate code for ProtocolA?

More Context

My Xcode project, "ProjectA", has two dependencies, both of which are other local Xcode projects that I created, "ProjectB" and "ProjectC". I have this situation in one of my Swift files within ProjectA:

// file within ProjectA

import ProjectB

// sourcery: AutoMockable
protocol ProtocolA: ProtocolB {
    // ProtocolB lives within ProjectB
}

I'm trying to generate mocks for ProtocolA within ProjectA, but I'm failing to include the data associated with ProtocolB. Here is what I'm hoping for, within ProjectA:

// autogenerated file within ProjectA

class ProtocolAMock: ProtocolA {

    // Protocol A related variables/functions
    ...
    ...

    // Protocol B related variables/functions
    ...
    ...

}

I've tried the following two configurations in my config.yml file:

sources:
- path/to/ProjectA/
- path/to/ProjectB/
- path/to/ProjectC/
...
projects:
- file: path/to/ProjectA/
  target:
    name: ProjectA
- file: path/to/ProjectB/
  target:
    name: ProjectB
- file: path/to/ProjectC/
  target:
    name: ProjectC
...

For both of these configurations, it correctly generates the expected results for the protocols defined with ProjectA. However, within ProjectA, it also generates the code for the protocols in ProjectB and ProjectC. Since I'm also running Sourcery separately for ProjectB and ProjectC, I am left with duplicated code across these projects.

Therefore, my question is: how can I configure Sourcery to say "scan projects B and C for data to help generate code in project A, but don't also generate everything for projects B and C"?

I'm imagining something like this (pseudocode):

sources_to_generate:
- path/to/ProjectA
dependencies_to_also_scan:
- path/to/ProjectB/
- path/to/ProjectC/
@jamesormond
Copy link
Author

Hello! Just following up on this :)

@art-divin
Copy link
Collaborator

art-divin commented Apr 27, 2024

👋🏻 Hello @jamesormond ,

thank you very much for creating issue! 🤝
I will do my best to try to resolve this. But please keep in mind this sounds like more of a full new feature.

Feel free to investigate and resolve this on your own, since Sourcery is open source and every contribution is very much appreciated by the community 👥 I will provide guidance in case you would have questions.

@jamesormond
Copy link
Author

Sweet, I'll try to implement this feature! Can you point me to where in the codebase you handle the config files, specifically where you handle tags like sources? Thanks!

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

No branches or pull requests

2 participants