Anzeige
Anzeige

Más contenido relacionado

Anzeige

X-Platform native apps in C# and .NET using Xamarin tools (iOS/WP/Android)

  1. INTRODUCING XAMARIN 2.0 Pls check our blog at NFLXUG.com North Florida Xamarin User Group
  2. X-PLATFORM NATIVE APPS IN C# AND .NET USING XAMARIN TOOLS (IOS/WP/ANDROID) MARK J RADACZ, MCTS DEVELOPER, GLOBAL RAD SOLUTIONS, LLC WWW.MDUGJAX.COM WWW.NFLXUG.COM BLOG: XRADAPP.COM @MARKRADACZ
  3. LIVE THE LIFE YOU LOVE.. LOVE THE LIFE YOU LIVE…
  4. Who am I? Mark J Radacz  #HusbandFatherLife-LongMateGeek  Enjoying every trip around the Sun  MCTS, Consultant, Developer  10 years in .NET + iOS recently  Ex-Blackberry-Apple-WP “fanboy”
  5. QUESTION: CAN I WRITE CODE ONCE AND RUN ON ALL DEVICES?
  6. Write C# Run on 2.5+ billion devices With Xamarin, you write your apps entirely in C#, sharing the same code on iOS, Android, Windows and Mac
  7. AGENDA  What is Xamarin Studio  Why choose Xamarin tools  UX Design  Code Demo in iOS, WP and Android
  8. WHAT IS XAMARIN  Write in C# - run on iOS (iPhone, iPodTouch, iPad) and Android  Built on top of Mono  Xamarin Studio - Mac OS X APIs  Xamarin.Android - Android SDK APIs  .NET Base Class Library (BCL)  LEGIT!
  9. HOW XAMARIN WORKS Your shared code never needs to know the difference!
  10. WHY CHOOSE XAMARIN
  11. APPS IN C# FOR IOS, ANDROID AND WP  Write apps in C# (run on 2.5 billion devices)  shorter, more maintainable code  advanced language features (Language Integrated Query (LINQ), delegates, lambdas, events, garbage collection and many other)  Reuse up to 90% of code between platforms  Native UI, Native Performance  Modern Language, Powerful Framework  .NET Libraries and Objective-C libraries  Rich IDE Support (also edit code in VS)
  12. ANDROID DEVICE FRAGMENTATION July 2013 11,686 devices http://opensignal.com/reports/fragmentation-2013/ July 2012 3,997 devices
  13. SCREEN SIZES http://opensignal.com/blog/2013/07/30/40-developer-tips-for-android- Android iOS
  14. POWERFUL XAMARIN DESIGNER
  15. XAMARIN COMPONENT STORE
  16. SHARE CODE BETWEEN PLATFORMS  App functionality – save development time business logic data access and network communications  Xamarin helps to share the same C# code across iOS, Android, Mac, and Windows  GUI Designed separately on Each platform
  17. MVVMCROSS
  18. SHARING CODE BETWEEN PLATFORMS  File Linking into each App Project  File Linking into Separate Projects  Cloned Project Files  Microsoft Project Linker http://bit.ly/12C4pNF
  19. FILE LINKING
  20. FILE LINKING TO SEPARATE PROJECTS
  21. Developing with Xamarin Xamarin Studio PC or Mac Visual Studio Plugin VS 2012/2013
  22. XAMARIN TEST CLOUD  Start immediately  Useful Visual Reports  Hundreds of non-jailbroken devices  Test for fragmentation  Built for Continuous Integration  Object-based UI testing  script-free and scriptable
  23. TESTING MOBILE APPS
  24. TEST CLOUD INTERFACE
  25.  Scripting technology for Xamarin Test Cloud  UI Test Automation for iOS & Android  Run UI tests on Devices or Simulators/Emulators  Supports Behavior Driven Development (BDD)  Provides the Automation APIs needed to interact with UI controls in an app wait for events to occur (i.e. no network activity) make assertions about the visible view generate screenshots of the app app-lifecycle APIs (start/stop, uninstall, etc)
  26. UX DESIGN
  27. *UIKitten pic snagged from FrankAKrueger
  28. PLATFORM SPECIFIC SCHETCHES/WIREFRAMES UX Wireframes using Balsamiq, Mockingbird, Visio, etc
  29. PLATFORM SPECIFIC UX i.e. W8 - Live Tiles
  30. PLATFORM SPECIFIC UX i.e. iOS7 – (still) no back button
  31. DEVICE SPECIFIC UX Phone vs Tablet
  32. FOLLOW PLATFORM SPECIFIC UX  Apple - Human Interface Guidelines  Android – Design Guidelines  Windows Phone – UX Design Guidelines for WP
  33. CODE DEMO(S)
  34. PHONEWORD
  35. SUMMARY  What is Xamarin Studio  Why choose Xamarin tools  UX Design  Code Demo in iOS, WP and Android
  36. Q&A
  37. REFERENCES  UX Design for Devs  Tapworthy by Josh Clark http://www.youtube.com/watch?v=QU5Il9qVfbM  Universal Principles of Desing by William Lidwell et. al.  BillyHollis.com (watch: The Whole Brain Developer )  Videos http://www.youtube.com/user/XamarinHQ  Sample GitHub Repositories  https://github.com/xamarin/mobile-samples (x-platform)  https://github.com/xamarin/monotouch-samples  https://github.com/xamarin/monodroid-samples https://github.com/xamarin/Seminars  Xamarin.com/University
  38. TEST CLOUD REFERENCES  http://xamarin.com/test-cloud  http://docs.xamarin.com/  https://github.com/calabash-ios  https://github.com/calabash-ios/wiki  https://github.com/calabash/field-service-example  https://github.com/calabash/x-platform-example
  39. REFERENCES  Xamarin DevCenter - http://docs.xamarin.com/guides/cross-platform/ free/$299/$999/$1899 per year per platform (starter/Indie/Business/Enterprise)  UX Apple - Human Interface Guidelines Android – Design Guidelines Windows Phone – UX Design Guidelines for WP  DevCenter Memberships Apple – http://developer.apple.com ($99/year) Android – http://developer.android.com ($25) Win Store – http://dev.windowsphone.com ($19/99 year)  XUG & My Info www.NFLXUG.com blog: www.iRadApp.com radacz.mcp@gmail.com @MarkRadacz

