I'm not clear from your question whether you're trying to build a Managed Package, and a Managed Package is what you actually want (or need). Maybe have a read of this first and decide if a Managed Package is right for your needs, but in summary:
Managed packages are typically used by Salesforce partners to distribute and sell applications to customers
Addressing each of your questions:
- How do I access fields
Security_Description__c
and Product_Type__c
on my Object1__c
?
This really depends on how Security_Description__c
and Product_Type__c
came to be on Object1__c
. If they were installed as part of namespace_Y
'into' namespace_X
, then namespace_Y
would have been an extension to namespace_X
and you would have had to install first namespace_X
and then namespace_Y
into your org. In any case, the way to find out the API name of these fields would be to look at the API Name column under Custom Fields & Relationships on Object1__c
2) Should we use the namespace when we are accessing the Custom
Settings inside the Managed package Apex Controller?
You should not need to, the code in the managed package will always take preference of its own objects, even if there is an unmanaged object with the same name.
3) After creating a namespace - when I create a unmanaged package - I
am getting the following error:
line 158, column 30: Unmanaged packages cannot explicitly reference
this organization's namespace.
That error is because you are referencing a managed component (of namespace_X) from something in your unmanaged package. So, imagine if you didn't get this error message and then tried to deploy your unmanaged package to another org, what if namespace_X wasn't installed on your target org? This error is preventing that from happening. If you're creating an unmanaged package, it implies you're trying to release something from namespace_X package. The only way you're going to be able to release something from this org now is by uploading your Managed Package - once you have created a namespace, it is irreversible. If a managed package is not what you want, you would need to spin up a new DE org.
4) After packaging the code with a namespace - where will the next
version of development happen? Is it on namespace code or on a no
namespace code? if it is on namespace version how is it done?
Once you create a Managed Package, any further modification to the code in namespace_X would need to happen in the DE org for the Managed Package, i.e. if you deploy to a Sandbox, you won't be able to modify the code there.