Can PCLs created in Visual Studio be used in Xamarin projects? - c#

I created a Portable Class Library the other day in VS2013. It targeted the following platforms:
.NET Framework 4.5
Windows 8.1
Windows Phone 8.1 (non-Silverlight)
My question is, can this be used in Xamarin projects such as Xamarin.iOS or Xamarin.Android? I've found a project claiming to support Xamarin, but grepping the solution and project files for "ios" and "android" turn up nothing. If not, what can I do to make my library portable to those platforms?
Thanks.

You need to install Xamarin for Visual Studio first if you haven't already
Open your PCL project and change the target profile to include the Xamarin platforms you want to support. (e.g. Profile 78)
Optionally retarget all your dependencies (projects/nugets)
Recompile your PCLs
You should now have dlls that work also in Xamarin.

You'll have to make your project target those platforms and then recompile your .dlls in order to make them available for Android and iOS.
I don't know what is the edition of your Visual Studio, but the options to target Android/iOS should be available in VS2013. In any case, try downloading Visual Studio 2015 community (which is free), open your project using it and the option should be there.
If none of this works, you can also try manually changing your .csproj file to a different profile. This is stated to have worked on this answer.

Related

Change Xamarin Forms version for each platform - iOS, Android & Shared

I have the same error message as this question, causing my Xamarin Forms project to not deploy. This is because each platform target of my project (iOS, Android and the Shared Platform) is running different versions of Xamarin forms.
The answer in the linked question was:
Solution:
Change in your Core, Droid and IOS project the Xamarin.Forms versions. Make sure that all versions are the same.
How do I change my Xamarin.Forms versions for each of my target platforms? Here is what my navigation menu looks like:
Open your solution in VS expand the packages folder and right click your Xamarin.Forms package. Each .csproj in your .sln should be on the same version if not update update it to the version to match that or just update all of them to the latest XF.
It will look a bit different if you're on windows, which has the nice package manager, so in that case you can right click on your open solution and go to manage nuget packages for solution.

Visual Studio 2017 Target Framework problems

I'm new to C# and my xamarin forms project won't run. I don't know how to solve this problem, I tried already to change the android target platform, but I can only choose 6.0.
Here is a screenshot of my errors
Screenshot
Open the Android SDK Manager and install Android 7.1. The version of Xamarin you have requires a higher Android target, and once you've installed 7.1 you'll be able choose it in the project properties.

How do I install SQLite for use in a Universal Windows App targetting UAP v10

I'm trying to get SQLite working in a Universal Windows App targeting UAP v10 using Visual Studio 2015 (RTM).
I've installed the Visual Studio Extension, "SQLite for Universal App Platform" and referenced it (and "Visual C++ 2015 Runtime for Universal Windows Platform Apps") from my project.
I've then added System.Data.SQLite via NuGet, which appears to work as a reference to it gets added to my project and I don't see any error messages. However, I don't appear to get any DLLs added to my project through this process.
Upon further investigation, it looks as though the System.Data.SQLite NuGet package is actually empty, but lists the following as dependencies...
System.Data.SQLite.Core
System.Data.SQLite.Linq
System.Data.SQLite.EF6
So - I tried adding each one of these through the Package Manager Console and received the following error...
Install-Package : System.Data.SQLite.Core 1.0.98.1 is not compatible
with UAP,Version=v10.0.
This seems like a fairly conclusive error message. So what do I do now... is SQLite actually supported for Windows 10 Universal Apps at the moment or not? Documentation I can find on the web seems pretty contradictory or at least seems to imply that I should be able to do what I'm trying to do.
Any help / pointers would be appreciated!
Win10 UWP(UAP) and Win8.1/WP8.1 Store App does not support ADO. System.Data.SQL is an ADO provider, then it's not applicable for UWP, I believe.
To using SQLite on UWP, you need to have SQLite itself and wrapper for .NET.
SQLite - SQLite (Visual Studio Extension)
SQLite wrapper for .NET (NuGet) - SQLite.Net-PCL
or SQLite.Net.Async-PCL
And, following link may helps you. It's a VB guy's blog =) but very insightful for uwp works.
Win10 apps in .NET - references
Edited 7 Feb 2017: Windows 10 Anniversary Update(1607) support the SQLite as "Microsoft.Data.SQLite".
Using SQLite databases in UWP apps - Windows blog
Looks like Microsoft is building a version. As of this comment, they are in release candidate 1.
https://github.com/aspnet/Microsoft.Data.Sqlite
go to http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and download the right installer for the .net framework youre using.
this will register the dll's for you and give you everything you need
Since the Windows 10 Anniversary Update (Build 14393), SQLite has also shipped as part of the Windows SDK
This link explains everything:
https://blogs.windows.com/buildingapps/2017/02/06/using-sqlite-databases-uwp-apps
SQLite is supported for Universal Windows platform.
C# solution
Install SQLite for Universal Windows Platform Visual Studio extension.
Use SQLite C# API Wrapper Microsoft.Data.SQLite. More information here.
C# or C++/CX solution
Install SQLite for Universal Windows Platform Visual Studio extension.
Add reference to SQLite for Universal Windows Platform extension to your project:
Project => References => Universal Windows => Extensions => SQLite for
Universal Windows Platform
Write your own wrapper using low-level SQLite API in C# or C++.
C++/CX solution
This SQLite-WinRT wrapper is handy for UWP apps written in C++/CX.

