Disclaimer: this is an automatic aggregator which pulls feeds and comments from many blogs of contributors that have contributed to the Mono project. The contents of these blog entries do not necessarily reflect Xamarin's position.

September 22

Podcast: Android Oreo, iOS 11, and Xamarin.Forms Tips & Tricks

In this episode of the Xamarin Podcast, James Montemagno and I cover Xamarin support for Android Oreo and iOS 11, share tips for beating the learning curve with Xamarin.Forms, talk upcoming releases in the pipeline, and more! Be sure to download today’s episode from your favorite podcasting app.



Subscribe or Download Today

Keeping up with the latest in .NET, C#, and Xamarin is easier than ever with the Xamarin Podcast! Cohosts Pierce Boggan and James Montemagno cover topics relevant to Xamarin developers, from designing mobile apps to identity management. Be sure to subscribe to the Xamarin Podcast on iTunes, Google Play Music, Stitcher, or your favorite podcast app you use to ensure you don’t miss an episode.

The post Podcast: Android Oreo, iOS 11, and Xamarin.Forms Tips & Tricks appeared first on Xamarin Blog.

September 20

Protecting Your Xamarin Apps with Dotfuscator

This is a special guest post from Joe Sewell, a developer on the Dotfuscator team at PreEmptive Solutions.

Let’s be honest, releasing a library, desktop app, or mobile app can be a bit scary. Once your software is freely available to the world, you lose a certain degree of control over how it will be used. In particular, developers are often concerned with the threat of reverse engineering.

On many platforms and languages, code obfuscation tools are a familiar way to guard against reverse engineering. For instance, if you’re an Android developer, you may have already used ProGuard to shrink and obfuscate Java code.

Now, Xamarin developers have access to that same kind of protection across all major mobile device families, from Android and iOS to Universal Windows (UWP). The tool for the job is Dotfuscator, the Community Edition of which is available in Visual Studio.

Today I’ll explain how obfuscation can protect a Xamarin.Android app from reverse engineering, and how you can apply that same protection to your own Xamarin apps with a few simple steps.

How Obfuscation Protects Apps

Obfuscation is a process where an app’s compiled code is transformed into code that is functionally-identical but harder to reverse engineer. Typically, this is done by an automated obfuscation tool, or obfuscator. Below is a simple example to demonstrate how obfuscation guards apps against reverse engineering.

Consider the following C# method in the source code for a Xamarin.Android game:

When the developers of this game are ready to deploy it to a device, or upload it to an app store, they compile the source code into libraries and then package those libraries into an app bundle. In this example, the developers package the libraries into an APK file for distribution on Android devices.

However, once the app is released to an app store, a bad actor can easily obtain and reverse engineer the APK, producing decompiled code that is nearly identical to the original source code:

Note that the type, method, and member identifiers are the same here as they were in the source code, even if those code elements aren’t normally accessible from outside the project (i.e. they were marked internal). Also note that the general control flow of the method, such as the ordering of if statements, is plainly visible.

If, before distributing the APK, the developers also ran the libraries through the Dotfuscator Community Edition, the results of reverse engineering would be different:

The code has been protected with renaming obfuscation, a basic form of code obfuscation. Properties with straightforward names, such as ArrowsOnHand, have been replaced by method calls with unintuitive names, such as b and g. Other code elements have similarly been renamed. This makes reading and reasoning about the decompiled code much harder, as important contextual clues provided by the names are no longer available.

Renaming obfuscation is the main focus of this blog post, but we’ll discuss more advanced forms of obfuscation, and how to apply them, later.

How to Obfuscate Your App

Now, let’s go over how to integrate Dotfuscator Community Edition’s renaming obfuscation into your Xamarin build pipeline. As an example, I’ll be using the Xamarin.Android app mentioned in the previous section. You can follow along with your own Xamarin app, including those for iOS and UWP.

We’ll be using PreEmptive Protection – Dotfuscator, a .NET obfuscator and protection tool that now also supports Xamarin.

Note: These steps assume you are developing your app with Visual Studio 2017 for Windows.

Install and Set Up Dotfuscator

First, you need to install Dotfuscator on your development machine. Since we’ll be using Dotfuscator’s command line interface, you also need to register your copy and record the path to the interface.

To install and set up Dotfuscator:

  1. Visit the Dotfuscator Downloads page on the PreEmptive Solutions website.
  2. Download the latest update of Dotfuscator Community Edition (CE) for Visual Studio 2017.
    • While Dotfuscator is included with Visual Studio, PreEmptive Solutions occasionally releases important updates to Dotfuscator between releases of Visual Studio. Installing Dotfuscator this way ensures you have the latest updates.
  3. Run the VSIX file you downloaded and follow the instructions.
  4. Open Visual Studio 2017 and select Tools -> PreEmptive Protection – Dotfuscator to launch the Dotfuscator Community Edition user interface.
  5. You’ll need to register your copy of Dotfuscator before you can use the command line interface. Dotfuscator will ask you to register when you run it for the first time; follow these instructions.
    • To register later or check your registration status, look for the Registration status text in the upper-right corner of the Dotfuscator Community Edition start page.
  6. You need to know the path to the command line interface in order to configure the build integration later. To find this path:
    • Browse to the install directory for your installation of Visual Studio 2017. For instance, the default install directory for Visual Studio 2017 Professional is C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional.
    • Within this directory, locate the Dotfuscator Community Edition extension files in *\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE.
    • The dotfuscatorCLI.exe executable is the Dotfuscator Community Edition command line interface. Record the absolute path to the executable for use later.

