I have a requirement to split project's code into two parts:
- Unmanaged part - mostly, it's custom data model. Should be editable in client's org.
- Managed part - wrapped in 2GP Managed Package. There should be Apex Classes, Aura Components etc. Components should reference data model included in Unmanaged part. It should NOT be editable or even visible in client's org.
I've already split the code in such way, that Unmanaged part does not depend on managed part - it's obvious. But managed part depends on unmanaged part on purpose.
Now, I'm trying to create managed package version of the code, but verification of metadata ends with errors telling, that managed code part Apex does not recognize particular custom objects. I think it's totally justified error, so I added
--skipValidation flag thinking, that during installation in org, which already has the unmanaged part, it will resolve the references correctly. I was wrong - installation, also returns errors complaining about using API names not resolving to a valid sobjects.
Is it possible, to meet my requirements? What can I do to create managed package, which refers to custom objects from outside the package?
I read about Org-Dependent Unlocked Packages, but they don't satisfy the requirement, which is hidden code in client's org.