Reputation: 3293
I am looking into the best strategy for sharing code between different platforms
It's a bit of a nightmare!
PCL I can't use this easily as one of the frameworks I use, Catel, does not support Pcl as well as all the associated limitations they have
Linked files this is my ideal route as it prevents duplicating code, however setting up all the linked files is tedious across several projects, I am also not keen on putting everything in one assembly for iOS and one for android I.e all of the layers in 1 project
So I then looked at shared projects in VS 2013 I like the look of these however am I missing something or is there no way of linking files instead of creating copies? I really don't want to duplicate code files. Moving them into the new folder for the shared project will cause havoc with our subversion system in terms of showing historical changes etc it will also cause havoc if it is expected that files in totally separate places also have to be moved as all of the libraries that reference the moved files will need to be changed as well
Has anyone got a way of avoiding duplicating files in a shared project? I am thinking about creating my project in its new folder than moving it? Maybe I am misunderstanding something?
Paul
Upvotes: 0
Views: 92
Reputation: 19164
I would suggest to create one or more libraries, put them under VCS, add Unit Tests document the API thoroughly and carefully assign Version numbers (see Semantic Versioning). Don't forget to add those well known accompanying documentation files README, CHANGELOG and INSTALL.
Then use a package manager (e.g. NuGet) to manage the set of libraries and the version you require in your application or other library.
Developing a universally usable library in such a way is without doubt more elaborate than just copying or linking some helper classes from some server location. It's a poor practice, though which holds a lot of potential risks (like breaking projects, loosing files, unnoticed changes in helper files, etc) and virtually completely prevents further enhancements of the "libraries".
The additional costs spent with developing proper libraries with docs and Unit Tests will quickly return due to the reduced support costs and steadily improved libraries.
Upvotes: 1
Reputation: 3266
From what I've read, a shared project "exists purely as a grouping of source code files that can be included in other projects. When referenced by another project, the code is effectively compiled as part of that project." Essentially, your shared code is rolled up into the compiled code of the projects that reference it. I think this is your best bet based on your description of what you need.
Xamarin provides a nice guide to shared projects here.
Upvotes: 0