Requiring unreferenced assemblies to be included in Xamarin App package - xamarin

I have a Xamarin Forms app that requires me to dynamically load a single one of several possible assemblies at runtime (based on versioning). This should not be a problem as iOS can load assemblies using the mono interpreter. The problem I face is that the IPA and APK packages do not include the assemblies because they are not referenced directly in the app. I include them in the project references but they do not appear in the app package.
Is there a way to tell Xamarin to always include an assembly in the package regardless if it is being directly referenced in code?
==UPDATE==
I have a complete working POC with what I am trying to accomplish in terms of versioning in the application.
https://github.com/rlasker-b2w/XamVersioning
I specifically have to add references in the VersionSelector class otherwise the version projects do not get their assemblies added to the app package.
https://github.com/rlasker-b2w/XamVersioning/blob/main/VersionApp/VersionSelector.cs

Related

How to add .framework native references to Nuget Package

I built a Xamarin Binding project for an existing Swift library and I am now trying to create a Nuget Package to distribute it.
The library has three native references to Swift frameworks and I don't see any option to include them. When I try to look inside the Nuget package, I don't see them. When I try to compile an app that uses the package it crashes because it can't find the native framework.
Any idea on how to solve the problem ?
Thank you

Missing namespace of existing library, Xamarin Android

I have an auxiliar project that contains Java libraries used in the project. That project contains a folder with a mbwaysdk.jar and a WheelPicker-1.1.1.aar in it.
After building that project, it generates the .NET classes for the mbwaysdk.jar without any problem, but the classes of WheelPicker-1.1.1.aar don't show up. I've checked and the obj/Debug/generated/src folder contains the file classes for the mbwaysdk.jar and WheelPicker-1.1.1.aar libraries.
Within Visual Studio, the namespace Com.Aigestudio.Wheelpicker isn't recognized, although the project succesfully builds and deploys to devices, and any usage of the Com.Aigestudio.Wheelpicker views and methods works. While in debug I'm able to inspect the object, but unable to navigate to the class.
What can be causing this issue?

Adding System.Data.SQLite through NuGet doesn't add a reference to the project

I'm trying to make a very simple Xamarin.Forms test application to explore some features of the System.Data.SQLite package (namely encryption). However, I can't seem to get Visual Studio 2012 to add a reference to the package to the project.
Here are the steps I am taking:
Created a new Xamarin.Forms Portable blank app.
Right-click on TestApp (core project) and select Manage NuGet Packages
Search for "sqlite"
Install the "System.Data.SQLite (x86/x64)" package. (This package is version 1.0.97.0 and it is described as "the official SQLite database engine for both x86 and x64 along with the ADO.NET provider.")
According to NuGet, the package was successfully installed.
However, I cannot see the reference added under my project's "References" folder, and I also cannot write "using System.Data.SQLite" without errors ("cannot resolve symbol 'Data'"). Does anyone have any idea why this is happening?
On a side note, I can follow the exact same process described above except instead of creating a Xamarin.Forms Portable blank app, I choose a regular C# console app. This allows me to install the NuGet package fine and it shows up in references as expected.
Posting an update to share what I've learned.
So as Jason sort of alluded to in his answer, the reason I was not able to reference the package in my Xamarin.Forms project is because Xamarin.Forms is, by definition, a PCL project. It's meant to work on all platforms. The package I was referring to in my question is not a PCL, which means that anything in the package that is platform dependent is inaccessable (which is basically the entire package). The SQLite.Net-PCL package is basically the same thing as System.Data.SQLite, but in PCL form, which means it is compatible for use in a Xamarin.Forms project.
Following this logic, it makes sense that I was able to access System.Data.SQLite from a console project, since a console project is not a PCL project and it targets a specific platform.
For PCL projects, use SQLite.Net-PCL.

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.

Parse and Xamarin

I am using Xamarin and I was wondering if there is a way to run Parse in a shared project, so that I don't have to duplicate my code in the iOS project and the Android project in my solution?
Am I missing something, or do I really have to duplicate the Parse code?
What I did was create a Shared Project type to host my Parse specific Code. Then in my Xamarin.Android app, I reference the Parse.Android.dll. In my Xamarin.iOS code, I referenced the Parse.iOS.dll. Remember, that the "Shared Project" type does not create a DLL. Underneath the hood it's just file linking into your actual project, so it will use the references of that project. The Shared Project should not contain any iOS or Android specific code.

Resources