Search

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, November 23, 2016

Build and Debug Xamarin.iOS Application on Windows Machine

Introduction:
Xamarin is great technology for develop cross mobile application development. You can create, Build and Debug iOS application in windows machine using Visual Studio. In this article, I will explain what are the way to debug and build Xamarin.iOS application in windows machine.
Xamarin and Microsoft giving very great solution for create, build and debug IOS application on windows machine using visual studio. but, it cannot do this alone, an IOS app cannot be created without apple Compiler, and it cannot be deployed without apple certificate and code-signing tools. Read below I will explain about software requirement and steps.
Software Requirement:
You can install following software from Windows and Mac machine.
Windows Machine:
  1. Windows OS 7 or higher (7, 8, 8.1,10 +)
  2. Visual Studio 2013 professional or higher.
    1. Download Update Visual Studio from https://www.visualstudio.com/downloads/
    2. VS 2015 ++ included xamarin .
    3. If VS 2013 , Download Xamarin for Visual Studio from https://www.xamarin.com/download
    4. Note: You cannot use the Xamarin plug-in Visual Studio Express editions.
Mac Machine:
  1. A Mac running OS X El Capitan (10.11) or higher
  2. Xamarin Studio 5.10 or higher with Xamarin.iOS SDK
It greatly helps if your machines are physically near each other, since when you build and run on Windows, the iOS Simulator will load on your Mac.
Build and Debug iOS Application:
I have explained about basic xamarin.Form application creation in my previous article .You can refer and create basic xamarin.iOS or xamarin.Form application
After create, Visual Studio will prompt you to prepare your Mac to be the Xamarin build host using below 3 steps.
Mac Machine:
Step 1: On the mac Machine, Select “System Preferences”

Step 2: In System Preferences, Click on  “Sharing”
Step 3: In Sharing, Turn on Remote Login and Change Allow access to All Users or Only these users and add a user.
Windows Machine:
Step 1: In the Visual Studio, you can click on “Connection Indicator “


Step 2: You Can Select your mac name from mac agent window and click on “connect”.
Step 3: you can enter mac username and password and Click on Login .

After connection, Connection indicator color will change to green, If its connection is very less bandwidth means it will change to orange color (it’s not recommended for debug application)
Your app will compile and execute, but you won’t see it running on Windows. Instead, you’ll see it on your Mac build host.
iOS Simulator Remoting:
The Evolve 2016 Conference, Xamarin announced iOS Simulator remoting that will soon allow you to interact with apps running in Apple iOS simulator as through the Simulator were running on your Windows Machine.
iOS Simulator Remoting also you need follow above all the steps and below steps as well
Windows Machine
Step 1: Download the installer and install on your Windows computer
Step 2: After install, In Visual Studio go to Tools > Options > Xamarin > iOS Settings and tick the box for Remote Simulator to Windows:


Output:
Now build and run solution and ios simulator will open in windows machine

Issues and Resolution:
Issue 1:
Error Cannot resolve reference: C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0/Facades/System.IO.FileSystem.Watcher.dll I1Vector.iOS
Resolution:
This issue happened because of different versions of Xamarin.iOS on Windows Machine and mac machine. After updating xamarin.ios, this problem will get resolved.
How to Check xamarin.iOS Version Number ?
In Windows Machine, Go to Visual Studio ➔ Help ➔ About Microsoft Visual Studio
In mac machine, Go to Xamarin Studio ➔ Select Xamarin Studio Menu ➔ Click About Xamarin Studio ➔ click Show details


How to Update Xamarin.Ios in Mac and Windows?
Mac Machine:
Go to xamarin Studio and Click on “Check for Update” and Update
Windows Machine:
Go to Visual Studio ➔ Tools ➔ extensions and updates.
Some time it won’t available in update list. if it’s not available, go to control Panel➔Uninstall program  ➔ Select Visual studio ➔ and Click Change option and update
Issue 2: Mac Agent can't connect after update:
Starting connection to mac machine. Xcode license must be accepted in order to be connected and working against the Mac
Solution:
  1. Go to Xcode Preferences Location
  2. Check if "Command Line Tool" set or Select XCode version
  3. Run sudo xcodebuild -license in terminal
  4. Xcode license must be accepted press Space bar and press q
Issue 3: iOS simulator not display on Windows
Solution 1: Check Windows and Mac firewall rule or disable and test application.
Solution 2:
You need make sure xcode installed in Application Folder. If it’s not ,you need to change in visual studio Apple SDK path





Saturday, November 5, 2016

Store Data and Access from any Pages in xamarin.Form

Introduction:
The State Persistence between app restarts and when suspending/resuming.  The values in the Properties dictionary are only stored when the app goes to Start(OnStart), sleep(OnSleep), resime(OnResume) method.  I have tried with application crashes out with an exception properties it’s not saved.
Xamarin.Forms plugin which uses the native settings management. Refer below image different platform state persistence.
This can be accessed from anywhere in your Xamarin.Forms code using Application.Current.Properties .The syntax look like below


Application.Current.Properties [ <StringKey> ] = <Assign Object Type Value >;



Application different Action:
Refer below code for different xamarin Form application property action like assign,read,delete,Clear value.
Set value:
Key value always should be string and Value should be object (any type)
Application.Current.Properties["Email"] = "jssuthahar@gmail.com";


Get Value:
While getting the value, check if its available or not and always convert object type into your specific variable type.
if (Application.Current.Properties.ContainsKey("Email"))
           {
               var emailId = Convert.ToString(Application.Current.Properties["Email"]);
           }

If you want to reuse the same key value or update value. just assign value like below
Application.Current.Properties["Email"] = "nikhil@msdn.com";


The properties dictionary can only serialize primitive types for storage. Attempting to store other types like List<int> can fail silently
Remove Value:
If you want to remove application key and value, try below code
if (Application.Current.Properties.ContainsKey("Email"))
           {
              Application.Current.Properties.Remove("Email");
           }

Clear Value:
You can clear all the application property value  
 Application.Current.Properties.Clear();


If you have question type(?) ask in Comments Box