October 17, 2013

Xamarin Studio and iOS 7

By

Our latest Xamarin Studio release brings support for new iOS 7 capabilities, giving C# developers the great new benefits that Objective-C developers recently picked up with the release of Xcode 5.

The features fall into three categories:

  • Automatic Configuration
  • Asset Catalogs
  • Texture Atlases

Nina has put together a walkthrough of these new features:

Automatic Configuration

Xamarin Studio got a big upgrade to its iOS capabilities with this release, matching the new features introduced in Xcode 5 to simplify the development of iOS applications.

We start with an Account Manager that you use to track your Apple developer accounts (you can have multiple accounts and belong to multiple teams):


Xamarin Studio will automatically download any new provisioning profilers, app ids and certificates from the Apple Developer portal.

This simplifies the workflow when working with teams and you no longer need to use Xcode to do this synchronization for you.

Tasks that used to take a few trips to the iOS Developer portal are now possible by either editing your Info.plist file or your Entitlements.plist file.

When you edit your Info.plist file, you can now enable GameKit, configure background operation modes and provide data to the Maps app with a single click. You no longer need to go back and forth between your project and the Apple Development Portal:


Xamarin Studio now has support for specifying the new icon sizes introduced in iOS 7:


The following features are also available when you add or edit the Entitlements.plist file which allows you to easily configure iCloud, Passbook, In-App Purchases, Inter-App Audio, Keychain and Data Protection. Again, all within the IDE and removing the cumbersome back and forth with the Apple Developer portal:


Asset Catalogs

Asset Catalogs are a new feature in iOS 7 that helps you organize your image and icon assets.

Asset catalogs can be useful to make sure that you ship all the assets that you need for all resolutions. It starts with the simple manager for your own application icons (when you double click info.plist to edit your icons). You can migrate your existing artwork easily from the IDE:


And can also be used to manage your own collections of icons and image assets. To manage your image assets, select “Add New File” on your project and select the “Asset Catalog” template:


This will create an Images.xcassets folder in either the top-level folder (or within a Resources folder, depending on what you had selected in the Solution Tree). Within that Images.xcassets folder, there will be 2 other folders: AppIcons.appiconset and LaunchImages.launchimage. You can add more of these types of folders by right-clicking on the Images.xcassets folder and choosing “Add New File” which will
sense that an asset catalog folder is selected and offer templates for AppIcons, LaunchImages, or Images (which will create the corresponding asset catalog subfolder).

Once you do that, you can then edit the Contents.json file, which will bring up the Asset Editor:


You can then drag and drop images into the individual tiles in your asset manager.

To load the images at runtime, merely use the asset name, like this:

var image = UIImage.FromBundle ("Images");

Texture Atlases

iOS7 introduced SpriteKit, a framework for building 2D games, and with it they introduced Texture
Atlases
. Texture atlases are a mechanism used by developers to improve the performance of their application by combining multiple independent images into a single image.

To create Texture Atlases in Xamarin Studio, you just need to create a folder with a .atlas extension (for example “Textures.atlas”). Then fill this directory with the image textures that you want to compile into a texture atlas.

To load an image from the atlas, merely specify the name, and iOS 7 will load it for you from the atlas:

var robot = SKSpriteNode.FromImageNamed ("robot.png");

We’ll also be bringing these features to Visual Studio in the near future. To learn more about other improvements in Xamarin Studio, check out the Xamarin Studio Release Notes or our video walkthrough.

TwitterFacebookGoogle+LinkedInEmail