Can I use components / references in a shared project?

JflyJfly USMember

I created a solution with the Xamarin.Forms (shared project) template in Xamarin Studio. I do not see "Components" or "References" folder under the shared project in the Solution Panel. Does this mean a shared project cannot have components or references?

Suppose I need to use the SQLite.NET component for the shared project, right now it seems I can't. In the example from the shared projects document (http://developer.xamarin.com/guides/cross-platform/application_fundamentals/shared_projects/), it is achieved by using the SQLite.NET source code file directly. I am wondering, what if I need to use a component / reference which I do not have access to its source code, how can I use it in a shared project?

Thanks!

Posts

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    edited May 2014

    Components are on the platform level - iOS/Android, but you should be able to share common references such as JSON.Net / etc on the shared project level.

  • JflyJfly USMember

    @JonDouglas‌ ,

    Thanks, but I cannot add reference in shared projects either.

    Now I am thinking maybe the lack of references / components in shared projects is by design. I mean maybe shared projects are not supposed to have references / components. I can understand this from the compiling perspective, because shared projects are not supposed to be compiled. It is the platform projects that are compiled, so it is sufficient to just add references in platform projects.

    However, in the Xamarin Studio IDE, the lack of references / components in shared projects created a coding issue. There are lots of Red (errors) in shared projects because the classes referenced to are not in the shared projects. This is not an issue for compiling (because shared projects are not compiled standalone), but it is an issue for coding.

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    edited May 2014

    Just think of shared projects as glorified and more manageable file linking. You technically don't have references in the sense of a using statement, but rather a reference of a file to each platform. You can then do whatever implementation you want for each platform linked to the shared project.

Sign In or Register to comment.