Download the Build Integration File

To simplify the integration process, the Dotfuscator team has created an MSBuild targets file, which your Xamarin projects can reference. You can download it here.

Save the PreEmptive.Dotfuscator.Xamarin.targets file to your solution’s directory, under source control.

Modify the Project to Use the Build Integration

Next, you’ll need to modify the project file for the Visual Studio project you want to obfuscate. To modify your project file:

  1. Note what project build configurations you want to protect. Typically these are everything except Debug configurations. For more guidance, see the Select What to Protect section of the full documentation.
  2. Open the project file in a text editor. An example project file for C# would be `YourProjectName.csproj`.
  3. Note the relative path from this file to the build integration file you downloaded.
  4. Import the build integration file by adding the following line to the file, immediately before the </Project> tag:
    • <Import Project="..\..\PreEmptive.Dotfuscator.Xamarin.targets" />, substituting the relative path noted in step 3.
  5. Under the <PropertyGroup> tag with no Condition attribute, add the following tags:
    • <DotfuscatorXamarinCliPath>C:\pathto\dotfuscatorCLI.exe</DotfuscatorXamarinCliPath>, substituting the absolute path to the Dotfuscator Community Edition command line interface you recorded earlier.
    • <DotfuscatorXamarinConfigFileName>DotfuscatorConfig.xml</DotfuscatorXamarinConfigFileName>
    • <DotfuscatorXamarinGenerateNewConfigFile>true</DotfuscatorXamarinGenerateNewConfigFile>
  6. For each build configuration noted in step 1, locate the corresponding <PropertyGroup> and add the following tag:
    • <DotfuscatorXamarinEnabled>true</DotfuscatorXamarinEnabled>
  7. After the last <ItemGroup> tag, add the following:
    • <ItemGroup><None Include="DotfuscatorConfig.xml" /></ItemGroup>
  8. Save and close the file.

Build the App

Now you can build the app with Dotfuscator’s obfuscation protection. To do so:

  1. Open or reload your project in Visual Studio.
  2. Select a solution build configuration that exercises a project build configuration you decided to protect.
  3. Build the project.
  4. After this first build, note the build output contains the following lines regarding Dotfuscator:

  1. Note the addition of a DotfuscatorConfig.xml file in your project. This is the Dotfuscator config file, which tells Dotfuscator how to obfuscate your code. It is recommended to check it into source control.
  2. On the filesystem, notice the new DotfuscatorReports directory in your project’s directory. This directory contains information about how the project was obfuscated, including how to reverse the renaming process. You should treat this directory like a build output, and have source control ignore it.
  3. Test your app. If you see errors, you may need to configure Dotfuscator further to maintain correct behavior; see the next section for reference.
  4. Continue developing your app, building as you would normally. When Dotfuscator is used during a build, the build output will contain the following lines:

For more information on continuing development with obfuscation in place, please see the Continuing Development section in the Dotfuscator User Guide.

Configuring Renaming

There may be some cases where an app assumes that the name of a code element at compile time will be the same at runtime. This is especially true for Xamarin apps, which rely on XAML and reflection. Renaming obfuscation can break this assumption, causing the obfuscated app to behave differently.

While newer versions of Dotfuscator are better able to handle these scenarios automatically, some cases may need to be manually configured. For instructions and an example, see the Identify Renaming Exclusions page of the Dotfuscator User Guide.

Advanced Obfuscation

Instead of the free Dotfuscator Community Edition, you can also obfuscate your Xamarin apps with Dotfuscator Professional Edition. Professional Edition is licensed for use on commercial products, and free trials are available upon request.

To see the difference between Community and Professional editions, consider the game example from earlier. If the developers ran their libraries through Dotfuscator’s Professional Edition, instead of Community Edition, the results of reverse engineering would look like this:

In addition to renaming obfuscation, this code is now also protected by control flow obfuscation. The original code’s statements are scattered among obtuse `switch` blocks, in a seemingly random order, making it very difficult to follow. This and other advanced forms of obfuscation are exclusive to Dotfuscator Professional Edition.

Summary

In this blog post, we’ve seen how Dotfuscator can be used to protect Xamarin libraries and apps from reverse engineering. While I used an Android app as an example, these same steps can also be applied to iOS and UWP projects, so you can protect your app no matter what platforms it runs on.

For more details on how to protect Xamarin projects with Dotfuscator, see the Xamarin page of the Dotfuscator User Guide. There you’ll also find a git repository demonstrating how to integrate Dotfuscator into a Xamarin app for all three platforms.

You can get the latest developments in the obfuscation space by visiting the PreEmptive Solutions blog, and by following PreEmptive on Twitter at twitter.com/preemptive.

The post Protecting Your Xamarin Apps with Dotfuscator appeared first on Xamarin Blog.

September 19

Augment Reality with Xamarin and iOS 11

One of the showcase features of iOS 11 is ARKit, an augmented-reality mode available on devices powered by A9 and newer chips (basically, 6S and better iPhones, 2017 iPads, and iPad Pros). With ARKit, users hold up the device and view a composite of the video feed and computer-generated imagery (either 2D SpriteKit or 3D SceneKit) that appears “attached” to horizontal surfaces in the real world.

Ultra-brief overview of ARKit

The lion’s share of work in ARKit is done behind-the-scenes on the device. Basically, an ARSession object combines device motion data, the camera’s physical characteristics (focal length, pixel size, etc.), and computational geometry to detect trackable “feature points” in the input video stream, locates them relative to a fixed world coordinate system, and creates ARAnchor objects that can be used to bridge between real-world and computer-generated imagery.

