1

I am creating a Xamarin cross-platform app, I have 2 types of user, for example, a buyer and a seller.

I want to build 2 applications from the same code base by selecting/skipping the classes. There some classes are common for both apps, some classes only for buyer build, some are only for seller build.

If I write the logic for the application flow based on the user type then there will be unwanted classes that building, It will increase the app size.

I know we can create multiple projects/application for this, How can we do it from the same code base? Is it possible in Xamarin?

Iain Smith
  • 9,230
  • 4
  • 50
  • 61
Remees M Syde
  • 2,564
  • 1
  • 19
  • 42

1 Answers1

2

So from what you have said you have a code base but want to share some of the code but not all. Firstly you will need to create two separate App projects, e.g., App.Buyer and App.Seller.

From not knowing much about the architecture of your app, there are a couple of options:

  1. You can then link over the classes you want to share into the other project so that they have the same classes, you will need to check namespaces, etc. This also might mean you will have to rearchitect your app to separate more of the user flow logic

To do this go to Add > Exisitng Item... > then select the drop down on the add button to Add as link enter image description here

e.g. The classes in the Seller app get linked to the Buyer app.

  1. Another option is to create a shared project that has the common logic then add that to each of the projects.
Iain Smith
  • 9,230
  • 4
  • 50
  • 61
  • Hey thanks buddy. Let me try. By the way where is the add button? I am on VS17. – Remees M Syde May 03 '19 at 10:18
  • If you have a look at this, it shows where the button is https://andrewlock.net/including-linked-files-from-outside-the-project-directory-in-asp-net-core/ or this https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/9f4t9t92(v=vs.100)#adding-an-existing-item-as-a-link – Iain Smith May 03 '19 at 10:22
  • Great, Thanks again. – Remees M Syde May 03 '19 at 10:29