Developing for iOS

The following steps outline the basic procedure for using Visual Studio, Xamarin tools, and Xcode to develop for Mono on iOS devices. Most of these steps outline Visual Studio and Xamarin procedures (some of which change often), so see Visual Studio and Xamarin documentation for full information.

Tip

You can use the Synergy iOS Application project template to quickly get a simple application up and running on the iOS Simulator. See iOS quick start (Hello World).

In general, Synergy/DE's support for Mono on iOS is similar to its support for Windows desktop and server development (see Developing Windows Desktop and Server Applications), but there are differences. Windows-specific code won't work with iOS (for example, file paths for iOS must have forward slashes), and there are different restrictions. Many of these are discussed below, but see Feature Support for more information. And note that any iOS solution with a Synergy project must implement Synergy device licensing, though licensing is not used when running on the iOS Simulator. See Licensing .NET assemblies.

To develop a Synergy application for iOS, you must have an Apple developer account, and you must have Windows and Mac development machines that meet the requirements listed in Synergy .NET Requirements. For testing and debugging, you can use either the iOS Simulator or a provisioned iOS device connected to the Mac (see figure 1).

1. Components for iOS development.

Components for iOS development

Step 1: Pairing

Before you can build an iOS project, you must pair your Windows development machine to the Xamarin Build Host on your Mac. Initially, this must be done manually using the following procedure. Subsequently, Visual Studio will automatically attempt this whenever you open the iOS project.

1. On the Windows development machine, select Tools > iOS > Xamarin Mac Agent from the Visual Studio menu. The Remote Login window for Xamarin Mac Agent opens.

2. The Remote Login window for Xamarin Mac Agent (Windows development machine).

The Remote Login window for Xamarin Mac Agent

2. On the Mac, click the Spotlight icon (the magnifying glass) on the menu bar for the desktop and search for Remote Login. The “remote login – sharing” window opens.

3. The “remote login – sharing” window (Mac).

The remote login – sharing window

3. In the “remote login – sharing” window, double-click Sharing, which opens the Sharing window.
4. In the Sharing window, select the Remote Login option, and optionally select “Only these users” (under “Allow access for”) to limit users who can access your Mac remotely.

4. The Sharing window (on Mac).

The Sharing window

5. On the Windows development machine, click OK in the Remote Login window (see figure 2), which opens the Xamarin Mac Agent window.
6. In the Xamarin Mac Agent window, select the entry for your Mac and click Connect, and then, in the “Connect to Mac” window, enter the user name and password for the Mac and click Login.

The Xamarin Build Host on your Mac should now be paired with the Windows development machine. If you select Tools > iOS > Xamarin Mac Agent from the Visual Studio menu, the Xamarin Mac Agent window will display the name of the paired Mac machine (see figure 5 below).

5. Xamarin Mac Agent displaying the name of the paired Mac.

Xamarin Mac Agent displaying the name of the paired Mac

Step 2: Coding and configuring

To create and configure a Synergy iOS project, follow these steps:

1. In Visual Studio, create a project for each assembly in the iOS application. The following Synergy templates can be used for iOS projects:

For example, to create an executable assembly for an iOS application, select File > New Project, select Synergy/DE > iOS from the Installed Templates area of the new Project dialog, and then select iOS Application from the list of project types. You’ll then need to set a few options for the project (name, location, and so forth). Note the following:

2. Add DBL code, resources, assets, controls, etc., to the Visual Studio projects, and make sure each project references the assemblies it needs.
while(UIApplication.SharedApplication==^null)
    await Task.Delay(100)
3. Set project properties. See Synergy/DE project properties. And note the following:

Step 3: Building and debugging

Before you start, make sure debugging files are set up. See http://www.synergex.com/synergy_net.aspx.

Synergy licensing is not required when running a Synergy iOS application on the iOS Simulator.

1. Connect the Windows machine to the Xamarin Build Host on the Mac. See Step 1: Pairing.
2. Build the application in Visual Studio. Note the following:

Note that iPhoneSimulator and iPadSimulator cause the solution to be built for X86, not the actual target environment. iOS devices have ARM-based processors, but the Simulator requires applications to be built for a CPU that is not ARM-based.

You should now be able to run and debug. You can debug by using the iOS Simulator running on the Mac, or you can use a provisioned iOS device connected to the USB port on the Mac. Note that it is generally better to test on a physical iOS device since this is the actual environment in which the application will run.

For more information on debugging, see Debugging Synergy .NET Code.

Step 4: Deploying an iOS application

The process for deployment depends on how you want to distribute the application. There are two methods: you can distribute the application package to users (e.g., to users in your enterprise), or you can make it available through the App Store.

Deploying within an enterprise

To deploy an iOS application within an enterprise, you must sign the application with a distribution certificate obtained from Apple’s iOS Provisioning Portal (this is tied to the Enterprise Developer membership) and then package the application with a provisioning profile, which must also be obtained from the Provisioning Portal. (The Enterprise distribution provisioning profile allows the application to be deployed to an unlimited number of iOS devices.) You can then distribute the package to users who will do the following to install it:

1. Run the iTunes app on a Mac machine associated with the device. To connect the device, select it on the Devices list, click the Apps tab, select the app to be installed, and then click the Apply button.
2. Choose “Add File to Library...” from the menu, and then choose the distribution package containing the application to be installed.

For more information, see the iOS Deployment Technical Reference, which is available from Apple.

Deploying through the App Store

To deploy an application through the App Store, the application must be signed with a distribution certificate, and a store distribution provisioning profile must be created using the Apple iOS Provisioning Portal (as discussed in Deploying within an enterprise above). This profile indicates that the application uses certain technologies and services and confirms that it was submitted by the developer. These technologies and services can include iCloud, location data, keychain (passwords), background processing, encryption, etc. These are set in Xcode in the project data. You then archive and validate the application and create an application record on iTunes Connect at itunesconnect.apple.com. Finally, you submit the application using Xcode. You can then check the approval status of the application on the iTunes Connect web site, and when it’s approved, it can be purchased from the App Store.

For more information, see the App Distribution Guide, which is available from Apple.

iOS quick start (Hello World)

If you are set up for iOS development (see Synergy .NET Requirements), you can have a simple Synergy iOS application up and running in a matter of minutes.

1. Pair the Windows development machine to the Xamarin Build Host on the Mac development machine. See Step 1: Pairing.
2. Open Visual Studio and select File > New > Project. Expand the Installed > Templates > Synergy/DE category in the new Project window, and select iOS, and then select the iOS Application template.
3. Set options for the project (name, location, and so forth), and then click OK. The new iOS application project will open in Visual Studio.
4. Find the {assembly:SynergyDeviceLicense... line in Main.dbl, and enter dummy public key and GUID values for device licensing. In other words, add some characters between the quotes that follow PublicKey= and AppGUID=. In the following, for example, both are set to “abc”:

Although device licensing is not required when running on the iOS Simulator, the iOS Application project template includes a full device licensing implementation. This implementation requires PublicKey and AppGUID values. The application will not build without them.

5. Go to the property pages for the solution and set the Platform option to iPhoneSimulator.
6. On the Visual Studio toolbar, set the “Solution Configurations” drop-down list to Debug, set the “Solution Platforms” drop-down list to iPhoneSimulator, and set the next drop-down list (to the right of “Solution Platforms”) to an iPhone version—e.g., “iPhone 6 Plus iOS 8.1”.
7. Select Debug >Start Debugging. Starting a debug session while an iOS Simulator configuration is selected causes the application to be built, the iOS Simulator to start on the Mac machine, and the application to be deployed to the iOS Simulator.
8. Once the iOS Simulator is up and running, and the application has finished deploying, you should be greeted with a screen with the text “About Device License.”

Congratulations! You have just created a Synergy .NET iOS application. Clicking “About Device Licensing” will open a window with licensing information. (On a device, it prompts you for a user, a password, and a description.)