Answer
This isn't something to work around with conditional compilation — it's a sign the code is structured the wrong way around. As a rule, customization (code-layer) objects should never reference configuration objects (custom attributes, custom entities, and their generated packages) — configuration always sits above the code layer, not the other way around, and referencing it from your own PL/SQL creates exactly this kind of ordering/deployment dependency that can't reliably be satisfied. Restructure the dependency so the custom entity/attribute (if still needed) is created and referenced independently of your customization code's own deployment, rather than having your code call into something configuration generates.