Winter 18 introduced the FeatureManagement Apex Class, which contained a method which I was not expecting:
changeProtection. According to the docs,
changeProtection can be used to "Unprotect" objects or custom permissions which were previously released as protected. However, it is not clear from the documentation whether this method is supposed to be usable to "Protect" unprotected objects, or whether it is possible to use this with ANY Custom Object type, i.e. with something other than Custom Settings or Custom Metadata Types.
When I create a brand-new regular Custom Object, and then try to mark it "Protected" like this:
I get the following error:
System.TypeException: Once protection has been removed from CustomObject, never may it be restored.
Which doesn't make any sense in my case, as I've just created a brand-new Custom Object and am trying to mark it as Protected before I release it.
I'm probably trying to use this method in a way it was not designed, but I'd love to get some confirmation on that.
However, the docs seem to indicate that this is a possible use of this feature:
Be sure to protect any custom objects that you want to hide before you release the first package version that contains them.
Which is exactly what I'd like to do! If we can make regular Custom Objects Protected --- that would be a HUGE HUGE Winter 18 feature.