Xamarin Shared Code Project Created In Visual Studio For Mac
At this morning’s keynote, Nat Friedman and James Montemagno introduced, the newest member of the Visual Studio family.Visual Studio for Mac is a developer environment optimized for building mobile and cloud apps with Xamarin and.NET. It is a one-stop shop for.NET development on the Mac, including Android, iOS, and.NET Core technologies. Sporting a native user interface, Visual Studio for Mac integrates all of the tools you need to create, debug, test, and publish mobile and server applications without compromise, including state of the art APIs and UI designers for Android and iOS.
Both C# and F# are supported out of the box and our project templates provide developers with a skeleton that embodies the best practices to share code across mobile front ends and your backend. Our new Connected Application template gives you both your Android and iOS front ends, as well as its complementary.NET Core-powered backend. Once you’re up and running, you’ll find the same Roslyn-powered compiler, IntelliSense code completion, and refactoring experience you would expect from a Visual Studio IDE. And, since Visual Studio for Mac uses the same MSBuild solution and project format as Visual Studio, developers working on Mac and Windows can share projects across Mac and Windows transparently.
With multi-process debugging, you can use Visual Studio for Mac to debug both your front end application as well as your backend simultaneously. Mobile-First Visual Studio for Mac provides an amazing experience for creating mobile apps, from integrated designers to the code editing experience to the packaging and publishing tools.
It is complemented by:. The full power of the beloved-by-millions C# 7 programming language. Complete.NET APIs for Android, iOS, tvOS, watchOS, and macOS. The Xamarin.Forms API abstraction to maximize code sharing. Access to thousands of.NET libraries on NuGet.org to accelerate your mobile development. Highly optimized native code backed by the LLVM optimizing compiler But we know apps don’t stop at the client, which is why I am so excited about what Visual Studio for Mac brings to backend development, as well.
Check out the for a complete list of what’s included in this product. Cloud-First It is rare these days for mobile applications to run in isolation; most of them have a backend that does the heavy lifting and connects users. You can use.NET Core to build your own backend services and deploy these to your Windows or Linux servers on Visual Studio for Mac, while the project templates will get you up and running with an end-to-end configuration.
Additionally developers can easily integrate Azure mobile services into their application for things like push notifications, data storage, and user accounts and authentication with Azure App Services. This is available in the new “Connected Services” project node. Whether you are rolling out a custom backend with ASP.NET Core, or consuming pre-packaged Azure services, Visual Studio for Mac will be there for you. Check out the for a complete list of what’s included in this product.
What’s Next Today we released the first preview of Visual Studio for Mac, a member of the Visual Studio family, and the story is just beginning. In the coming months we will be working with the Visual Studio and Visual Studio Code teams to bring more features that you love to the Mac, from advanced Web editing capabilities to support for more programming languages via the Server Language Protocol. Visit the page and take it for a spin. We look forward to hearing your feedback! Miguel de Icaza, Distinguished Engineer, Mobile Developer Tools Miguel is a Distinguished Engineer at Microsoft, focused on the mobile platform and creating delightful developer tools.
With Nat Friedman, he co-founded both Xamarin in 2011 and Ximian in 1999. Before that, Miguel co-founded the GNOME project in 1997 and has directed the Mono project since its creation in 2001, including multiple Mono releases at Novell.
Xamarin Shared Code Project Created In Visual Studio For Mac Windows 10
Miguel has received the Free Software Foundation 1999 Free Software Award, the MIT Technology Review Innovator of the Year Award in 1999, and was named one of Time Magazine’s 100 innovators for the new century in September 2000. This is a beautiful app. A bug exists in NuGet though, if you have any sources that are using encrypted credentials it will cause the NuGet Package Source preference to not show any sources. You have to remove it manually via the command line (nuget sources remove -name “TheSource”). After you’ve done that, you’ll be able to see/add a source, but the GUI won’t allow ANY sources with credentials to be saved. I was able to get something in there by adding my source without credentials (As you can’t save a new source that has a user/pass for some reason in the GUI), then edit to add those credentials. Upon saving, it gives an error that it can’t write to /.nuget/config/NuGet.config.
Adding cleartext credentials via terminal works though. Xamarin Workbooks & Inspector installation failed with more than one exception (Attempt #Xamarin Workbooks & Inspector) Some installation errors are present. Exception type: System.AggregateException Message: Some installation errors are present. It is definitely the case that UWP is not supported at this time.
Hey, Microsoft, can you please explain this? It’s difficult for me to consider making UWP apps if Microsoft seems to be downplaying them. Recent reports of UWP apps being used by only a tiny fraction of Windows 10 users makes this even less desirable.
(A quick survey of people close to me using Windows 10 confirms that few have even tried such apps — mot one uses a UWP app on a regular basis. Anecdotal1 of course, but Microsoft has said nothing at all about this that I’m aware of — leads me to believe it may be true.). I’m truly sorry if it appears that we’re downplaying UWP. That’s not our intent, though I totally see how it could appear that way when VS for Mac doesn’t build for UWP by default.
I’ve heard many developers say they think of Visual Studio and Windows development synonymously, so I can see how it might seem strange at first that a Visual Studio product doesn’t build for UWP. When you peel back the layers, though, I think it makes a lot of sense. I hear from more and more developers who want to target Windows and iOS and Android. They say we live in a “multi-platform” world where it’s not viable to target only a single operating system.
For those of us at Microsoft building developer tools, we want to empower developers to fulfill the needs of their business. Today, that means enabling development for all the major platforms. When I talk to developers building for UWP, they almost universally prefer to develop on Windows. To enable iOS development on Windows was a multi-year effort we undertook because Windows developers wanted to stay in Visual Studio on Windows, but their businesses required them to build for iOS. Thus, we’re working hard to create the best possible UWP development experience in the environment Windows developers like best: Windows. UWP was a last desperate attempt to fill the App Gap for Windows Mobile. I did not work.
Windows Mobile is left for dead, the current “its for business users only” state is just intermediate. MSFT keeps telling otherwise, but its written on the wall: UWP is left behind by.Net Core, by VS2017, same applies to.Net Native on which UPW is partially based. Intel has abandoned Broxton, so there will be no surface phone. If you develop for Desktop only, as Windows Mobile is out of scope, why bother with UWP? The ship is sinking, time to abandon it. MSFT just needs some time to finally admit it.
If I do a Visual Studio Update, i see “Xamarin Profile 1.0.1” is available. But if i press “Install Update” I get an error telling “Failed to start update installer”.
I don’t wan to be mean, but VS for Mac looks ugly. Maybe it is time for your to make WPF cross-platform and reuse the wonderful VS GUI? Of course, Mac is ugly by itself and usability is not something that Mac users want, so I am sure no-one will notice the current ugliness. Certainly not me! I am not planing on using a Mac like. 😀 This seriously looks similar to the Xamarin Studio though.
Is it the same IDE?:^) Is this freeware? Mac users have a lot money for waste. Feel free to ever-charge them. I’m trying to load a sizable.NET Core project with multiple types (several assembly libraries, and several apps that use those assembly’s for different things).
This works great in Visual Studio 2015 (Community Edition) + Resharper using the.sln files, or in VS Code using the global.json on Windows or OSX 10.11. Visual Studio for Mac gives the following error for each sub-project when I load the.sln file: Error while trying to load project: “/my/project/path/library1.xproj” Unknown solution item type.
Error while trying to load project: “/my/project/path/library2.xproj” Unknown solution item type. Error while trying to load project: “/my/project/path/library1.Tests.xproj” Unknown solution item type.
Error while trying to load project: “/my/project/path/app1.xproj” Unknown solution item type. Error while trying to load project: “/my/project/path/app2.xproj” Unknown solution item type.
Any ideas on how to this make this work? I’m VERY excited about VS for Mac Something I thought I’d never see!
I’ve been working with a team on a mobile app for iOS and Android using Xamarin Studio for Mac, and downloaded VS for Mac to try it out, but ran into some serious problems. I cannot say for certain that these problems were caused by VS for Mac, but the evidence points that way, so I wanted to report my experience here: 1) App working fine in XS.
2) Downloaded VS for Mac, app worked fine running there. 3) Next day when I launched VS for Mac, it complained about not having Mono, and so I clicked the option to install it.
This had me concerned, but I thought perhaps VS had some specific requirements it needed for an update (since it hadn’t complained and worked fine the day before). 4) Now the app will not run in either VS or XS. It simply hangs on launch, never making it to the ‘main page’. 5) This same behavior happened on a second machine as well. 6) On a 3rd machine with XS only, where VS was never installed, things continued to work just fine.
7) Tried lots of troubleshooting steps with reinstalling Mono, uninstalling VS for Mac, and more Ultimately, the only thing that got me up and running again was going through a FULL uninstall of VS and XS , then a reinstall of XS, and I think I’ll be holding off on re-installing VS for Mac until another update comes out. Looking forward to a smoother experience in the future Hope this is somewhat helpful for someone running into similar issues, or perhaps for the VS Mac team.
Keep up the great work! There is no point in making a macOS-specific IDE for macOS.
Apple already has one, called Xcode, and there is no point in competing with a native (direct from the developer) developer tools which is, overall, even cheaper than Visual Studio Community (when you factor in the “Exceptions” VSC carries). Also, anyone not Apple would be consistently chasing Xcode (behind the 8 ball).
This is similar to the issues 3rd party developer tool vendors had on Windows. Most of the native Windows Developer Tool vendors are gone. The ones left are most for Non-Microsoft Development Languages, or (for the most part) fairly vestigial or Legacy (Visual dBase, Delphi/CBuilder, etc.).
I’m speaking of the commercial tool vendors. He who owns the platform always has a massive innate advantage when it comes to developer tools. I am trying to run the default.net core web app.
But I explicitly installed.Net Core 1.1 and want to use it. When I run it after restoring the packages. It says ” he specified framework ‘Microsoft.NETCore.App’, version ‘1.0.1’ was not found.
– Check application dependencies and target a framework version installed at: /usr/local/share/dotnet/shared/Microsoft.NETCore.App – The following versions are installed: 1.1.0 – Alternatively, install the framework version ‘1.0.1’. WARNING: The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use Microsoft.NETCore.App 1.0.0 or newer. This may be expected if the target process did not run.NET code. The program ‘/Users/krishn/Projects//xxx.dll’ has exited with code 131 (0x00000083). ” I then went to Preferences of VS.NET and tried to add a new.NET Runtime, but then when I navigate to the folder containing.net core 1.1, the IDE gives an error in a dialog that says ” Mono runtime not found.
Please provide a valid directory prefix where mono is installed (for example, /usr).” I don’t know why it is saying Mono. Also I don’t see any projects.json or any sort of framework dependencies configuration file in the created WebApp scaffolding.
Any help on what I am missing? I am basically from Windows background, but now trying things on MAC. While in the installer, it asked me to select the components I like to install, I only checked Xamarin.Mac, and even tried installing only Xamarin Profiler. When I click continue, I see the “Please configure the installation” message and there is “Private copy of Android SDK installed by Xamarin.Android”. I tried looking for it in the provided location but there’s no folder matching the name.
If I click continue, it says it will install 3 components, these are Android SDK, Xamarin.Mac and Visual Studio for Mac Preview. As mentioned, I unchecked Android component, so why am I seeing this component being installed?
I can’t even continue with the installation process because it always fails in downloading the android thing. Does VS for Mac share the same components as Xamarin Studio? I have an up-to-date Xamarin studio installed, and it appears VS 4 Mac wants to install the same components. In addition, it appears VS 4 Mac wants to install Android SDK. I already have android studio and the sdk installed. A preview version installing expensive duplicate clutter or, worse, overwriting stable release software components, is not a potential step I’m willing to commit to blindly.
Lastly, what is the ETA on stable/production release? 2017-01-13 02:46:19.898 Info Installation ID: 0a7ffa89-ce68-4da1-9ad2-01e018196f5f 2017-01-13 02:46:19.907 Info Operating system: Mac OS X v10.12.2 (10.12.2; Mac OS X 10.12.2 (10.12.2 build version: 16C67)), 64-bit 2017-01-13 02:46:19.915 Info Installer product: Visual Studio for Mac Preview 2017-01-13 02:46:19.921 Info Installer version: 3.5.0.208 (HEAD detached at b49471a) (b49471af6b0aeb2ea6f09740ae80b613dba3f0bd on 19:10:50) 2017-01-13 02:46:19.926 Info Status: in progress 2017-01-13 02:46:22.778 Debug Waiting for manifests to finish downloading. 2017-01-13 02:46:22.784 Debug Initial task executing (WaitingForActivation).
Waiting for it to finish. 2017-01-13 02:47:38.345 Info Initial task completed successfully 2017-01-13 02:47:38.352 Info Status: aborted by user 2017-01-13 02:47:38.361 Info No network connectivity. Falling back to embedded manifest. Software might be older versions than currently published! 2017-01-13 02:47:38.369 Debug Detection complete on the introduction page, determining the next step.
2017-01-13 02:47:38.378 Info Determining list of software items to install. 2017-01-13 02:47:38.386 Debug Processing update nodes from the manifest.
Overview In a recent post to software decision makers, I discussed reasons businesses should consider cross-platform native development over website development. You can read the previous Xamarin Tutorial post. In the post, I gave a case to use the Xamarin toolset, why it should be considered, and why it could be a good business and development decision for your organization. In this Xamarin Tutorial series, I will be building a solution that can be used as a starting point for cross-platform applications using the Xamarin toolset. Today I will be focusing on the following:.
What is Xamarin?. How to Setup the Xamarin development environment using Microsoft Visual Studio. Briefly talk about iOS support. Discuss Shared vs Portable Class Libraries (PCL) strategies and how to use both.
Connecting to your Mac to debug an iOS version of your application. Using the Visual Studio iOS Simulator to debug your iOS application Xamarin – What is it? Before we start diving into creating our solution, I will include a snippet from the post mentioned above that gives you an overview of Xamarin. After this explanation, my assumption will be that you at least know what it is and why we are using it.
Is a Microsoft owned company that started with the engineers that created the popular, and, which are cross platform implementations of the Common Language Infrastructure (CLI) and the Common Language Specifications, also known as.NET. Xamarin uses a shared C#/.NET codebase along with either Xamarin Studio or Visual Studio, to write native Android, iOS, and Windows Apps. Did you understand that? Yes, native applications. Wow, so, all your code is 100% shared.
Again, not exactly. For most simple UI patterns, Xamarin.Forms allows you build native user interfaces for iOS, Android and Windows using 100% shared C#.
It also includes dozens of controls and layouts which are mapped to native controls in their respective platform. Depending on your application needs, however, you may need to access a platform specific feature, such as Live Tiles for Windows, or maybe you need to create a custom control that isn’t a native control for any of the platforms. In these scenarios, Xamarin provides a means to call into platform specific code. However, check this out, wait for it wait for it it is still in C#. So, as you can see, the App Logic and most of the user interface code is shared across all platforms. In fact, there is even a community of user-built components that you can leverage in your application using both and the.
Development Environment – The Microsoft Way Now that we have the basic definition and understanding of what Xamarin is, we can put that behind us and make sure that we have the tools necessary to start developing. For this, my plan is to stick with as many Microsoft technologies as possible. Visual Studio So, first in this Xamarin Tutorial, I am going to assume that you are using Windows 10 and have a flavor of Visual Studio 2015 installed on your machine.
Even under that assumption, we need to make sure that you have the Xamarin tools installed. Luckily, this is easy. First, make sure that you don’t have any instances of Visual Studio currently running.
Next, open your Windows Settings application and type add or remove in the search box. Select Add or remove programs from the dropdown list.
You will be taken to the Apps and Features section of settings. Scroll down and select Microsoft Visual Studio 2015. Now select Modify. You will be prompted to give permission to the installer.
Give it permission by selecting Yes. You should see the Installation program initializing. If you didn’t shutdown Visual Studio 2015 before you selected Modify, the installer will notify you and recommend that you close Visual Studio now. If you did forget to close Visual Studio or skipped that step entirely, close Visual Studio now and select Retry.
If Visual Studio is closed, the installer should provide you an option to modify the current installation. Select Modify.
After selecting Modify, you will see a list of all the features currently installed. Since our goal in this Xamarin Tutorial series is to create a cross platform application, verify that all the Cross Platform Mobile Development features are enabled. We aren’t going to use all of features, but if you know you are going to do cross platform development and you have the space, install it now and forget it, you will have all the tools necessary for the future. Since I already have the features installed, I can be assured that all the necessary tools are installed for me to start developing cross platform applications. If some of the features weren’t enabled for you, make sure they are and select Update. This will install all the tools for you. IOS Support If we plan on having iOS support for our application, Xamarin.Forms does support it.
So, yes, you can create iOS applications on Windows using C#.NET. However, you will need a networked Mac running OS X Yosemite (10.10) & above with XCode 7 installed. You will also need to install the Xamarin.iOS tools onto the Mac. The best way to do this is to use the Xamarin Unified Installer, which will install everything you need.
You can view these instructions. I will assume that you have XCode and the Xamarin.iOS tools setup on your Mac. However, I will discuss how to attach to your Mac, build and run/debug the application later in the post. One thing we can do right now is setup the permissions to allow us to debug our application on the iOS simulator on the Mac.
First, on your Mac, search for Remote Login in Spotlight. Select Sharing. Select Remote Login and make sure that your account is in the list of Allow Access for: Only these users.
I am an Administrator on my Mac, so I will just allow all Administrators. NOTE: You could allow All Users to have remote access, but, I am not sure that is a good idea. Your Mac should now be discoverable in Visual Studio.
Again, we will talk more about this later. Create a New Project Blank Application Now we can create our new project.
Open Visual Studio, select File, New, Project Next, select Installed, Templates, Visual C#, Cross-Platform. Then, select Cross Platform App (Xamarin.Forms or Native). Enter the name of your project.