There are limitations. As mentioned previously, ARKit leaves behind older iOS devices. Also, ARKit can only detect horizontal surfaces (ARPlaneDetection is an enumeration that only defines Horizontal, but I have to believe that the limitation is due to some quirky behavior that Apple will fix sooner rather than later). Finally, the computer imagery in an AR scene is rendered above the video and appears above real-world objects that would occlude it.

The five critical concepts in ARKit are:

  • Everything is defined in terms of the world coordinate system, which is initialized soon after the ARSession begins running.
  • Image-processing finds high-contrast points in the real world that are stable from frame-to-frame. These “feature points” are intermediate results that are available to the developer, but mostly inform the system’s detection of ARPlaneAnchor objects. A good number of feature points are necessary for quite a few frames before ARKit detects a plane. Not surprisingly, bright lighting and textured surfaces seem to generate many more trackable feature points than evenly-illuminated matte surfaces.
  • Planes are created, removed, and coalesced as the image-processing continues. Their extent shifts, expands and shrinks, depending on the world-tracking.
  • Computer imagery is anchored to these planes and rendered on the screen as if at that location and orientation in the real world.
  • Because AR processing occurs 60 times per second, for optimal performance you need to be careful about memory and disposing no-longer-needed resources. Xamarin’s Profiler is your friend!

The following two images show these concepts. The first image shows the axes of the world origin “floating in space”, the current feature points as a set of yellow dots, and a small red cube where ARKit placed an ARPlaneAnchor.

The second image shows a conceptual view of the world coordinate system, camera / iOS device, and anchor, as well as showing the plane defined by the ARPlaneAnchor and a piece of 3D SceneKit geometry placed relative to the world coordinate system and the plane.

The Simplest ARKit That Could Work

Developers actually have complete control over rendering in ARKit but many scenarios will use the predefined ARSCNView and ARSKView that provide augmented-reality content based on SceneKit (3D) and SpriteKit (2D) respectively.

The following ARKit program allows you to place a piece of SceneKit geometry (a cube) so that it appears “attached to” a recognized horizontal plane. Before that happens, ARKit has to be initialized and run long enough to recognize a horizontal plane.

I initialize ARKit in two methods: ViewDidLoad and ViewWillAppear. The first to run is ViewDidLoad:

public class ARKitController : UIViewController
{
	ARSCNView scnView;
	public ARKitController() : base(){ }
	public override bool ShouldAutorotate() => true;
	public override void ViewDidLoad()
	{
		base.ViewDidLoad();
		scnView = new ARSCNView()
		{
			Frame = this.View.Frame,
			Delegate = new ARDelegate(),
			DebugOptions = ARSCNDebugOptions.ShowFeaturePoints | ARSCNDebugOptions.ShowWorldOrigin,
			UserInteractionEnabled = true
		};
		this.View.AddSubview(scnView);
	}
//... code continues ...

This is a typical iOS UIViewController subclass. It creates a new ARSCNView (the easy-to-use route towards SceneKit 3D geometry), sets its delegate-object to an instance of a class I wrote called ARDelegate (discussed later), turns on some debug visualizations, enables the view to respond to touches, and adds the ARSCNView to the view hierarchy.

The second part of initialization occurs during ViewWillAppear (it may be that this could be done during ViewDidLoad but I am always a little leery of the highly stateful view-initialization process in iOS):

public override void ViewWillAppear(bool animated)
{
	base.ViewWillAppear(animated);
	// Configure ARKit
	var config = new ARWorldTrackingConfiguration();
	config.PlaneDetection = ARPlaneDetection.Horizontal;
	// This method is called subsequent to ViewDidLoad so we know scnView is instantiated
	scnView.Session.Run(config, ARSessionRunOptions.RemoveExistingAnchors);
}

This simply configures the ARSession of the previously-created ARSCNView and begins its processing.

At this point, ARKit begins background processing. On the screen, the user will see the feed from their camera and, in a second or two, the debug visualizations will begin to show the feature cloud and world-coordinate’s origin (similar to the screenshot image shown previously).

At some point after that, ARKit will hopefully discover enough co-planar feature points to track a horizontal plane. When that happens, ARKit will automatically add an ARPlaneAnchor to its world-tracking. That addition triggers the DidAddNode method on the ARSCNView object’s delegate-object, which in our case is ARDelegate:

public class ARDelegate : ARSCNViewDelegate
{
	public override void DidAddNode(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor)
	{
		if (anchor != null && anchor is ARPlaneAnchor)
		{
			PlaceAnchorNode(node, anchor as ARPlaneAnchor);
		}
	}
	void PlaceAnchorNode(SCNNode node, ARPlaneAnchor anchor)
	{
		var plane = SCNPlane.Create(anchor.Extent.X, anchor.Extent.Z);
		plane.FirstMaterial.Diffuse.Contents = UIColor.LightGray;
		var planeNode = SCNNode.FromGeometry(plane);
		//Locate the plane at the position of the anchor
		planeNode.Position = new SCNVector3(anchor.Extent.X, 0.0f, anchor.Extent.Z);
		//Rotate it to lie flat
		planeNode.Transform = SCNMatrix4.CreateRotationX((float) (Math.PI / 2.0));
		node.AddChildNode(planeNode);
		//Mark the anchor with a small red box
		var box = new SCNBox
		{
			Height = 0.1f,
			Width = 0.1f,
			Length = 0.1f
		};
		box.FirstMaterial.Diffuse.ContentColor = UIColor.Red;
		var anchorNode = new SCNNode
		{
			Position = new SCNVector3(0, 0, 0),
			Geometry = box
		};
		planeNode.AddChildNode(anchorNode);
	}
	public override void DidUpdateNode(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor)
	{
		if (anchor is ARPlaneAnchor)
		{
			var planeAnchor = anchor as ARPlaneAnchor;
			System.Console.WriteLine($"The (updated) extent of the anchor is [{planeAnchor.Extent.X} , {planeAnchor.Extent.Y} , {planeAnchor.Extent.Z} ]");
		}
	}
}

DidAddNode is called any time a node is added to the view, but we are only interested in special processing if it’s an ARPlaneAnchor, indicating that ARKit is adding to its internal model of horizontal planes. We test for that condition and, if true, call this.PlaceAnchorCube. That method, in turn, creates some SceneKit geometry: a node that holds the plane’s geometry and is positioned in the same world coordinate as the anchor, and a small red box as a visual indicator of the ARPlaneAnchor. Note that because SceneKit uses a scene-graph architecture, the anchorNode position of [0,0,0] is relative to its parent’s position — the planeNode, whose position is based on the planeAnchor, whose position, in turn, is in world coordinates.

Once this method is called, the user will see something essentially identical to the screenshot above.

Hit-Testing

Once at least one plane is detected and tracked, the user can place additional geometry by touching on the screen. Back in the ViewController class:

// This snippet is part of:
public class ARKitController : UIViewController
{
	//… code shown previously …
	public override void TouchesBegan(NSSet touches, UIEvent evt)
	{
		base.TouchesBegan(touches, evt);
		var touch = touches.AnyObject as UITouch;
		if (touch != null)
		{
			var loc = touch.LocationInView(scnView);
			var worldPos = WorldPositionFromHitTest(loc);
			if (worldPos != null)
			{
				PlaceCube(worldPos.Item1);
			}
		}
	}
	private SCNVector3 PositionFromTransform(NMatrix4 xform)
	{
		return new SCNVector3(xform.M14, xform.M24, xform.M34);
	}
	(SCNVector3, ARAnchor) WorldPositionFromHitTest (CGPoint pt)
	{
		//Hit test against existing anchors
		var hits = scnView.HitTest(pt, ARHitTestResultType.ExistingPlaneUsingExtent);
		if (hits != null && hits.Length > 0)
		{
			var anchors = hits.Where(r => r.Anchor is ARPlaneAnchor);
			if (anchors.Count() > 0)
			{
				var first = anchors.First();
				var pos = PositionFromTransform(first.WorldTransform);
				return (pos, (ARPlaneAnchor)first.Anchor);
			}
		}
		return null;
	}
	private SCNMaterial[] LoadMaterials()
	{
		Func<string, SCNMaterial> LoadMaterial = fname =>
		{
			var mat = new SCNMaterial();
			mat.Diffuse.Contents = UIImage.FromFile(fname);
			mat.LocksAmbientWithDiffuse = true;		return mat;
		};
		var a = LoadMaterial("msft_logo.png");
		var b = LoadMaterial("xamagon.png");
		var c = LoadMaterial("fsharp.png");
		// This demo was originally in F# :-)
		return new[] { a, b, a, b, c, c };
	}
	SCNNode PlaceCube(SCNVector3 pos)
	{
		var box = new SCNBox
		{
			Width = 0.10f,
			Height = 0.10f,
			Length = 0.10f
		};
		var cubeNode = new SCNNode
		{
			Position = pos,
			Geometry = box
		};
		cubeNode.Geometry.Materials = LoadMaterials();
		scnView.Scene.RootNode.AddChildNode(cubeNode);
		return cubeNode;
	}
}

Skip to the TouchesBegan method and you can see that what we do is pretty straightforward at a high level: we grab the position of the touch and then perform a hit test for horizontal planes. If that hit-test is successful, we return the position on the first such plane as a tuple of type (SCNVector3, ARPlaneAnchor). The hit-testing is done using the built-in ARSceneView.HitTest(SCNVector3, ARHitTestResultType) method, which projects a ray outward into the augmented-reality “world” and returns an array containing anchors on any of the planes that it intersects, ordered nearest-to-furthest. If that array is not empty, we grab the first and return its position as an SCNVector3 (which we extract from the appropriate components of the anchor’s NMatrix4 matrix). (Historical note: During the iOS 11 beta period, the type used for these matrices switched between row-major and column-major in the Xamarin bindings. If you review code written during the beta period, rotations and translations may appear transposed.)

The PlaceCube method just creates a box 10cm on a side and places it in the augmented-reality “world” at pos, whose value is the SCNVector3 returned by WorldPositionFromHitTest as mentioned above.

The result is something like:

Learn More

The #MadeWithARKit hashtag on Twitter has been a great source of inspiration this Summer, with people demo’ing such great concepts as virtual portals, sound nodes located in space, and the combination of ARKit with video filters.

After the iPhone X launch announcement, Apple revealed some new APIs relating to face detection and mapping, including an ARFaceAnchor and ARFaceGeometry.

All the code for this sample is available at https://github.com/lobrien/ARKit_Csharp. Pull-requests and questions welcome! Make sure to also check out the Introduction to iOS 11 guide in the Xamarin Developer Center.

Discuss this post in the Xamarin Forums

The post Augment Reality with Xamarin and iOS 11 appeared first on Xamarin Blog.

September 18

Learn How The Lean Cook Uses Mobile to Drive Revenue and Promote Healthy Living

The Lean Cook, a popular UK diet and fitness blog started as a hobby by a husband and wife team, is a prime example of how to design apps for the user. Instead of simply replicating web content on a smaller screen, the team crafted an interactive shopping and cooking experience. They’ve grown a loyal following, and their latest project (available on Android and iOS) is already getting five-star reviews and overtaking established food personalities.

Today, Chris Foulds joins us to share how he, a first-time C# developer, launched the Lean Cook in just six months using Xamarin.Forms to share 90%+ code across platforms, with in-app upgrades, dynamic customization features, and more on the roadmap. 

Tell us a little bit about your company and role. Who are your customers?

We’re a new startup focused on the “lean revolution.” Popularized in the UK by “The Body Coach” Joe Wicks, the lean revolution focuses on fresh, healthy meals and smart exercise: eating the right things at the right time and changing your lifestyle. Our customers are anyone, of any age, looking for lean, flavorful versions of everyday recipes.

During our own lean transformation, my wife starting blogging and sharing her healthy creations,  and in the first year her website saw 850K+ visitors without any paid promotion. As a long-time software engineer, I’d spent the last four years as a freelance mobile developer, and I knew that a mobile app could take the website to the next level by creating a unique, fully interactive cookbook experience.

How long have you been building apps? 

I’ve been writing software since I was a teenager in the early 90’s, writing in 68k assembler for the Commodore Amiga. I graduated university with my degree in software engineering. Over the years, my career path took me into management.

In 2010, I decided to go back to actively working on projects, and I’ve been writing mobile apps ever since. I’ve written Android and iOS apps with native languages and tools (Java and Obj-C), and I’ve also used other frameworks, like Gideros and Unity.

I’d never programmed in C# before building the Lean Cook, but since I’ve written in various forms of C since the mid-90’s, there wasn’t much of a learning curve.

How did you get up to speed with cross-platform mobile development?  

After creating the basic design and requirements, I reviewed the Xamarin samples and just started writing, learning as I went along. I made wrong turns along the way, but that’s part of the learning process for me.

Lean Chef on Android (HTC)

Walk us through your app and what prompted you to build it. 

We built the Lean Cook app to be the best interactive cookbook possible. With it, users can search and find our recipes, make them as-is or make customizations own based on their needs and preferences, and upgrade to access more recipes and premium features.

It’s key for me to ensure that anyone can benefit from the app without purchasing a subscription; we include 75 free recipes and give one “premium freebie,” allowing users to try out subscription features, such as customizing ingredients for their nutritional needs, on one recipe before they commit to buy.

The three standout features that make The Lean Cook go beyond a mere recreation of our website to become an interactive recipe book are:

  1. Dynamic recipe sizes and nutritional information: Not only do we allow users to change amounts of certain (or all) recipe ingredients, we automatically recalculate the calories and macros for any altered recipe. Our users can quickly customize our recipes, making the version that best fits their personal nutritional goals. I haven’t seen any other app in our category offer this capability.
  2. Intelligent shopping lists: Most cooking apps allow you to add a recipe and its associated ingredients to a shopping list, but our app takes this one step further. As you add multiple recipes to your list, we intelligently identify ingredients from each recipe and allow you to see a combined grocery list, grouping ingredients across all recipes so you can quickly see what you need to buy to make all your saved meals.
    • For example, if one recipe calls for two tomatoes and another calls for four tomatoes, we’ll add six tomatoes to your grocery list. It seems small, but it’s a huge time saver, because instead of forcing users to skim lists for similar ingredients or realize ten minutes later that they need to return to the produce section for more tomatoes, they get everything they need in one shot, check out, and get on with their day.
  3. Interactive recipe steps: We’ve organized all of our recipes like task lists and, as users complete each recipe step (like chopping vegetables or mixing sauces) they can tap to mark the step complete, so they don’t get lost while cooking or forget critical steps. We call this “crossing off the method,” and it’s another way that we’ve taken advantage of mobile-unique capabilities, such as interactive screens to create a better user experience.

I think the entire application is exciting, but I may be biased!

How long did it take to ship your apps, from design to deploy?  

Lean Chef on Android (Nexus)

In total, it took about five months to write a completely release-ready app for Android (phones and tablets), iPhone, and iPad.

I wrote the majority of the app on my PC, focusing on Android as the lead development platform, before finally transferring to my MacBook Pro to finalize the iOS app to ship to the Apple App Store.

With Visual Studio Tools for Xamarin, and Xamarin.Forms specifically, I share nearly 94% of the code across Android and iOS. The evolving nature of Xamarin.Forms drew me to Xamarin, as I wanted to be able to write my UI once and have it work—and look and feel native—across platforms. To me, a native app is one that looks “at home” on a user’s device; no UI or interactive elements should be a jarring or unfamiliar experience. Delivering this level of quality is important to me, as I want our customers to instantly feel at home and comfortable with our apps, not fighting to understand the UI.

While I may have been able to write an iOS app in three months using Obj-C, I’d then have to start all over again, from the beginning, to build the Android version.

I was not only able to get both platforms out to users faster, I can now concentrate on developing and adding new features, rather than trying to maintain feature parity across platforms or managing two codebases. We plan to add new recipes to our existing packs every month, and we’ll roll out new recipe themes and authors (and associated free and premium recipe packs) with new app features timed with these monthly / quarterly content updates.

Lean Chef on iOS (iPhone)

What’s feedback been like so far? 

We’ve had amazing five-star reviews across the board, with a few of my favorites:

“Probably one of the best cooking/recipe apps to date. Lovely, healthy food … brilliant addition of being able to adjust the servings, making it great to cook for one or for 6. Oh, and the brilliant idea of adding items to a shopping basket and it totals all required items, so no miscalculations.”

“This app is so easy to use and has some brilliant features… the recipes are so varied and delicious and really helped me through The Body Coach SSS plan! Thank you 👍

“Can’t imagine life without this amazing app. Makes food planning so easy and such a mix of recipes that it makes choosing what to eat a joy.”

“Fantastic app, full of awesome recipes and lots of fab little add-ons like editing your own quantities”

My wife also loves the app (seeing her recipes “come to life” in her words), and she uses it herself to recook her recipes or make tweaks to existing ones. 

Outside of reviews, we saw 2K+ downloads within 24 hours of our launch, placing us #1 in the Food & Drink category for the day, and ahead of Jamie Oliver’s app! Since Jamie Oliver is one of the biggest food stars in the UK (and extremely popular around the rest of the world), seeing our app place ahead of his and other well-known personalities was an amazing feeling.

What are your future plans for the app?

Our strategy is two-fold. First, we’ll continue to grow The Lean Cook app, and we’re partnering with other prominent internet food personalities (chefs, bloggers, social media celebrities) to surface their content in it, making it a one-stop shop for anyone interested in healthy food.

Second, we want to expand the brand with additional health and fitness applications. As we’ve adopted this lifestyle, we’ve realized that thousands of people don’t use the existing apps how they’re designed to be used, but instead try to make them fit various needs. We’re not ready to share any details, but we’re aiming to create a suite of apps designed with users’ real needs in mind.

I’d also love to get international food writers to contribute to give the apps broader appeal, reaching users across the globe in addition to partnering with health bloggers in the UK.

What advice do you have for developers who are just starting out or investigating mobile development?

Choose something really small, like a simple 4–5 page application, and see it through to the end. You’ll be surprised how many hurdles you come up against and, if you’re committed to seeing the project to the finish line, figuring out how to overcome each challenge forces you to learn the most vital steps to successfully building mobile apps.
 
 
Visitxamarin.com/customersto learn how our customers across industries and geographies deliver amazing mobile apps, and visitxamarin.com/downloadto start building your own. 

The post Learn How The Lean Cook Uses Mobile to Drive Revenue and Promote Healthy Living appeared first on Xamarin Blog.

September 15

Xamarin.Forms: Tips for Beating the Learning Curve

As a first time user learning any new technology or pattern, there’s always a curve, and over the years I’ve stood at the threshold of a product and gazed up that curve to determine how painfully steep it appeared and how long it would take until I was productive. Now, as the Program Manager for Xamarin.Forms, I gather and receive a lot of feedback from first time users, and stand in a position of being able to offer some help.

I’ve curated some great resources to get you over the curve, from our documentation guides to Xamarin University training materials, blog posts, and more. Whether you’re new to Xamarin.Forms or a seasoned user, I think you’ll find something useful below.

Quick Index

The Giddyup: Prerequisites

 

What do I need to install?

Mobile development requires more than a few things before you can be productive, including mobile platform SDKs, an IDE, and some combination of emulators, simulators, and devices. These guides will get you going quickly:

Windows Installation
Mac Installation

Also check out this self-guided session from Xamarin University, Getting Started With Xamarin [XAM101].

Simplified iOS Development

We’ve been hard at work simplifying iOS development by introducing the Xamarin Live Player (currently in Preview 2). Xamarin Live allows you to code in Visual Studio 2017 and see your app immediately on device via the Xamarin Live Player app.

When you’re ready to compile and deploy your applications for iOS, or outgrow the Xamarin Live Player’s capabilities, you can connect to your Mac and use the Remote iOS Simulator for Windows.

Common First Questions

 

How do I navigate from one screen to another?

Xamarin.Forms screens are called Pages and use the base class ContentPage. Xamarin.Forms follows a stack concept and you push and pop from that stack. Before you can do that, you need a navigation stack. The easiest way to introduce one is to start your application with a NavigationPage.

Now, from within a ContentPage, you can simply use the Navigation service to push a new page onto the navigation stack:

MainPage = new NavigationPage( new FirstPage() );

await Navigation.PushAsync( new SecondPage() );

For more information about navigation, visit the guide here.

How do I lay out my content?

Xamarin.Forms supports several layout patterns, including Grid, StackLayout, AbsoluteLayout, and RelativeLayout. I recommend you learn to use and love the Grid, as it’s presently the most flexible and performant option.

For highly optimized layouts, explore creating a custom layout, where you can finely control aspects of the measure and invalidation cycles.

Check out our Xamarin University Self-Guided course on Layout in Xamarin.Forms[XAM135].

Awesomeness Alert! Some adventurous community members have recently taken exception to the long held opinion that Xamarin.Forms cannot create highly polished layouts:


 


 

How do I see my design?

You have a few options here. As the Xamarin Live Player gets better and better, it’s a great companion for live editing XAML in the text editor and seeing an instant rendering. A little tip: use an application like Reflector to mirror your device on your development machine.

Our designer team has also been making improvements to the Xamarin.Forms Previewer.

Where do I find _____ control?

Xamarin.Forms provides implementations of many native UI controls across each target platform. This concept of abstraction becomes more clear when you see the mapping of Xamarin.Forms renderers to native controls.

Still looking? Xamarin has a great ecosystem of third party and community controls to fill in the gaps and extend the platform. Spend a few minutes on your favorite search engine, GitHub, and searching NuGet.

Moving Beyond Basics

 

How do I customize a control?

Out-of-the-box Xamarin.Forms controls provide basic customization possibilities, and we provide doors for when you “hit a wall.” Here are your options:

Platform Specifics

When you need to customize a control for only a specific platform, you can implement a Platform Specific. A good example is one provided to adjust the font size of an Entry to fit the control width.

Effects

Effects are good for when you need to add a customization on each platform to a control, which may be useful across a variety of controls, and when you just need to modify a single property that isn’t currently exposed in the control abstraction. Some common examples are adding shadows or one from the Xamarin.Forms Community Toolkit that I often use to remove the border of an Entry.

Sign up for the live Xamarin University class Using Effects in Xamarin.Forms [XAM330] to learn more.

Custom Renderers

Creating a custom renderer gives you total control of the native platform control for design and behavior. This guide demonstrates creating a simple custom Entry renderer.

Custom renderers are also where you want to go when implementing a control that may not currently exist in Xamarin.Forms, such as a Floating Action Button. Xamarin University covers this topic, as well, for scenarios such as interactive graphs, a custom drawing surface, and more in the live session Xamarin.Forms Renderers [XAM335].

How do I use custom fonts?

While Xamarin.Forms makes a lot of cross-platform development smooth, and while setting font attributes is included, custom fonts require a bit more attention.

We use a custom icon font, WeatherIcons, in our Weather demo app. Once you have the font properly set up in the platform projects, using the font in XAML is pretty simple.

<Label Text="{Binding WeatherIcon}" FontSize="18" Grid.Column="0" VerticalTextAlignment="Center" TextColor="White">
    <Label.FontFamily>
        <OnPlatform x:TypeArguments="x:String">
            <On Platform="UWP" Value="/Assets/WeatherIcons.ttf#Weather Icons"></On>
            <On Platform="iOS" Value="Weather Icons"></On>
            <On Platform="Android" Value="WeatherIcons.ttf#Weather Icons"></On>
        </OnPlatform>
    </Label.FontFamily>
</Label>

Where do I put my images?

Like fonts, managing images requires more effort. This is in part due to the way each platform handles images differently, and the variety of sizes and densities each requires or supports. This guide will show you where each expects to find images and how you can load them. When you place them in the right place, referencing them is as simple as <Image Source="waterfront.jpg" />. The platforms will find the image and deliver the proper density for the device.

How can I store data locally?

Each platform has a storage API that Xamarin.Forms exposes via Application.Current.Properties. This API is good for storing simple data.

As your storage needs become more complex, you’ll want to start exploring options like sqlite, Azure Mobile Apps, Realm + Azure, or any number of other options available.

Where do I get started with Push Notifications?

Azure Mobile Apps is a great option for Xamarin.Forms apps. The Azure documentation site includes an article on enabling push notifications in your app.

Other services such as Urban Airship provide components for Xamarin apps to enable use of their APIs.

How do I authenticate with ______ service?

This is fairly dependent on what the service is, but in general I recommend starting with the service’s component to see if they expose an API for authentication. Take a look at using Xamarin.Auth which has built-in authenticators for Google, Microsoft, Facebook, and Twitter. I’ve also used it to authenticate with the Strava oAuth service.

How do I inspect my app UI tree?

Visual Studio Enterprise license holders have access to the Xamarin Inspector for this very purpose! While this is our clear favorite and what we use, there are other commercial and open source projects out there for inspecting mobile apps.

Bonus: Additional “Stuff”

