I am using Xamarin to develop iOS and Android application.I have creates one shared project which is common for both platforms.
As I am using database its common and put in shared project.I need to encrypt database, so need to add native sqlite library reference in shared project so that I can modify that code.
My question is : I have not found any way to add reference of other project/library in shared project.
Is that bug or expected behavior?
Any explanations are appreciated.
Thanks.
There are no 'References' from the usual sense of adding a project reference from a Shared Project.
There is definitely scope for a Shared Project to be opened up further than it currently is, however its not, and this is by design, currently, although limiting in some ways.
In short, Shared Projects have no generated outputs. It is from other projects that reference the Shared Project(s) that compilable outputs are generated - based on any conditional compilation symbols that you may have specified.
In order for you to add sqlite library references you need to use NuGet in order to add packages to your solution.
These NuGet packages will then also install and create your platform specific library references appropriate for each platform you are targeting.
If you take a look on your platform specific projects, you will see the References treeview node expand when you add a NuGet package and install it into those projects with the library outputs appropriate for the package.
You can then code in the Shared Project against these NuGet packages that are referenced in your projects.
Update 1:-
If you've added the package from NuGet, most things should line-up perfectly in general unless there is any platform specific stuff included.
If there is functionality that is specific to a particular platform; or for a library that is only added directly to a platform-specific project, then you can use conditional #if statements in the Shared Project to access these platform-specific differences.
Update 2:-
Example:-
1) You have a Shared Project and Android, iOS and WindowsPhone platform-specific projects that reference this Shared Project.
2) Create another new WindowsPhone Class Library Project.
3) Add the following class to it:-
public class MyWindowsPhoneClass1
{
public string SayHello()
{
return "Hello";
}
}
4) In your WindowsPhone platform specific project, add a Reference (in this case it will be a Solution reference as it is part of the same solution) to the new WindowsPhone Class Library Project you created in Step 2.
5) Enter the following code into some function in the Shared Project:-
PhoneClassLibrary1.MyWindowsPhoneClass1 o;
o = new PhoneClassLibrary1.MyWindowsPhoneClass1();
string strResponse = o.SayHello();
and compile.
You will notice you will get compilation errors for iOS and Android, as PhoneClassLibrary1 could not be found.
However....
If you now change the code to:-
#if WINDOWS_PHONE
PhoneClassLibrary1.MyWindowsPhoneClass1 o;
o = new PhoneClassLibrary1.MyWindowsPhoneClass1();
string strResponse = o.SayHello();
#endif
You will see that your project now compiles on ALL 3 platforms due to the use of conditional #if statements.
There is no concept of adding reference to Shared Project in Xamarin.
Shared Project is just a centralised project to shared codebase (like Model and ViewModel) between multiple projects (Android and iOS projects).
Solution:
Add the reference to the Android / iOS project and it will be automatically be accessible from the Shared Project.
References and components are not supported by Shared Projects. So, if you have no platform-specific project, a Shared Project is of no use, as you won't be able to abstract any of the needed references and/or components for your applications.
A Shared Project depends on you referencing it on any other platform-specific project, so you'll be able to use all references and components this platform-specific project uses.
To reference the Shared Project on any platform-specific application, right click the References folder of that application and select Edit References..., select the tab Projects and check the box of your Shared Project. After that, you can use any reference of that application on you Shared Project.
Related
I am new to a custom function. I already have a react project. I want to use one custom function in that project. I have read the document about it. It has two options either you can create a react js project or you can create custom function project.
can anyone guide me on "how to create a custom function in react project"?
Yadav, here is one option:
Generate a new add-in project using the yo office "Excel Custom Functions using a Shared Runtime" template.
Compare the following files with what you already have in your add-in project to identify the changes you need to make to add custom functions to your project: manifest.xaml, package.json, webpack.config.js.
Copy new files that identified in step 2 from the project you made in step 1 to your add-in project.
Make the changes identified in step 2.
Office add-ins that combine two kind of features - custom functions and, for example, react web app are run all of its code in a single shared runtime. A shared runtime isn't a type of runtime. It refers to a browser-type runtime that's being shared by features of the add-in that would otherwise each have their own runtime. Specifically, you have the option of configuring the add-in's task pane and function commands to share a runtime. In an Excel add-in, you can configure custom functions to share the runtime of a task pane or function command or both. When you do this, the custom functions are running in a browser-type runtime, instead of a JavaScript-only runtime as it otherwise would.
See Configure your add-in to use a shared runtime for information about the benefits and limitations of sharing runtimes and instructions for configuring the add-in to use a shared runtime. In brief, the JavaScript-only runtime uses less memory and starts up faster, but has fewer features.
I am trying to publish a WPF application using the publish section in the project properties. When I attempt to specify application files (i.e. references) for the publish, I see lots of old dlls that were once in the project but were deleted later.
Is there a way to clean up this list so that it matches the references actually used in the project ?
It is not possible without extensions. However you can check this question for more details. There are also some extensions listed you could use.
I'm porting a WPF app over to Windows Store app. I have some view models that I would like to put into a Portable Class Library. That code uses reactiveui framework. I created the library and I use nuget package manager to add reactiveui to the project. I get this:
Could not install package 'reactiveui-platforms 5.4.0'. You are trying to install this package into a project that targets 'portable-net45+wp80+win', 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 this really an unsupported configuration or am I doing it wrong?
ReactiveUI-Platforms is specifically only the platform-specific code. You need to just reference ReactiveUI-Core in your PCL and reference ReactiveUI-Platforms in your WPF and Windows Store apps, and everything should work.
I'm new to Xcode so not really keen on it yet. In my college is used visual studio to program in C in which they create a solution and fill it with an application and then include static libraries with .h and .c files. Been trying to do this in Xcode but can't seem to include them or add dependencies like in Visual Studio
One approach is just using the standard gcc command line options for static library linking which you can specify using the XCode project settings. This will work if the static library is installed and accessible in the standard locations.
Alternatively you can add a static library explicitly to your project and set the dependencies and search paths for headers etc appropriately. This may sound a bit involved, but there's not really that much to do, and you only need to set it up once. It's all done in the same place as other project settings, and you can use the search box to find exactly where to enter the options.
I'm assuming you don't want to actually build the static library with your project. if you do there's more to do - basically you need to set up the static library project, set it as a target dependency, and setup a build step to copy the resulting library.
I am new to MonoDroid so maybe there is an easy answer, but so far searching hasn't turned it up... Since deploying to the Android emulator takes _for_ever_ on my PC, I would like to put most of my logic into a separate library and test it from a separate winforms application. Later, I can build a regular MonoAndroid application that provides the UI and just calls the library. However, when I try to link to the MonoAndroid class library I get this message:
Warning 1 The project 'MonoAndroidClassLibrary1' cannot be referenced. The referenced project is targeted to a different framework family (MonoAndroid)
Is there another way to achieve this objective? Yes, I could simply create a separate standard windows library and copy/paste the code between the two, but there must be a better way
You can use this extension http://msdn.microsoft.com/en-us/library/ff921108%28v=pandp.20%29.aspx
You would need to create a regular .Net 2.0/3.5/4.0/etc class library and copy (or link) your source code files into it. Use this assembly for testing in winforms, and the Android class library copy for Android.
Of course, this will only allow you to write code that doesn't reference anything in the Mono.Android.dll assembly.