Make sure the directory is correct and then select OK. Another dialog prompting for the type of cross-platform project will be displayed. Select Blank App, Xamarin.Forms, Shared Project and then select OK.
Visual Studio will start creating your Xamarin solution. However, since we are targeting Universal Windows Platform applications in our project, you will be prompted for your Target and Minimum versions of Windows. I have chosen to target Windows 10 Anniversary Edition with a Minimum version of Windows 10 (Build 10586). Once you have made your selection, select OK.
You will also probably see the following dialog while it is creating the solution. When it is finished, you should notice that there are several projects in your solution. One for each of the platforms we will target with our application. Along with the iOS, Android and UWP projects, you should also notice that there is a Shared project.
I know, I kind of blew past that part when I had you select the Code Sharing Strategy shared project. I did this on purpose, I will explain this in more detail now. Xamarin uses a couple of strategies for sharing code within our Xamarin solution: Shared and Portable Class Library (PCL). Shared Strategy The shared strategy basically takes each file in the shared project and compiles it under each of the other projects. Think of it as making a copy of the files in the shared project into each specific platform project and then doing a build. You can still do platform specific code in the shared project by using #if compiler directives, but be cautious, your code can, and probably will, become ugly fast.
Note: the shared project isn’t really a traditional project that gets built into an assembly. You can’t actually build it. Portable Class Libraries (PCL) With portable class libraries, the code is compiled separately and referenced in each project like any normal class library. The big difference here is that you have access to a subset of.NET that is compatible with all the target platforms. So, for example, you could use System.Net.Http, but trying to access hardware, such as, the camera API is not available. You could, however, use a generalized interface that uses dependency injection.

