Introduction to Mono on macOS
Mono supports macOS version 10.9 (Mavericks) and later.
This is the hello.cs program (not sure if it helps). Please not: I know it is not a WPF or Winforms app; I just want to test if I can get a console app to run on Mac: using System; namespace Dela.Mono.Examples public class HelloWorld public static void Main(string args) Console.WriteLine('Hello World. 'Ey, you can use.NET to do your app for something, but only for console apps if you want to use cross-platform. If you want to use it on any system, please search some different.' Today you can use VS on mac/linux. Today you can have SQLServer on linux. But you cannot compile a simple hello world with graphics on a mac.
You can use Mono on macOS to build server, console and GUI applications. Read below for the options available for GUI application development.
If you are interested in creating native GUI applications, use the MonoMac bindings and our MonoDevelop add-in. Read the description on MonoMac for more information on how to get started. Google photo app mac.
Installing Mono on macOS
You can use Mono either as a runtime to run existing application, or as an SDK to develop new applications with Mono.
Visit the download page to find the latest macOS package. Run it and follow the instructions there, you can either get a basic runtime, or a complete runtime plus a software development kit.
If you plan on developing applications with Mono, we suggest that you also install the MonoDevelop IDE after you install Mono.
The Mono package includes:
- The Mono Runtime
- GUI Toolkits: Windows.Forms and Gtk# for macOS.
- Note: the MonoMac GUI toolkit for native macOS GUI development is currently a separate download.
- SDK: C#, Visual Basic compilers, assemblers and tools
- XSP ASP.NET server
- Manual pages.
This package installs as a framework into
/Library/Frameworks/Mono.framework
(the same way the Java packages are installed). The executable binaries can be found in /Library/Frameworks/Mono.framework/Versions/Current/bin
. If you’d like to access the mono manpages you’ll have to add /Library/Frameworks/Mono.framework/Versions/Current/man
to your manpath. The macOS Mono package does not include Gtk#, XSP or mod_mono. These will have to be compiled from source.Our packages currently require macOS 10.9 or better, for older versions, you will need to build from source code.
Using Mono on macOS
At this point, you must use Mono from the command line, the usual set of commands that are available on other ports of Mono are available.
To build applications you can use “mcs”, to run then you can use mono.
From a Terminal shell, you can try it out:
Most users would be using the MonoDevelop IDE to create their projects.
You will have a choice of GUI toolkits for building your application, from pure cross platform, to Mac-specific using MonoMac.
32 and 64 bit support
The Mono packages published on this web site provide both a 32-bit and a 64-bit Mono VM.
Starting from Mono 5.2 the
mono
command defaults to 64-bit, you can use the --arch=32/64
switch to control the bitness.The 64 bit support has a few limitations today:
- Our Windows.Forms implementation uses Carbon, and as such, it would not work with a 64-bit Mono.
Building Client Applications
![Mono Mono](/uploads/1/3/4/2/134293353/888541768.jpeg)
There are a few choices to build client applications on macOS, you should pick the technology that better fits your goals, your choices are:
Toolkit | Runs on Linux | Runs on Windows | Runs on Mac | Binding Style | License | Status |
MonoMac | no | no | yes | Strongly typed C# binding to Cocoa APIs | MIT X11 | Actively developed, builds on the design lessons from MonoTouch but still incomplete. This will be the new default binding for Mono on macOS. Separate download. |
Gtk# | yes | yes | yes | Strongly typed C# binding to the cross platform Gtk+ API. Applications look foreign on macOS. | LGPL v2 | Actively developed, cross platform. Bundled with Mono. |
Windows.Forms | yes | yes | yes | Cross platform implementation of Microsoft’s Windows.Forms. Applications look foreign on macOS. | MIT X11 | The Windows.Forms API was frozen in time by Microsoft. Bundled with Mono. |
MonObjc | no | no | yes | Binding to the native Cocoa APIs, but requires manual use of Objective-C selectors to work with, relatively thin wrapper around the underlying APIs. | LGPL v3 | Actively developed. Separate download. |
CocoaSharp | no | no | yes | Binding to the native Cocoa APIs, but requires manual use of Objective-C selectors to work with, relatively thin wrapper around the underlying APIs. | MIT X11 | No longer developed, no longer maintained, deprecated. Bundled with Mono. |
Running Mono applications on macOS
Running applications on macOS is very similar to linux systems, from the terminal:
For GTK# applications, it’s easiest to run them the same way but using xterm from X11.app
Windows.Forms
Mono’s implementation of the System.Windows.Forms API is built on top of Carbon and can only run with Mono on 32 bit systems. The look and feel of System.Windows.Forms applications mimics the Windows style and does not currently render like a native macOS application.
Third Party Libraries
ObjC# is a transparent two way bridge that allows the CLR to access the rich underlying ObjectiveC frameworks as well as providing direct access to the CLR frameworks from the ObjectiveC language.
Uninstalling Mono on macOS
Install Mono On Mac
Run this script in a terminal:
Yesterday I decided to install Mono onto my MacBook to enable .NET development. Below I have listed the steps I took to accomplish compiling and running a Windows Forms hello world style application and packing it into an app bundle so I can run it by double clicking the icon.
The reasons for doing this are twofold;
* I spend most of my time at work professionally developing .NET applications using Visual Studio, so obviously I'm interested in using .NET also on the Mac.
* I'm thinking of writing an experimental Push Notification Service backend in .NET and would rather avoid having to launch Windows to do this.
Requirements
Leopard (Supposedly works on Tiger as well, but then you need to install X11 to make Windows Forms applications work)
Installation
1. Get Mono for Mac from the Mono Project website. I grabbed version 2.4, the latest stable version as of this article's publication.
2. Run the installer. Mono installs under '/Library/Frameworks/Mono.framework'.
Mono Download Mac
Hello World on the command line
3. Compile a command line hello world tool:
hello.cs file contents
Compile using the 'gmcs hello.cs' terminal command.
4. Run using the 'mono hello.exe' terminal command. The 'Hello Mono World' message should be printed.
Windows Forms Hello World
5. Compile a Windows Forms hello world app tool.
helloforms.cs file contents
Compile using 'gmcs helloforms.cs /r:System.Windows.Forms.dll'.
6. Run using the 'mono helloforms.exe' terminal command, and if all is well a message box should be displayed.
Creating an app bundle
7. Use MacPack to package the .NET assembly into an app bundle, which can be launched from the Finder.
'macpack -n:HelloForms -a:helloforms.exe -o:. -m:winforms' on the command line.
8. Launch the app bundle HelloForms.app from the Finder to make sure it works.
That's it really. You are now ready to start development on your enterprise level .NET project using Mono on your Mac.
Additional tips
* MacPack has a really good man page documenting its use.
http://linux.die.net/man/1/macpack, or just 'man macpack' on the command line.
* Simplified compilation using pkg-config
Note that using pkg-config (see if it's setup on your system by running 'pkgconfig' on the command line) you can compile the forms app using 'gmcs helloforms.cs -pkg:dotnet' instead. Not a big difference in this example, but not having to list all needed assemblies will help when compiling more complex projects.
For .NET 3.5 compatibility, you would use the -pkg:dotnet35.
To set it up, add the following line to the '~/.bash_profile' file, if the file does not exist create it: Download dukto app.
References
Windows.Forms and Mac OS/X
http://oepapel.blogspot.com/2005/04/windowsforms-and-mac-osx.html
http://oepapel.blogspot.com/2005/04/windowsforms-and-mac-osx.html
Mono Basics
http://mono-project.com/Mono_Basics
http://mono-project.com/Mono_Basics
Customizing Terminal when Compiling Mono apps
http://dotmac.rationalmind.net/2008/12/customizing-terminal-when-compiling-mono-apps/
http://dotmac.rationalmind.net/2008/12/customizing-terminal-when-compiling-mono-apps/
Archive for the 'firefox' Category
(contains info about pkg-config)
http://wp.colliertech.org/cj/?cat=9
(contains info about pkg-config)
http://wp.colliertech.org/cj/?cat=9