Add manifest.json dependencies to exported Unity Package

I have a unity package which is built via the AssetDatabase.ExportPackage API.
The code in my package is depends on com.unity.ads.ios-support.
Is there a way to add com.unity.ads.ios-support to my exported package as a dependency so it will be installed automatically in the project I install my package, meaning will be added to the manifest.json in the target project?
Currently I just pack an additional Editor script that adds it to the manifest.json, but it’s just a hack.

This question appears to be popular and I’ve struggled today looking exactly how to do this. So, here’s a working solution for anyone looking at this in the future, with Unity 2021 and 2023

Here’s how it works:
Unity compiles and initialises code in stages. Before compiling user-generated assemblies, Unity compiles “firstpass” code, which can be generated from several folders. For some reason Unity doesn’t create instance of c# classes if you just put them into the “firstpass” assemblies, but it works if you compile your code into a .dll and paste it there. I’ve attached the .dll in the file below. This folder will need to be put into Assets/Plugins/Editor in order for it to work

The other file alongside the .dll is a .csv file, where you can put the package names that you want the editor to install. IF you put it into a unity package and just load it up, there’s a chance it won’t work (haven’t extensively tested it yet), but it works after the editor restart. If you have code that relies on these dependencies and won’t compile, than don’t load the editor in safe mode or just exit safe mode (otherwise Unity won’t recompile and execute its firstpass assembly)

Here’s the pastebin for the code so you can generate your own version of this asset if you need to adjust things:

Here are the resources you can read to get a better understanding of how this works and how you can create your own asset of this type

Cheers and hope you have a good day

Did you ever find a better solution than the Editor script that updates the manifest.json?