Top Banner
移动端开发技术的应用与比较
44

移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Jul 26, 2018

Download

Documents

letruc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

移动端开发技术的应用与比较

Page 2: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Agenda

• Architecting Mobile App

• Apache Cordova

• Xamarin

• Cordova vs. Xamarin

Page 3: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms
Page 4: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms
Page 5: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Sweet spot for the successful mobile enterprise

+

+

-

Page 6: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Client development trends

WebNative

Page 7: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Client development trends

Web

Native

Page 8: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Apps dominate the mobile web

80% 86%

20% 14%

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

100%

2013 2014

Time Spent in Apps vs. Browser

Apps Web

Page 9: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Low investment for more capabilities

Capabilities

Develo

per

Investm

ent

Web App

Hybrid App

Native App

Page 10: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Supported PlatformsNative Windows Store + browser / hybrid

Supported PlatformsNative Windows Store / Windows Phone / Desktop support + Native iOS / Android through Xamarin and C#

Supported PlatformsMost OS, but code re-usage via standard C++ subset language

Highest abstraction level

Flexible abstraction level

Lowest abstraction levelC++

Native Client AppsMicrosoft Technology choices

Page 11: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Silo Approach:

Build the Same Apps Multiple Times

Page 12: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

The Silo approach: Build native apps multiple timesMultiple teams and multiple code bases are expensive and slow

Great apps delivered to the user’s choice of device

Development agility hampered by multiple code bases and fragment toolsets

End user experience

Better TCO, productivity andDeveloper Experience

+

+

-

Page 13: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Write Once,Run AnywhereApproach

Lowest Common Denominator

Browser Fragmentation

• App Generation.• Web Browser in a

Native Wrapper + Cordova APIs.

Page 14: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

The write-once-run-anywhere approachHTML Hybrid scenarios (Semi-native apps) like PhoneGap (i.e. Cordova)

End u

ser

experience

Developer experience

Development agility hampered by HTML5 implementations fragmentation and insufficient tooling

Lowest common denominator apps with poor performance✗

Page 15: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Benefits of cross platform development

• Improved reuse of code.• Less duplicated work.• Easier to maintain code base.• Better consistency in implementations.• Leveraging of existing skills on different platforms.• Lower development cost.• Quicker to market for multiple platforms.

Page 16: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Native Wrapper

What is Apache Cordova?

• Open-source framework

• Hosted webview

• Single, shared codebase deployed to all targets

• Plugins provide a common JavaScript API to access device capabilities

<webview>

Your JavaScript App

Cordova Plugin JS API

Page 17: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Cordova @ MS Open Tech• MS Open Tech devs contribute to Cordova

• We released the Visual Studio Tools for Apache Cordova

• Included in Cordova 4.0.0: npm install –g cordova

• Updated the ‘windows’ platform• Support now for Universal Apps

• Windows Phone 8.1 & Windows 8.1

• Native JS/HTML5 development

• does NOT use Webview

• Local Security context vs. Web security context• JavaScript Dynamic Content Shim for Windows apps

• https://github.com/MsopenTech/winstore-jscompat

• Windows Phone 8

• Webview control

Page 18: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Visual Studio Tools for Apache Cordova

Page 19: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Supported Platforms

Android• Uses Android SDK installed locally• Android emulator, Ripple, real device

iOS• Uses agent running on a MAC with Xcode tools installed• Ripple

Windows Store• Device Visual Studio is running on• Simulator• Remote debugging

Windows Phone• Emulator (Hyper-V based)• Real device

Page 20: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Publish & Manage Your App: Pick your deployment!

Deploy to your enterprise via Windows Intune

Manage distribution & version updates

Deploy to the public via Windows Store, Google Play or the Apple Store

Reach the widest audience possible

Page 21: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Where are Microsoft going with this?• Cordova contributions

• Improve the support matrix for most popular plugins• Support for Windows Platform

• Stay in the browser longer• Cordova Browser Platform• Evolve the Ripple emulator

• Interoperability with other tools• CLI• Frameworks (e.g. Ionic)• Grunt, Bower, etc.

• Better coding & debug experiences• Intellisense for popular frameworks• TypeScript

Page 22: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms
Page 23: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

What is Xamarin?

Extension to Visual Studio• iOS, Android apps entirely

