1 00:00:00,830 --> 00:00:04,800 Now that we've discussed some of the challenges with mobile development and 2 00:00:04,800 --> 00:00:08,070 how Xamarin can help, let's look at how it works. 3 00:00:09,250 --> 00:00:13,390 Each platform has its own feature set, application framework, and 4 00:00:13,390 --> 00:00:14,630 execution differences. 5 00:00:16,290 --> 00:00:18,440 Xamarin has Base Class Libraries, or 6 00:00:18,440 --> 00:00:24,440 BCLs which provide many features usually found in the .NET framework. 7 00:00:24,440 --> 00:00:28,210 They're implemented on the native platform and exposed through the BCL. 8 00:00:29,270 --> 00:00:32,945 For example, in the BCL there's support for Streams, IO, 9 00:00:32,945 --> 00:00:38,450 XML, Databases, and Networking. 10 00:00:38,450 --> 00:00:44,420 These provided base class libraries have the same signature as the dot net BCL. 11 00:00:44,420 --> 00:00:47,860 So we can write the same code for each platform. 12 00:00:47,860 --> 00:00:52,712 There are libraries provided by Xamarin that are included in each platform project 13 00:00:52,712 --> 00:00:57,690 that provide implementation for platform SDKs. 14 00:00:57,690 --> 00:01:00,660 All these features are plugged into Visual Studio and 15 00:01:00,660 --> 00:01:05,010 include IntelliSense, tools and compilation features. 16 00:01:06,100 --> 00:01:11,170 Xamarin provides bindings to the native libraries and SDKs for each platform. 17 00:01:12,390 --> 00:01:16,770 Bindings are strongly typed and are designed to follow C# standards. 18 00:01:18,540 --> 00:01:22,730 This gives developers a single consistent programming syntax 19 00:01:22,730 --> 00:01:25,140 regardless of the target platform. 20 00:01:25,140 --> 00:01:29,910 For example, Java does not have a concept of properties. 21 00:01:29,910 --> 00:01:34,150 So you use Get and Set methods to update a class variable. 22 00:01:34,150 --> 00:01:38,700 But, Xamarin wraps them in a property to match C# standards. 23 00:01:38,700 --> 00:01:39,670 Other than that, 24 00:01:39,670 --> 00:01:45,080 converting Java code to C# is relatively simple cuz they share a lot of syntax. 25 00:01:46,260 --> 00:01:52,140 For Objective-C developers, there are many differences between Objective-C and C#. 26 00:01:52,140 --> 00:01:54,540 So if you're converting from Objective-C, 27 00:01:54,540 --> 00:01:57,800 there's some articles in the teacher's notes to help with the transition. 28 00:01:58,840 --> 00:02:02,690 Xamarin also allows us to create an interop between 29 00:02:02,690 --> 00:02:05,540 any of our favorite Objective-C or Java libraries. 30 00:02:06,570 --> 00:02:11,300 Using a declared syntax we can bind any pre-existing library, and 31 00:02:11,300 --> 00:02:15,110 make it look like a C# class and use it in our app. 32 00:02:16,360 --> 00:02:19,090 Compilation is where all the magic happens, so 33 00:02:19,090 --> 00:02:21,330 we'll spend a few minutes talking about how it works. 34 00:02:22,330 --> 00:02:26,570 As I said earlier, Android and iOS have fundamental execution differences. 35 00:02:27,580 --> 00:02:30,705 Android uses a just in time execution model or 36 00:02:30,705 --> 00:02:35,280 JIT which means that it compiles to an intermediate language 37 00:02:35,280 --> 00:02:38,140 that is interpreted and executed when the app launches. 38 00:02:40,120 --> 00:02:44,670 iOS on the other hand uses an ahead-of-time execution model or 39 00:02:44,670 --> 00:02:49,340 AOT which means everything is compiled directly to native assembly code and 40 00:02:49,340 --> 00:02:50,310 nothing is interpreted. 41 00:02:51,470 --> 00:02:57,080 All of this compilation happens through special platform specific MS built targets 42 00:02:57,080 --> 00:03:01,020 that put all the pieces together and produce the executable artifacts. 43 00:03:02,350 --> 00:03:06,340 It's important to know when compiling for iOS you need a Mac. 44 00:03:06,340 --> 00:03:10,730 Because Apple's licensing does not permit compiling on any other platform. 45 00:03:12,330 --> 00:03:15,030 Android requires your target SDKs and 46 00:03:15,030 --> 00:03:18,350 tools to be on your machine, which can be downloaded when needed.