I want to experiment with Monogame in F# using Xamarin on OSX. I am able to create a working C# Monogame project and a working F# Cocoa app, but not a working F# Monogame project.
What is the boiler-plate setup for an F# Monogame project?
Are there Monogame F# templates available?
This is not a solution but a work-around: create two projects, one C# Monogame project and one F# console application. Both of these templates should be installed with Xamarin and Monogame.
Create a C# Monogame project
Create an F# console application
Edit the fsproj file so that it has OutputType Library
Link the F# project to the Monogame project
Add the Monogame package to the F# library using nuget
Write your Game class in F#!
Aside from the hassle of creating two projects, the main problem I've found is that every reference used in the F# library also needs to be referenced in the C# library or you will get runtime errors. I'm sure a custom build script could be written to fix this.
Related
I have a problem with the MWArray.dll which is the original dll library from mathworks compiled from Matlab. This dll works under visual studio but not under unity. The goal was to compile under matlab a simple function mycos which calculates a cosinus and uses it under unity with the second dll MWArray mathworks library.
I made a test under Visual Studio and it works well. I have no problem to read the dll and make a call to the mycos.dll class. I made a typical c# project with two references on MWArray and mycos.
But when I try under unity, by putting the two dll under a plugins folder and configure unity 2018 on .NET 4.0 because the dll are compiled with the .NET framework 4.0.
Unity can read the dll but when running I get an error:
NotImplementedException: The requested feature is not implemented.
System.Security.Principal.WindowsIdentity.GetCurrent (Boolean ifImpersonating)
(at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs:166)
If I want to use matlab for a research project which was coded in matlab with advanced high level math functions which going to be difficult to recode under unity with c#. So the easy way is to use compiled package from matlab compiler. So is there someone who did this already?
The solution consists in NOT using MWArray.dll in Unity project because of incompatibility with Mono. Create a Visual Studio project (when creating new select the type "console applicatiion"), it MUST be separated from unity project directory, and use it as an application server; in fact in that app you can use MWArray.dll, remember that you have to configure your project configuration to x64!!! In the Unity project create a client app to communicate with the other server project.
As the title says, is this currently an option? As can be seen in the screenshot, I don't see an option for creating a crossplatform project in Visual Studio. Is there a way around this i.e. is the cross-platform option just there for conveniently setting up the project structure? If so, how should I do this?
The references others have posted are good, except that not all those projects are .Net Standard 2.0, so if you use them, you will need to upgrade later. But even without a current template, creating a Xamarin Forms F# solution is not hard:
Create a new .Net Standard C# Xamarin.Forms project. Delete the .Net Standard C# library, leaving the platform-specific parts.
Add a .Net Standard 2.0 F# library, install the Xamarin.Forms package, and connect the platform projects to it.
Define an App class in this library:
type SomeNamespace.App() =
inherit Xamarin.Forms.Application()
do base.MainPage <- ...
Refer to this in the (C#) platform projects: LoadApplication(new SomeNamespace.App());
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.
Under Visual Studio 2015, I have integrated Android C++ code into Xamarin and it works as expected. Now, I am trying to do the same for iOS and am running into some basic issues.
I am assuming the integration mechanism is the same for iOS as that of Android in the sense that a shared library (probably .so) is created that one can load using DllImport in C# code.
When I try to add a new C++ project for iOS to my solution, the only option that seems to make sense is Visual C++-->Cross Platform-->iOS-->Shared Library. I added this project type as MyTestShared. This actually ends up creating three projects - MyTestShared.Shared, MyTestShared.iOS, and MyTestShared.Android. Project MyTestShared.iOS already has an external method defined as char* iOSInfo(). However, when I try to add project MyTestShared.iOS as a reference to my MyMainApp.iOS project, I see an error "A reference to MyTestShared.iOS could not be added. An assembly must have a dll or exe extension."
Questions:
For Android C++, it generates exactly one project. Why does it create three projects for iOS C++?
How do I add a reference to MyTestShared.iOS? What is it that I am missing?
I see there is an option to create a static C++ library for iOS. Can I reference it somehow in my C# code?
Regards.
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!