Cross-Platform Mobile Development in Visual Studio

4,820 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,820
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
87
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Fast Enough for Games Native UX means that apps look like they belong Full platform SDK Access means that anything you can do in Obj-C on iOS or Java in Android, you can do here. Animation libraries, Media libraries, etc.
  • Need better graphic for this.
  • Need Visual Studio Screenshot
  • A good layered architecture allows for proper separation of responsibility and encapsulation, providing isolation to allow for code changes and maximizing code sharing between platforms. It also provides a pattern-agnostic framework so you can pick and choose which patterns you want to use, and then be flexible to changing them later on. And this is very simple to do. We’ll see later on how to accomplish this with proper namespacing and project setup.
  • Xamarin supports portable library projects, but they pose practical problems in real-world scenarios because of dependencies. it eliminates the ability to use ifDefs, so you have to do massive architectural refactoring, use the provider/simple dependency pattern, etc. to solve even minor things. Best way, instead is to link your code.
  • Don’t use .Android - the namespace will cause you hell
  • Download install, and configure the plugin as state on the git page. Must create the initial MonoTouch application on a mac. Copy it over to your VS machine, into your project. or just synchronize in your source control. Edit the <ItemGroup> that has the “System” entry to include the mscorlib and monotouch items Finally, remove the mscorlib.dll reference in project settings : build : advanced.
  • Download install, and configure the plugin as state on the git page. Must create the initial MonoTouch application on a mac. Copy it over to your VS machine, into your project. or just synchronize in your source control. Edit the <ItemGroup> that has the “System” entry to include the mscorlib and monotouch items Finally, remove the mscorlib.dll reference in project settings : build : advanced.
  • Xamarin supports portable library projects, but they pose practical problems in real-world scenarios because of dependencies. it eliminates the ability to use ifDefs, so you have to do massive architectural refactoring, use the provider/simple dependency pattern, etc. to solve even minor things. Best way, instead is to link your code. There are two ways to do this. The magical way, or the manual way. Automatic linking is done fia the Project Linker VS Add-in. Manual is just plain old file links - your only option in MD. Simply add a project link to the corelib, and when you add/remove classes there, they’ll show up in your app projects. if you put your classes in folders, they’ll link nicely into your apps. The manual way is to simply add existing files and make sure they’re added as links.
  • You can use SQLite on all three mobile platforms, iOS, Android, and WP7. on iOS and Android, SQLite is bundled with it, and on Windows Phone, you can use the open source C# port. We’ll show later how to easily support this cross platform with the same exact API. Additionally, we recommend SQLite.NET ORM for easy data access. For Data Access, we’ve added some nice convenience methods in TaskDatabase.cs that make the basic CRUD operations a snap with zero code.
  • Platforms are different. pInvoke is available on iOS and Android, not on WP. SQLite is native on Android and iOS, on WP you have to use the C# lib. Devices also have different features. Cameras are different on nearly every single android device out there. Some devices have location features, some don’t. Some vary, etc.
  • There are predefined symbols that allow you to use different code, depending on the platform you’re building for. Additionally, you can define your own symbols in Build Settings. Demo of this in use can be found here: TaskyPro :: CoreLib.DataLayer/SQLite.cs
  • ITask - Interface TaskBase - Task class DialogTask - with MT.D annotations
  • Cross-Platform Mobile Development in Visual Studio

    1. 1. XamarinMobile Cross Platform Development in Visual Studio
    2. 2. bryan costanichem: bryanc@xamarin.comtw: @bryancostanichslides:slideshare.net/bryancostanich/crossplatform-mobile-development-in-visual-studio
    3. 3. Sample Codegithub.com/xamarin/mobile-samples/TaskyPro
    4. 4. Xamarin Platform
    5. 5. One Language + C# Framework LINQ Lambdas Task Parallel Library (TPL) Compile-Time Checks Garbage Collectionº
    6. 6. Native Perf. + UX Compiles Down to Native Code Not Interpreted All Native UX Controls Full Platform SDK Access iOS: Selectors/Obj-C Runtime Android: JNI Fast Enough for Gamesº
    7. 7. Reuse Story C# Libraries Obj-C Bindings + Binding Projects .jar Bindings + Binding Projects C via pInvoke C++ via Cxxiº
    8. 8. Other PlatformsWindows - via .NETMac - via Xamarin.MacLinux - via MonoEtc.
    9. 9. Community + Support Huge C# Community StackOverflow.com IRC + chat.xamarin.com Great Supportº
    10. 10. General XPlat Considerations
    11. 11. Design Platform-Specific UX UX in iOS != Android != Windows Phone UX Metaphors are Different: Navigation Controller vs. Back Button Write-Once, Run-Anywhere is Problematic Users Expect Native UXº
    12. 12. Choose Device Targets iPhone != iPad Beware Android Fragmentation Form Factor + Capability Differences Inform UX Pro-Tip: Minimize Targetsº
    13. 13. Building an X-Plat Architecture
    14. 14. Architecture Layers Separation of Responsibility Encapsulation Core Code Sharingº
    15. 15. VS Project/Solution Setup
    16. 16. Code Sharing - Linking vs. PCL Portal Library Projects - Take a Lot of Work Great Discussion Here: http://forums.xamarin.com/discussion/28/challenges-thoughts-loves/p1 Takeaway: PCL is clean, but difficult to implement Linking is less “clean” but simpler Our Recommendation Now: File Linking for Most Projects Walkthrough Here: Linkingº
    17. 17. WP7 + Android New Blank Solution: "[AppName]" New C# Lib Project: "[AppName].Core" Test Project: “[AppName].Core.Tests” New Mono for Android Project: “[AppName].Droid” New WP7 Project "[AppName].WP7"º
    18. 18. iOS - Visual Studio 2012 VS MonoTouch Plugin: https://github.com/ste8/VSMonoTouch Visual Studio SDK (to build plugin): http://msdn.microsoft.com/en-us/library/bb166441(v=vs.80).aspx iOS - Visual Studio 2010 VS MonoTouch Plugin: https://github.com/follesoe/VSMonoTouchº
    19. 19. .csproj edit: iOS - Plugin Config <ItemGroup> <Reference Include="mscorlib" /> Create iOS Project (on Mac): "[AppName].iOS"<Reference Copy to Solution Directory or Synch in Source Include="monotouch" /> Manually Edit iOS .csproj File, add Refs -> <Reference Include="System" /> Remove CoreLib Reference -> <Reference Include="System.Xml" /> Limitations: Can Build, but No Designer, or <Reference Deployment Include="System.Core" /> (must use Mac for now**) </ItemGroup>º
    20. 20. Shared Code Linking Two Linking Options: Auto or Manual Auto: Use Project Linker VS Add-In Add a project link, voila. (2010 + 2012) Manual: Link Files Add Files as Linksº
    21. 21. Shared Data + Data Access Layer Data Access Layer SQLite on iOS + Android, C# SQLIte on WP7: http://code.google.com/p/csharp-sqlite/ SQLite.NET ORM Use Generics for CRUD Convenience Methods: TaskDatabase.csº
    22. 22. Platform AbstractionsHandling Divergence and Taking Advantage of PlatformFeatures
    23. 23. ConditionalCompilationPre-Defined Symbols: #if __ANDROID__ #if WINDOWS_PHONE #if SILVERLIGHTCan Add Additional in Build Settings
    24. 24. Class Abstraction Sometimes, You Wanna Provide Different Implementations for Different Platforms Partial Classes Partial Methods Interfacesº
    25. 25. Xamarin.MobileXPlat API AbstractionsXamarin.com/MobileAPI Compass + Contacts Geolocation Acceleromete Camera Notifications r
    26. 26. Other XPlat Libs MonoCross - http://code.google.com/p/monocross/ MvvmCross - https://github.com/slodge/MvvmCross Vernacular - https://github.com/rdio/vernacular MonoGame - http://monogame.codeplex.com/º
    27. 27. Q+A

    ×