Hinweis der Redaktion

  1. WP over iPhone and AndroidCall quality. I actually use my phone as a phoneSimplicity. Samsung Focus S, Nokia 900 and Nokia 800 were flawless out of the box. No junk software. Speaking of science experiments, I also tried a Android on Samsung Galaxy, Captivate, HTC MyTouchsoftware that cannot be deleted and restarts itself? Simplicity again. Everything after set up has been painless as well. Adding apps, setting up email accounts, etc. I thought the iPhone was good. WP set up was actually smoother and took WAY less time. Same for Wi-Fi, etc.Speed. The 900 4Gdidn’t seem to lag the way the iPhone did at times. Live Tiles. It’s a minor thing but the Metro tiles are pretty cool.
  2. Use any native APIXamarin's binding technology exposes all of the APIs available in iOS and Android to your applications as regular C# class libraries. This means your Xamarin application can do anything a platform, or device, offers, with native user interface and excellent performance.
  3. Native compilationXamarin's compiler is smart - so smart that it can produce exactly the right output for each platform. Xamarin.iOS does full Ahead-of-Time (AOT) compilation to produce an ARM binary suitable for Apple's App StoreXamarin.Android takes advantage of Just In Time compilation right on the Android device. Your shared code never needs to know the difference!
  4. Leverage the full .NET runtimeXamarin contains a fully functional implementation of the .NET runtime, called Mono, which is bundled with your app so that your code executes with all of the power of C# and .NET, including memory management, reflection, and the .NET base class libraries. Create fully native apps with device-specific experiences that today’s mobile users demand. Xamarin delivers high performance compiled code with full access to all the native APIs that make each device platform unique.With Xamarin, you can write your mobile apps entirely in C#. Not only can you write succinct, strongly typed and garbage-collected code, you can utilize Language Integrated Query (LINQ), Delegates and Events, and easily import existing libraries written in C#, C/C++, Java, and Objective-C.Xamarin allows you to share all the non-UI code across iOS, Android, Mac and Windows apps, significantly reducing the barrier to building and maintaining multi-platform apps. Save time building apps in this heterogeneous computing world by sharing up to 90% of your code.Xamarin gives you great tools to design, develop, debug and deploy apps. Point and click to create user interfaces, explore native iOS and Android APIs as you type with code autocompletion, debug apps running on emulator or device, and distribute apps to app stores or internally. Use Visual Studio or use our own cross-platform IDE, MonoDevelop.It is possible to edit code in Visual Studio have access to ReSharper and other tools, than move it over to MonoDevelop
  5. Samsung have a 47.5% share of the Android market.Samsung are, with Sony-Ericsson in second with a 6.5% market share - less than 1/6th of Samsung's. Some of the brand names shown as different in the graphic are part of the same company, i.e. Moto and Motorola are the same and HTC is shown as split up into its different regional variants. But even when unified under one umbrella name Motorola only ends up with a 4.2% share and HTC even less at 3.9%. Fragmentation is both a strength and weakness of the Android ecosystem. When comparisons are made between Android and iOS the issue of different API levels, and the vastly different devices running them, is often emphasised. In this report we examine the extent of Android fragmentation and analyse its impact on both users and developers.The Problem:Android devices come in all shapes and sizes, with vastly different performance levels and screen sizes. Furthermore, there are many different versions of Android that are concurrently active at any one time, adding another level of fragmentation. What this means is that developing apps that work across the whole range of Android devices can be extremely challenging and time-consuming. The Advantage:Despite the problems, fragmentation also has a great number of benefits – for both developers and users. The availability of cheap Android phones (rarely running the most recent version) means that they have a much greater global reach than iOS, so app developers have a wider audience to build for. It may be tricky to do, but the potential reward definitely makes it worthwhile. For consumers, extreme fragmentation means that they can get exactly the phone they want – big or small, cheap or expensive, with any number of different feature combinations.
  6. The iOS designer is Xamarin Studio’s alternative to Xcode’s Interface Builder that provides an integrated experience for working with Storyboards. It is similar to the Xamarin.Android designer, and facilitates building Views using drag-and-drop functionality and property fields.
  7. Share code between platformsArchitect your app so that the UI is cleanly separated from the rest of the code. Deliver a device-specific, native user experience by writing code that calls the native APIs, while sharing business logic, data access, and network communications code.
  8. File Linking into each App Project – Use the ‘file linking’ feature of Visual Studio & Xamarin Studio to include the same file in each platform’s application. File Linking into Separate Projects – Use the ‘file linking’ feature of Visual Studio & Xamarin Studio to include the same file in multiple library projects (one for each platform). Cloned Project Files – Rather than linking, directly include the same files in multiple projects (one for each platform). Microsoft Project Linker – A tool that only runs on Windows, which keeps multiple project files synchronized as source files are added to each.---------------Portable Class Libraries are the simplest way to share code across multiple platforms, however they have some disadvantages including the custom configuration currently required to install PCL support.File linking or cloned project files are simpler to create but require constant manual intervention to keep them synchronized.The code sharing strategy you choose will be driven by the platforms you are targeting. Choose a method that works best for your project.
  9. File Linking - The simplest approach to sharing code files is to place them in a separate directory (ie. outside of your various mobile application projects) and use file-linking to include them1.1. ExampleA cross platform application that supports iOS, Android and Windows Phone would require an application project for each platform. The shared code lives in a separate filesystem directory from all the projects, and all the shared source code files are linked in to each application’s project.An example solution would contain the following folders and projects (project names have been chosen for expressiveness, your projects do not have to follow these naming guidelines):Core – Filesystem directory containing the shared code. Optionally create a “csproj” file to manage the source, but this project file will not be referenced by any other part of the solution. AppAndroid – Xamarin.Android application that contains linked-files for all the source code in the Core directory. AppiOS – Xamarin.iOS application that contains linked-files for all the source code in the Core directory. AppWP7 – Windows Phone application that contains linked-files for all the source code in the Core directory. In this way the three application projects are effectively sharing the same source code (the C# files in Core.Android). Any edits to the shared code will be shared across all three projects – however, file additions or deletions must be done manually. Add files in the filesystem (or use a separate library project to contain them) and then update all the application projects’ linked files to keep them in sync.1.2. BenefitsAllows you to share code across multiple projects.Shared code can be branched based on the platform using compiler directives (eg. using #if __ANDROID__, Application projects can include platform-specific references that the shared code can utilize (such as using Community.CsharpSqlite.WP7 in the Tasky and MWC samples). 1.3. DisadvantagesIn Visual Studio there is no simple way to add an entire filesystem ‘tree’ to a project, so files must be individually added. The directory hierarchy must also be manually created. If you add, delete or move a file in one project you must remember to perform the same action in all the other project files. Refactoring will only work within one platform type.Empty subdirectories must also exist before you can ‘link’ files contained within a subdirectory. If you forget to choose Add As Link (in Visual Studio), it will copy the file into your target project instead of linking. If you don’t notice this has occurred you could accidentally edit both the original file and the copy, getting them out-of-sync. 1.4. RemarksWorks for all platforms but requires careful, manual management of file links.
  10. 2. File linking to separate projects2.1. ExampleA cross platform application that supports iOS, Android and Windows Phone would require three shared-code project files and three application projects. Because the Android project can be loaded in both Xamarin Studio and Visual Studio it makes sense to use it as the ‘source’ project.An example solution would contain the following folders and projects (project names have been chosen for expressiveness, your projects do not have to follow these naming guidelines):Core.Android.Source – Xamarin.Android Library Project that contains the shared source files. Core.iOS.Linked – Xamarin.iOS Library Project that links to all the files in Core.Android. This project contains the same directory structure as Core.Android but NO physical C# files, they are all linked. Core.WP7.Linked – Windows Phone Library Project that links to al the files in Core.Android. This project contains the same directory structure as Core.Android but NO physical C# files, they are all linked. AppAndroid – Xamarin.Android application that references Core.Android. AppiOS – Xamarin.iOS application that references Core.iOS. AppWP7 – Windows Phone application that references Core.WP7. In this way the three application projects are effectively sharing the same source code (the C# files in Core.Android). Any changes to the shared code should be done in the Core.Android project – file additions or deletions must then be manually re-done in the other two Core projects with linked files to keep them in sync.2.2. BenefitsAllows you to share code across multiple projects.Platform-specific projects can each have different compiler directives defined, so you can branch code based on the platform (eg. using #if __ANDROID__, as discussed in the [Building Cross Platform Applications] document). Platform-specific projects can include platform-specific references (such as using Community.CsharpSqlite.WP7 in the Tasky and MWC samples). The code using these references can be managed with compiler directives. 2.3. DisadvantagesIn Visual Studio there is no simple way to add an entire filesystem ‘tree’ to a project, so files must be individually added. The directory hierarchy must also be manually created. If you add, delete or move a file in one project you must remember to perform the same action in all the other project files. Refactoring will only work within one platform type.The project file must live in a separate directory to enable files to be linked. Empty subdirectories must also exist before you can ‘link’ files contained within a subdirectory. If you forget to choose Add As Link (in Visual Studio), it will copy the file into your target project instead of linking. If you don’t notice this has occurred you could accidentally edit both the original file and the copy, getting them out-of-sync. 2.4. RemarksWorks for all platforms but requires careful, manual management of file links.
  11. Xamarin StudioIDE for developing cross-platform apps with C#. Available for Mac and Windows.Xamarin for Visual StudioVisual Studio add-ins so that you can develop your Android, iOS and Windows apps all in a single solution.Xamarin.AndroidAndroid phone and tablet apps in C#, using Xamarin Studio or Visual Studio.Create Android app layouts from directly within Visual Studio and Xamarin Studio with drag and drop simplicity.Xamarin.iOSiPhone and iPad apps in C#, using Xamarin Studio or Visual Studio.Xamarin.MacNative Mac apps in C#. Expand your app reach to 66 million Macs and reach new users through the Mac App Store.Xamarin.MobileLibrary that increases code-sharing by exposing a single set of APIs for accessing common mobile device functionality across device platforms.
  12. Find bugs before your users do.Start immediatelyQuick and easy to get started with the Xamarin App Explorer.Beautiful reportsMore than detailed technical feedback: visual reporting and performance monitoring.Hundreds of devicesBe confident that your apps function correctly and looks great on actual physical devices.Test for fragmentationTest automatically on hundreds of combinations of operating systems, screens, and resolutions.Continuous IntegrationUse command line tool to run your tests or execute automated acceptance tests as part of your continuous integration process or ALM.Object-based UI testingTest your entire app, from the UI down, using object-level user interface testing.
  13. Lowest-Common-Denominator User InterfacesOne of Xamarin’s strengths is the ability to build a native UI on each platform. Avoid re-using the user-interface design across iOS, Android and Windows Phone without tweaking it for each platform. For example: don’t build a ‘Back’ button into your Android or Windows Phone applicationsdon’t build a custom tabbed-control for iOS where the tabs sit across the top of the screen. Use the metaphors that the users on each platform are familiar with.
  14. MWCPhonewordEmployee DirectoryField Service on iOS
  15. Here is a summary of the key points for creating Xamarin cross-platform apps:Use C# - Write your apps in C#. Existing code written in C# can be ported to iOS and Android using Xamarin very easily, and obviously used on Windows Phone. Utilize the MVC design pattern - Develop your application’s User Interface using the Model/View/Controller pattern. Architect your application using a Model/View/Controller approach or a Model/View/ViewModel approach where there is a clear separation between the “Model” and the rest. Determine which parts of your application will be using native user interface elements of each platform (iOS, Android, Windows Phone and Windows 8/RT) and use this as a guideline to split your application into two components: “Core” and “User-Interface”. Build native UIs - Each OS-specific application provides a different user-interface layer (implemented in C# with the assistance of native UI design tools): On iOS use the MonoTouch.UIKit APIs to create native-looking applications, optionally utilizing Apple’s Interface Builder. On Android, use Android.Views to create native-looking applications, taking advantage of Xamarin’s UI designer On Windows Phone you will be using the XAML/Silverlight presentation layer, using Visual Studio or Blend’s UI designer On Windows 8, use the Metro APIs to create a native user experience.The amount of code re-use will depend largely on how much code is kept in the shared core and how much code is user-interface specific. The core code is anything that does not interact directly with the user, but instead provides services for parts of the application that will collect and display this information.To increase the amount of code re-use, you can adopt cross-platform components that provide common services across all these systems such as:SQLite-NET for local SQL storage, Xamarin.Mobile for accessing device-specific capabilities including the camera, contacts and geolocation, Using framework features for networking, web services, IO and more.Some of these components are implemented in the Tasky Pro and MWC 2012 case studies.Separate Reusable Code into a Core LibraryBy following the principle of separation of responsibility by layering your application architecture and then moving core functionality that is platform agnostic into a reusable core library, you can maximize code sharing across platforms, as the figure below illustrates:
Anzeige