  • Checking connectivity is something you’ll probably bake into every mobile app, so check out the Connectivity plugin.
  • There are lots of good plugins out there to make cross-platform development easier. Check out this list and browse NuGet and GitHub to discover even more.
  • I love to promote and share useful resources, but it’s gonna be hard to top Xamarin University instructor Kym Phillpotts’ recent blog of Xamarin Tools and Resources.
  • Our performance guide is “recommended mandatory” reading.

Get Coding

I hope you discovered a few tips that are useful for you, and I encourage you to share your own discoveries as you begin the journey. If you happen to tweet something, please mention me (@davidortinau) so I can add it to my list and help share with others.

Discuss this post in the Xamarin Forums

The post Xamarin.Forms: Tips for Beating the Learning Curve appeared first on Xamarin Blog.

September 14

Xamarin All-Stars at .NET Conf 2017!

Join Xamarin Product Managers and Engineers at .NET Conf 2017, a free virtual event for any developer.

This year’s speaker line-up consists of all-star Xamarin speakers, including Miguel de Icaza, James Montemagno, and Mikayla Hutchinson, who will present on Xamarin tooling and the latest on what’s happening with Xamarin and related technologies.

What’s .NET Conf?

.NET Conf is a free, three-day virtual developer event co-organized by the .NET community and Microsoft. Developers can select from a wide selection of live sessions that feature speakers from the community and .NET product teams. This is your chance to learn, ask questions live, and get inspired for your next development project from these experts in the field.

Attend a Local .NET Conf Event!

If you’re unable to attend the conference in Stockholm, .NET Conf is partnering with organizers around the globe to bring you local, in-person events from September 19 through the end of October! Join your fellow developers in a city near you to learn more about .NET and the new .NET Core 2.0 release.

The post Xamarin All-Stars at .NET Conf 2017! appeared first on Xamarin Blog.

September 13

Get Your Apps Ready for iOS 11!

We’ve just updated our iOS 11 support to go along with the Xcode 9 GM Seed release. You can use this build along with the Xcode 9 GM to submit applications that take advantage of the new features in iOS 11, tvOS 11 and watchOS 4 to the Apple AppStore. We also have awesome new sample documentation for iOS 11 features!

Getting Started with iOS 11

Visit our Getting Started with iOS 11 guide to stay up-to-date on installation details, samples and the latest information on what’s new. Here is what you’ll need:

iPhone and iPad showing iOS 11

Augment your apps with iOS 11

iOS 11 brings some exciting new features to the platform. We’ve created a new section in our documentation for iOS 11 to make it as easy as possible to integrate those features into your apps. To get started, visit the Xamarin Developer Center and check out our iOS 11 Samples and Introduction to iOS 11. Here are some of the exciting new samples that are available:

