Can't add PCL to existing Xamarin Forms project - visual-studio

Brand new install of Visual Studio Pro 2017, Prism Template Pack, and Xamarin Forms.
I am trying to create my first App and things are going very well so far. I have all the views, view models, etc. set and the app is functioning perfectly. Now I am trying to add some more PCL projects to the solution for things like Domain or Services, etc. so I can keep all the parts separated.
I can create a Xamarin Forms PCL just fine and add all my classes, etc. Problem comes when I try to add a reference to the Domain project from the main PCL project in the solution. I get the "targets of pcl don't match" error message.
This is what I am using to create the new PCL project:
This is the error message I receive when trying to add the PCL project reference:
What am I missing?
Here is the main PCL created with the template pack properties:
Here is the newly added PCL project properties:
PCL properties for template:

Since you are missing the Windows Phone & Silverlight targets in your IDE for some reason, this is a potential workaround:
Open up your .csproj files and make sure the TargetFrameworkProfile elements match up in both PCL projects.
Is it possible that you didn't install the tools for Windows Phone development when you installed Visual Studio?

Related

Xamarin Forms Platform Specific Project Cant See Class Library

I'm trying to develop a Xamarin forms application and I'm having problems seeing namespaces in an Android class library I've added to the solution. Note, I'm using visual studio 2015 Community Version 14.0.25431.01 Update 3.
My Xamarin forms application solution contains the following projects.
XFormsApp(Portable)
XFormsApp.Android
XFormsApp.IOS
XFormsApp.UWP
MyCoreComsLib Preexisting PCL containing communications interfaces/abstractions, and cross platform utilities.
MyAndroidComsLib Preexisting Android specific implementations of the communications interfaces. This library references MyCoreComsLib. I believe MyAndroidComsLib is an "Android Class Library" project.
Right now I'm just trying to get the android implementation of the Xamarin forms app running so I added the following references between projects.
from MyAndroidComsLib to MyCoreComsLib
from XFormsApp(Portable) to MyCoreComsLib
from XFormsApp.Android to MyCoreComsLib
from XFormsApp.Android to MyAndroidComsLib
My Problem: When I work in CrossApp.Android I can't see any classes or namespaces from MyCoreComsLib or MyAndroidComsLib. However, when working in XFormsApp(Portable) I can access namespaces / classes in MyCoreComsLib. I've used the MyCoreComsLib and MyAndroidComsLib class libraries in android only c# projects so there aren't any issues with the visibility of classes.
I've done the following in an attempt to solve this issue.
Made sure MyCoreComsLiband MyAndroidComsLib built in the cross platform app solution.
Made sure the references to MyCoreComsLiband MyAndroidComsLib show up in the references list under the XFormsApp.Android project.
Restarted visual studio.
Created a brand new Xamarin forms app. Added a new Android Class library to the project. Added a reference from the NewFormsApp.Android project to the class library and attempted to access classes in the class library. Note, I wasn't able to see a class an in the new android class library so this leads me to believe this is a limitation with visual studio / Xamarin but I don't understand why this wouldn't be supported.
Thanks Everyone!
This has been confirmed as a bug in visual studio 2015 https://bugzilla.xamarin.com/show_bug.cgi?id=57991. I was able to resolve this issue by switching to visual studio 2017.

What PCL should I use to build a Xamarin mvvmcross app

I am new in mvvmcross and I want start to developing an app using this framework but I don't know which PCL should I use and how to mount my solution.
In some videos people uses C# -> windows -> PCL, and then add android, ios projects one by one, but all the videos are too old.
I want to know if there are a newer (better) way to create my solution to use mvvmcross and xamarin.
Beacuse in VSCommunity 2015 see there are a cross-platform option, should I use this?
One more question, how can I fix the .Core, in the solution name? And the others .Ios, .Droid? If I create my project with name.Core all others projects become: name.Core.Ios, name.Core.Droid
It will make me in trouble when i have to use the namespace ?
The options?:
Using cross-platform
Using the old windows -> pcl like in videos
Have you had a look at the mvvmcross addin for Visual studio by JimBobBennett.
tools > Extensions and Updates > click Online > search for "Mvvmcross for visual studio"
then create a new project like so :
It will give a template that will create a solution with this structure:
Then just delete the projects you dont need.
Here is a link to the source code for that plugin if you want to take a look