Both Shared and Portable? So, as you can see, each strategy mentioned above, contains some pros and cons. So, it really depends on the type of application and how much external sharing you are going to need to do with the code.
Simply put, if you are going to share code outside of the application itself, PCL’s are a good choice. However, if this is a one-time application with no externally shared code, the shared strategy would be a good choice. That being stated, what if we want to use both? Can we do that? To answer your question, yes.
What if you have a lot of shared code between applications, but you also have a significant amount that is just shared across your specific application? In fact, let’s add a PCL to our project for any code that we might want to share with other applications we write in the future. We won’t do anything with it right now other than wire it up for use in my next blog post.
First, right-click on the solution, select Add and then select New Project From here, we want to repeat the same steps we used to create the solution, but in this case, we want to select a class library. Select Installed, Cross-Platform, Class Library (Xamarin.Forms). Enter the name of your shared class and select OK. Okay, now, one thing you should know is, by default, the project will add a Xamarin ContentPage, XamarinBlog.CommonServices.cs. You can go ahead and delete it now. Okay, we now have a portable class library in our solution, however, it isn’t being referenced. So, go ahead and reference it in each of the platform specific projects by right clicking on references and selecting Add Reference Select Projects, then Solution, then select your new PCL from the list.

Finally, select OK. Okay, now that we have our PCL referenced in each project, you should be able to build most of the projects. As far as the iOS project, we really haven’t talked about how to connect to your Mac for building, so let’s do that quickly. Connecting to the Mac For us to build our iOS project, we will need to connect your Visual Studio iOS project to a Mac. To do this for the first time, all you do is attempt to build the project. Right-click on the project and select Build.
If you haven’t connected before, Visual Studio will display instructions for setting up the remote login functionality on your Mac. Since we already did this earlier in the post, we will skip them and select Next.
If you would like, you can turn off the instructions for next time, however, if you are like me, I forget the “setup once and forget” things, so I usually leave mine unchecked. You will now be prompted to pick your Mac. For it to show up in the list, you must have setup remote access properly and the Mac bust be on the same network as Visual Studio. Select your Mac and then select Connect. Next, you will be prompted for your username and password. Enter your credentials and select Login. Once you have selected Login, it will attempt to connect to your Mac.
If it is successful, you will see a link under the Icon for the machine you selected. Once you see this, select Close. Now, go ahead and try to build.
I should build successfully if everything on your Mac is setup correctly. Can I see Something? I know, we have done a lot up to this point and we haven’t seen a darn thing.
Well, before we run the application, I do want to mention a couple more things. First, let’s look at where this whole application starts in code. Where is the application object for this thing? In the shared project, XamarinBlog, open App.xaml.cs. Notice this is where our Application object for all our projects resides. How do we know what page to load first? Check out the constructor.
Notice that we assign XamarinBlog.MainPage to the MainPage property of our application. Also, you may have noticed that there are a number of events that are created for us: OnStart, OnSleep and OnResume. These are application lifecycle events that get fired for each platform. We will probably talk more about these in later posts in this series.
Let’s look at the XamarinBlog.MainPage object in Mainpage.xaml and see if we can figure out what this page is going to be presenting us. Select MainPage.xaml. Looking at the markup, we see we are creating a ContentPage with a label, that has the text ‘Welcome to Xamarin Forms!”, and it is centered in the middle of the page. Now that we know what it is supposed to do, let’s see it in action. Build and run the application for each platform and see what you get. It should look something like the following: Cool, right?
Three platforms, mostly the same code. Well at least the UI, so far. Using Visual Studio iOS Simulator It is nice to be able to debug on your Mac, but I must admit, it is kind of a pain at times to be forced to sit by the machine to test your application. Well, a cool new feature for Visual Studio is the Visual Studio iOS Simulator. This add-in for Visual Studio allows us to debug our iOS version of the app right on our computer.
So, you don’t need to be near your Mac to do the debugging. You can do it right on your PC. To get the add-in, download the installer. You might have to restart Visual Studio for changes to take effect.
Once you do, make sure that you select iPhoneSimulator and run the application again. You should see the Visual Studio iOS Simulator with your application. If for some reason, you would like to disable the Visual Studio add-in and go back to debugging your iOS application on the Mac you can do so. All you need to do is select Tools from the main menu and then select Options Scroll down to the Xamarin tab and select iOS Settings. Uncheck the Remote Simulator to Windows checkbox and select OK. Now, you should be able to debug on your Mac again.