  • ARKit – Create next-generation apps using the camera on the device to augment the world around you.
  • CoreML – Analyze problems directly on the device with new Machine Learning APIs available with CoreML.
  • Drag and Drop – Discover new ways to move images and more across your app or into another app.
  • MapKit – Improvements include a new compass view and easier ways to render custom overlays.
  • SiriKit – SiriKit now has additional intents for Payments, new support for lists, notes and more.
  • Vision – New image processing techniques directly in your apps including face and feature detection for images and videos.

Be sure to follow along with the Xamarin Release Blog for up-to-date information about known issues and other release notes.

Discuss this post in the Xamarin Forums

The post Get Your Apps Ready for iOS 11! appeared first on Xamarin Blog.

September 11

Xamarin.Android 8.0 Gets Even Sweeter with Oreo

Android 8.0 Oreo is by far the sweetest version of Android to date, with great new features including notification channels, notification badges, custom fonts in XML, downloadable fonts, instant apps, background limits, autofill, and picture-in-picture (PIP). We’re excited to announce Xamarin.Android support for Android Oreo in our latest release of Xamarin.Android for both Visual Studio and Visual Studio for Mac.

Installing Xamarin.Android for Android 8.0

You can get Android Oreo support inside Xamarin.Android 7.5.0.15 and above, which is available today in the Visual Studio Preview channel and Visual Studio for Mac Beta channel.

Visual Studio

