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

Allow specifying branch for source #11888

Open
wkornewald opened this issue May 4, 2023 · 6 comments
Open

Allow specifying branch for source #11888

wkornewald opened this issue May 4, 2023 · 6 comments

Comments

@wkornewald
Copy link

Currently, in a Podfile you can define source 'git@github.com:user/podspecs.git' but there's no way to specify the branch for that repo. The only way to do this is by manually adding a source via the cli and then using the source's name. But this setup is error-prone and every developer has to do it by hand (or via some script). Could you please add support for branches/tags either via source 'git@github.com:user/podspecs.git#branch' or source 'git@github.com:user/podspecs.git', branch: 'branch'?

@paulb777
Copy link
Member

paulb777 commented May 7, 2023

CocoaPods uses versioned tags to determine what hash to choose from the specified repo.

@wkornewald
Copy link
Author

Could you please elaborate?

Our use case is to have different branches which can contain the same version numbers, but those would point to different variants. Or actually, the real use case is to have module substitution. If the app integrates pod A and that depends on pod B and that depends on pod C, pod A should be able to replace C with D and the app should be able to replace C/D with E. This is similar to what Gradle allows in the Kotlin and Java world. Using different branches would be one possible solution, but having explicit support for substitution would be better (in addition to branch support).

@orta
Copy link
Member

orta commented May 7, 2023

We often get asked about resolving podspecs in a particular way, which I think is what Paul accidentally thought about.

I think allowing :branch => "something" in the source attribute of a Podfile makes sense.

I think the APIs necessary to do an overrides is in the current CocoaPods plugin API, and I don't think we'd need native support for that in the main repo itself

@wkornewald
Copy link
Author

Having native support for overrides would allow an important use-case like replacing a buggy/insecure dependency with a custom fixed build. Having to install plugins when you have different people using your SDK is also not nice at all because this is a transitive problem and at some point there's enough indirection that people don't even know you have a dependency that requires a plugin. Some things are important and universal enough to justify inclusion into the main app (same as how Gradle provides module substitution out of the box without plugins).

@orta
Copy link
Member

orta commented May 12, 2023

The order of sources is the order in which CocoaPods looks for a dependency, and so you can have an overrides specs repo which has your patched version if needed - but generally the dependency graph on a CocoaPods project is so shallow I don't think we need those sort of features.

@Pierre-Monier
Copy link

Anything new here ?

I think allowing :branch => "something" in the source attribute of a Podfile makes sense.

I totally agree, this would help me a lot for one project where we want to be able to switch between different versions of a private SDK. It would be nice if we just have to change the branch parameter (or a potential tag parameter).

In my case I'm forced to use the source attribute, because using thepod attribute with the desired branch or tag give me an error : [!] Unable to find a specification for ...

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

5 participants
@orta @paulb777 @wkornewald @Pierre-Monier and others