Wednesday, November 6, 2019
iOS Development in C# with Xamarin and Visual Studio
iOS Development in C# with Xamarin and Visual Studio In the past, you may have considered Objective-C and iPhone development but the combination of a new architecture and a new programming language together may have been too much. Now with Xamarin Studio, and programming it in C#, you may find the architecture not that bad. You may end up coming back to Objective-C though Xamarin makes feasible any type of iOs programming including games. This is the first of a set of tutorials on programming iOS Apps (ie both iPhone and iPad) and eventually Android Apps in C# using Xamarin Studio. So what is Xamarin Studio? Previously known as MonoTouch Ios and MonoDroid (for Android), the Mac software is Xamarin Studio. This is an IDE that runs on Mac OS X and its pretty good. If youve used MonoDevelop, then youll be on familiar ground. Its not quite as good as Visual Studio in my opinion but thats a matter of taste and cost. Xamarin Studio is great for developing iOS Apps in C# and likely Android, though that depends on your experiences creating those. Xamarin Versions Xamarin Studio comes in four versions: Theres the free one that can create Apps for the App store but those are limited to 32Kb in size which is not a lot! The other three cost starting with the Indie version for $299. On that, you develop on the Mac and can produce Apps of any size. Next is the Business version at $999 and thats the one used for these examples. As well as Xamarin Studio on the Mac it integrates with Visual Studio so you can develop iOS/Android apps as if writing .NET C#. The clever trick is that it uses your Mac to build and debug the App using the iPhone/iPad simulator while you step through code in Visual Studio. The big version is the Enterprise edition but that wont be covered here. In all four cases you need to own a Mac and to deploy Apps in the App store needs you to pay Apple $99 each year. You can manage to offset paying that until you need it, just develop against the iPhone simulator that comes with Xcode. You have to install Xcode but its in the Mac Store and its free. The Business edition does not have a big difference, just that it is on Windows instead of the Mac with free and Indie editions, and it uses the full power of Visual Studio (and Resharper). Part of that comes down to whether you prefer to develop Nibbed or Nibless? Nibbed or Nibless Xamarin integrates into Visual Studio as a plugin that gives new menu options. But it doesnt yet come with a designer like the Xcodes Interface Builder. If you are creating all your views ( the iOS word for controls) at runtime then you can run nibless. A nib (extension .xib) is an XML file that defines the controls etc in views and links events together so when you click on a control, it invokes a method. Xamarin Studio also requires you to use Interface Builder to create nibs but at the time of writing, they have a Visual designer running on the Mac in alpha state. It will likely become available on the PC as well. Xamarin Covers the Whole iOS API The whole iOS API is pretty massive. Apple currently has 1705 documents in the iOS developer library covering all aspects of iOS development. Since they were last reviewed, the quality has improved a lot. Likewise, the iOS API from Xamarin is pretty comprehensive, though you will find yourself referring back to the Apple docs.ââ¬â¹ Getting Started After installing Xamarin software on your Mac, create a new Solution. The project choices include iPad, iPhone, and Universal and also with Storyboards. For iPhone, you then have the choice of an Empty Project, Utility Application, Master-Detail Application, Single View application, Tabbed Application or OpenGl Application. You have similar choices for Mac and Android development. Given the lack of designer on Visual Studio, you can take the nibless (Empty Project) route. Its not that difficult but nowhere as easy to get the design looking spot on. In this case, as you are mainly dealing with square buttons, its not a worry. Architecting iOS Forms You are entering into a world described by Views and ViewControllers and these are most important concepts to understand. A ViewController (of which there are several types) controls how data is displayed and manages view and resource management tasks. The actual displaying is done by a View (well a UIView descendant). The User Interface is defined by ViewControllers working together. Well see that in action in tutorial two with a simple nibless App like this one. In the next tutorial, well look in depths at ViewControllers and develop the first complete App.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.