Conditional package dependency

Hi!

I’m in the situation where I’d like to add a package as a dependency of another package only if the first package is found in the project.

Example:
I have a package named Apples, that doesn’t have any dependencies, but has some awesome functionalities available.
I have another package, Oranges, that would benefit from the functionalities of the Apples package, but it should not be enforced to have it as a dependency.
Can I somehow detect that I have both packages and add the Apples package inside Oranges?.

I managed to have some conditional #defines if the package is found (using the Version defines from the asmdef file), but I would like to have access to the API found in the other package.

Thank you!

1 Like

You can use Client.List method to detect installed packages, then promote a user to install the OrangesApplesExtention package.

But probably keep everything in Oranges (both oranges and oranges-apples-extension) and use #if defines maybe easier.