How to develop a xamarin forms component control to be used as dll in a project

I'm developing a xamarin forms class library (Custom Component) that targets (Windows, Androi and IOS) platforms "this library should be added to an existing Xamarin forms Portable project as DLL reference" and want to add a UI control and use it's native functions from inside the library. Custom renderers can't be added in PCLs so Can anyone help on how to access the control's native functionality?
You can start from scratch on your by following this piece of documentation by Xamarin on how to build NuGet packages. Then just make sure you build them without too much references and test them in your sample projects.
But to make your life a lot easier have a look at this Visual Studio extension by James Montemagno. It installs some project templates for you so naming is consistent and you have the basics already setup to start building your reusable code.

Can't reference PCL library within Xamarin Studio

I'm trying to build an Android and iOS app with Xamarin using a shared PCL library. I'm following the tutorial on the Xamarin website [1].
I have created my PCL solution, which currently doesn't do anything, and I'm now trying to reference it from another Android solution.
The documentation indicates I should use References and then select Projects. However, when I do this, I can't either see or find a way to add my PCL library project as a reference.
How can I add my PCL library solution as a reference in another solution?
[1] http://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/introduction_to_portable_class_libraries/#Using_PCL
A solution is just a container for one or more projects. One project can be included in multiple solutions. By including multiple projects in one solution you can reference them from one another, which will allow them to automatically build/update their dependencies when needed. You can add a new project to an existing solution by doing "Add New Project" in the solution explorer - you don't have to create a complete new solution for each project.

What should go in the different projects in a SL/XNA solution in Visual Studio 2010?

In Visual Studio 2010 I created a new Windows Phone Silverlight and XNA Application. The solution it created contained 3 projects:
myProject
myProjectLib
myProjectLibContent
I can understand that content like pictures and textures, should go in myProjectLibContent, but what about myProjectLib, what should I put in there instead of in a folder in myProject?
The reason the projects are set up like that is simply a quirk of how Visual Studio and XNA Game Studio work.
So you start with myProject which is a Silverlight project. It's the same as any Silverlight project you'd create - except that it also has assembly references to the XNA assemblies so you can write XNA code within this project and it will compile just fine.
Now, because you're using XNA, you probably want to use the XNA content pipeline. So you get an XNA Content Pipeline project (myProjectLibContent) in the template as well.
Now all you have to do is build these two projects, right? Wrong!
First of all, an XNA Content Pipeline project is a special kind of project. It can't build itself - try it - try right-clicking the project and selecting "Build" - the option isn't there.
An XNA Content Pipeline project can only be built from an XNA project. The Silverlight project is not an XNA project. Only XNA projects can have "Content References" - which the XNA project will then build during its own build. Note the Silverlight project doesn't have a "Content References" section.
So the only reason that the XNA Library Project myProjectLib exists is to act as a bridge between the Silverlight project and the content project. The Silverlight project references the XNA Library project, which in turn builds and includes the content project.
This means that you can safely ignore the XNA Library project and leave it empty.
It's the same deal on Windows. A WinForms project that uses XNA needs an XNA Library project in order to build XNA content projects.
Lib is a "Library" project. Usually one is not created when creating a XNA game, even in 4.0. In fact, you don't have to put anything in it in the one it created for you.
Typically, a Library is a storage of centralized routines one would use on any game or any game of your game's type (like any rpg). And then you would call those routines from the more specific implementations in the game's base project library.
However, none of that's required and if this is your first game, I'd recommend you ignore in entirely. Place your code in the first project, the content in the 3rd and go to town!

Resources