within Visual Studio

• Compiles .NET/C# code to

native platforms

• Visual Studio ALM and IDE

capabilities fully available

Build apps faster• Leverage skills

• Reuse code and binaries

with flexibility

• Fully native user interfaces

Page 24: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

• iOS

• Android

• Windows Phone

• Windows Store

• ReSharper

• Team Foundation Server

• Your favorite code coverage and profiling tools

Visual Studio Integration

Page 25: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

• Emulators

• Devices

• Status

• Logs

• List of devices

Visual Studio Integration

Page 26: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

• Xamarin Studio

• Visual Studio

Android Designer

Page 27: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

iOS Designer

Page 28: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms
Page 29: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Windows APIs

Microsoft.Phone Microsoft.Networking Windows.Storage Windows.Foundation Microsoft.Devices

System.Data System.Windows System.Numerics System.Core System.ServiceModel

System.Net System System.IO System.Linq System.Xml

C#

Page 30: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

iOS – 100% API Coverage

MapKit UIKit iBeacon CoreGraphics CoreMotion

System.Data System.Windows System.Numerics System.Core System.ServiceModel

System.Net System System.IO System.Linq System.Xml

C#

Page 31: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Android – 100% API Coverage

Text-to-speech ActionBar Printing Framework Renderscript NFC

System.Data System.Windows System.Numerics System.Core System.ServiceModel

System.Net System System.IO System.Linq System.Xml

C#

Page 32: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Native Performance: How it works

• Xamarin.iOS does full Ahead Of Time (AOT) compilation to produce an ARM binary for Apple’s App Store.

• Xamarin.Android takes advantage

of Just In Time (JIT) compilation on

the Android device.

Page 33: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

How Xamarin.Forms works

Shared App Logic in C#

At runtime, each Xamarin.Forms page and its controls are mapped to platform-specific native user interface elements

iOS C# UI Android C# UI

Shared App Logic

Windows C# UI

Use a single API to generate native, platform-specific user interfaces

Page 34: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Pages

Content MasterDetail Navigation Tabbed Carousel

Page 35: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Layouts

Stack Absolute Relative Grid ContentView ScrollView Frame

Page 36: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

ControlsActivityIndicat

orBoxView Button DatePicker Editor

Entry Image Label ListView Map

OpenGLView Picker ProgressBar SearchBar Slider

Stepper TableView TimePicker WebView EntryCell

ImageCell SwitchCell TextCell ViewCell

Page 37: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Shared Projects

Page 38: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Choosing a Code Sharing Option• Shared Projects / File Linking

• Reuse the same files in multiple projects• Can use conditional compilation

(i.e. #if)

• Portable Class Libraries• Reuse your past investments in .NET code• Common Denominator only• Common code only, no #if conditionals

• Combo Approach• Not mutually exclusive, use both in same

solution• e.g. Shared Project with Xamarin.Forms + UI

code, combined with shared non-UI code in PCL

Page 39: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms
Page 40: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Why Cordova?

72%62%

34%28% 27% 24% 20%

9%

0%

10%

20%

30%

40%

50%

60%

70%

80%

Source: Kendo UI Developer Survey 2013

Page 41: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Why Xamarin?

• High performance application that can access native API• Strong typed and object oriented development to support you flexible

architecture• Drag and Drop user interface development. If you are Windows Developer, no

need to learn JS or HTML. You can build using drag and drop style for IOS or Android.

• Xaml UI and adaptive layout. • Based on Mono runtime and totally open source.

Page 42: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Picking between Xamarin and Apache Cordova

Xamarin is generally better when you:• Xamarin.Forms can help you implement device specified UI• Have .Net developers especially UWP developers• Need a high performing, native looking app like a game

Cordova with Visual Studio is generally better when you:• Want to share more UI between platforms, with fewer native looking elements.• Share UI assets with a mobile website• Have HTML / JS developers• Are OK with a somewhat less smooth UI on older Android and iOS devices, or

don’t plan on supporting older Android

Page 43: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

No matter what’s your choice.Visual Studio 2015 offers both and

FREE!

Page 44: 移动端开发技术的应用与比较download.microsoft.com/download/7/8/D/78D289B4-CC63-4EA8-BB4… · Supported Platforms Native Windows Store + browser / hybrid Supported Platforms

Thanks