  • Open the Visual Studio Installer and download the latest Preview (15.4 Preview 2).

Visual Studio for Mac

Both Visual Studio and Visual Studio for Mac

Android 8.0 development requires JDK 1.8 for compilation of applications; JDK 1.8 is available from Oracle. See the requirements documentation for more information.

Install the Android Oreo SDK

Start the Android SDK Manager:

  • Visual Studio, use Tools > Android > Android SDK Manager
  • Visual Studio for Mac, use Tools > Open Android SDK Manager

Install Android 8.0(API 26) SDKs and Device Images:

Install the latest Android SDK tools, which are listed under Tools and include Android SDK Tools revision 26.0.2 or later, SDK Platform-tools 26 or later, and SDK Build-tools 26.0.0 or later:

For more information about using the Android SDK Manager to install the Android SDK, see Using the SDK Manager.

After restarting Visual Studio, you’ll be able to set your <TargetFrameworkVersion> to Android 8.0 (Oreo) in your project to take advantage of the new APIs:

If you do not see the new Android SDK Manager in Visual Studio 2017, you can install it manually from the Visual Studio Marketplace.

Want to know what features to start implementing first in your app? We have a full Introduction to Android Oreo guide that outlines the latest features, and we’ll continue to add more content over time. Here are a few of the stand out new features in action:

Autofill Framework

The new Autofill framework in Android Oreo makes it easier for users to handle repetitive tasks such as login, account creation, and credit card transactions, allowing users to spend less time re-typing information (which can also lead to input errors).

Picture-in-Picture

Android Oreo makes it possible for an Activity to launch in picture-in-picture (PIP) mode, overlaying the screen of another Activity. Currently, this feature is intended to be used for video playback.

Notification Badges

Android Oreo now shows notifications the user has not yet acted upon associated with one or more notification channels in an application. Users can long press on an application icon to see notifications associated with it.

Learn More

For more detailed information on how to get started with Android Oreo, please see our documentation.

We encourage your feedback on any issues to be filed as a bug. If you have any questions regarding Android Oreo APIs, please post them on the Xamarin Forums or Stack Overflow.

Discuss this post in the Xamarin Forums

The post Xamarin.Android 8.0 Gets Even Sweeter with Oreo appeared first on Xamarin Blog.

Podcast: Android Oreo Support, Xamarin Live Player Preview 2, New iOS 11 Previews, and more!

In this episode of the Xamarin Podcast, James Montemagno and I discuss all of the amazing new previews available to Xamarin developers, including Android Oreo, iOS 11, Xamarin Live Player, Xamarin.Forms, and more! We also discuss some exciting news with the Xamarin MVP Program and a new certification level for Xamarin developers. Be sure to download today’s episode from your favorite podcasting app.



Subscribe or Download Today

Keeping up with the latest in .NET, C#, and Xamarin is easier than ever with the Xamarin Podcast! Cohosts Pierce Boggan and James Montemagno cover topics relevant to Xamarin developers, from designing mobile apps to identity management. Be sure to subscribe to the Xamarin Podcast on iTunes, Google Play Music, Stitcher, or your favorite podcast app you use to ensure you don’t miss an episode.

The post Podcast: Android Oreo Support, Xamarin Live Player Preview 2, New iOS 11 Previews, and more! appeared first on Xamarin Blog.

Monologue

Monologue is a window into the world, work, and lives of the community members and developers that make up the Mono Project, which is a free cross-platform development environment used primarily on Linux.

If you would rather follow Monologue using a newsreader, we provide the following feed:

RSS 2.0 Feed

Monologue is powered by Mono and the Monologue software.

Bloggers