Xamarin.Forms could not install package

When creating a new solution within Xamarian studio I get this error
Could not install package 'Xamarin.Forms 1.0.6186'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Is there a certain version of .Net that Xamarian Forms requires for it to be included in the solution? I've tried searching in their documentation but I'm only seeing marketing and not real in depth documentation.
I had a similar issue using Visual Studio and I've found that the following combination in the PCL works:
.NET Framework 4.5
Windows Phone Silverlight 8
Xamarin.Android
Xamarin.iOS
You have created the wrong project type, you created a normal Windows app, and I assume you are targeting iOS/Android or Mac.
Create the project with the correct type and it should work correctly.
If you are using Xamarin Studio for Windows (without also having Visual Studio installed) you need to download the Portable Library Tools. See the Xamarin doc Introduction to Portable Class Libraries.
I had the same problem with my Xamarin project. The problem was, that in the portable Xamarin project Windows Phone Silverlight was set as target. The PCL project from which I created the nuget, didn't reference Silverlight as target. I don't need Silverlight, so uninstalling all nuget packages from my portable Xamarin project, removing silverlight as target and reinstalling the NuGet packages solved it.
I had similar issue using VS and I found solution here - http://forums.xamarin.com/discussion/29674/xamarin-forms-dll-cannot-be-installed
"It looks like your NuGet Package Manager needs to be upgraded. The Xamarin PCL Profiles are installed but NuGet is not recognising Xamarin.iOS as a target framework. You can update NuGet by selecting Tools - Extensions and Updates, then select the Updates tab, then select Visual Studio Gallery. Then update NuGet from there."
I have invested a lot of time trying all the solutions posted here, but none of them helped me... Here is the solution that worked for me (on Windows 10):
1.) Open your .csproj file
2.) Find the TargetFrameworkProfile entry
3.) This entry contains Profile78 for me, therefore I open the folder below
c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETPortable/v4.5/Profile/Profile78/SupportedFrameworks
4.a) If the folder does not exist, then use one of the solutions posted here to install the PLC right on your PC
4.b) Unfortunately, ASP.NET and Xamarin don't like each other, therefore delete all ASP profiles from this folder. For me it was ASP.NET Core 5.0.xml. Obviously this will break your ASP.NET support in VS
5.) Restart Xamarin and have fun!
interesting reading about all that:
https://forums.xamarin.com/discussion/52846/cannot-create-new-xamarin-forms-project-pcl-in-xamarin-studio-win10-vs2015

How do I recompile an assembly targeting the MonoTouch profile?

On http://docs.xamarin.com/ios/about/assemblies it says that if I want to provide my code as an assembly to other MonoTouch developers: "You must recompile your source code to generate assemblies targeting the MonoTouch profile".
How do I do that?
How do I do that with Visual Studio?
How do I do that with msbuild?
I found MonoDevAssist at http://monodevassist.codeplex.com/documentation, but the instruction there said I should copy a bunch of DLLs from "your Mac". I don't have a Mac. I have installed MonoTouch for Android on my Windows machine, but I can't find a directory like the one in that description.
I have installed MonoTouch for Android on my Windows machine
What you likely have is Mono for Android which runs fine on Windows and targets Android.
MonoTouch is another product from Xamarin, targeting iOS (iPhones, iPod, iPads) and it requires a Mac computer.
Even if there's quite a bit of features shared between the two products, in general, you need to look at the documentation for the product you have.
How do I do that?
Simply re-compile your existing source code including reference(s) to the assemblies that are shipped with Mono for Android.
How do I do that with Visual Studio?
Create a new project, e.g. a library, for Mono for Android. Add your source code to the project. Add references to the SDK assemblies you requires. Rebuild your code.

Categories

Resources