Best way to organize solutions for Xamarin.Forms PCL with multiple dependent iOS/Android Apps

ShaneLuttrellShaneLuttrell USMember
edited February 2015 in Xamarin.Forms

Hello,

QUESTION:
1) What is the best way to layout multiple apps that depend on a single core PCL?
2) Do Workspaces do anything to help this problem?

BACKGROUND:
I've been working with Xamarin.Forms building some projects with the following layout that is generated by the Xamarin.Forms template (New Solution->MobileApps->BlankApp (Xamarin.Forms Portable)

  • SolutionName
    |- SolutionName.Core (PCL Library)
    |- SolutionName.App1.Droid
    |- SolutionName.App1.iOS
    |- Tests.PCL
    |- Tests.App1.iOS
    |- Tests.App1.Droid

This is pretty much the layout in the tutorials presented on the Xamarin website.

So now, I want to develop some additional Apps that will depend on the SolutionName.Core PCL library.

IDEAS:
1) Add to SolutionName additional projects like SolutionName.App2.Droid, etc. This way is going to quickly lead to a very busy solution. Also, my git repository (NOT using the internal Xamarin Studio version control) will have all apps chunked together, so not ideal.
2) Create a new solution (SolutionName.App2) and bring in PCL Project project (Add Existing Project). Then add new App2.iOS and App2.Droid + associated tests. Any changes I make in the PCL Project are reflected in SolutionName.App2 as well.
3) Change the layout in my original solution to look like:

  • SolutionName.Core
    |- SolutionName.Core (PCL Project Holding objects common to all apps (Models, serialization, Business Logic))
    |- Tests.PCL

  • SolutionName.App1
    |- SolutionName.Core (Add Existing PCL from SolutionName.Core)
    |- SolutionName.App1 (New PCL) - PCL for App1 (Mainly View and ViewModels, removed from the current PCL Project)
    |- SolutionName.App1.iOS (New)
    |- SolutionName.App1.Droid(New)
    |- Tests.App1.iOS(New)
    |-Tests.App1.Droid(New)

And for every new app, create a new solution:

  • SolutionName.App2
    |- SolutionName.Core (Add Existing PCL from SolutionName.Core)
    |- SolutionName.App1 (New PCL) - PCL for App2 (Again, mainly View and ViewModels)
    |- SolutionName.App2.iOS (New)
    |- And so on...

Right now, I like solution 3 the best. Looks scalable. More solutions to track, but a nice clean demarcation line for my git repositories.

Any insight and ideas are greatly appreciated. Curious if anyone has any solutions involving Workspaces. Just now starting to play with them and still not quite sure what they are for.

Thanks,

Shane

Posts

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    3 is the way to go.

    You can create a new solution using Templates / Visual C# / Mobile Apps / Class Library (Xamarin.Forms Portable). This will include everything you want to share between apps. Also create a separate repository for that solution.

    The best would be to compile the shared solution and only reference the dlls in your actual app solutions. Then compilation will be faster. But you could also include the projects themselves if you have to make changes very often (that would be your idea 2 if I understood it correctly). Then they will always be compiled with the apps, but you don't have to open the other solution to make changes. But that's totally up to you.

    1 is definitely a no go. You would often have changes in the overall solution because only one app changed. This also violates separation of concerns.

Sign In or Register to comment.