2016년 5월 11일 수요일

Tizen Gear S2에서 지역에 따른 date 출력 방법

Tizen Gear S2에서 locale에 따른 date를 출력하기 위해 찾아봄

i18n (Internationalization)
: https://ko.wikipedia.org/wiki/%EA%B5%AD%EC%A0%9C%ED%99%94%EC%99%80_%EC%A7%80%EC%97%AD%ED%99%94

Tizen i18n Tutorial & Guide
: https://developer.tizen.org/ko/development/api-tutorials/native-application/base/i18n#dates
 : https://developer.tizen.org/ko/development/guides/native-application/base/i18n?langredirect=1

Get System Settings for Current Locale, Time Zone
 : https://developer.tizen.org/ko/development/tutorials/native-application/system/system-settings
 : https://developer.tizen.org/ko/development/guides/native-application/system/system-settings?langredirect=1

Date, Time Display Guide by Time Zones
 : https://developer.tizen.org/ko/development/api-tutorials/web-application/tizen-features/system/time



<샘플코드>

#include <utils_i18n.h>
#include <system_settings.h>

bool print_loca_date()
{
i18n_udatepg_h pattern_generator = NULL;
char *locale;

if (SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale))
return false;
dlog_print(DLOG_INFO, LOG_TAG, "Current Locale Country : %s\n", locale);

i18n_udatepg_create(locale, &pattern_generator);
if (!pattern_generator)
return false;

i18n_uchar bestPattern[64] = {0,};
char bestPatternString[64] = {0,};
int bestPatternLength, len;
const char *custom_format = "EEE, MMM d, yyyy 'at' HH:mm:ss zzz";
i18n_uchar uch_custom_format[64];

i18n_ustring_copy_ua(uch_custom_format, custom_format);
len = i18n_ustring_get_length(uch_custom_format);
i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength);
i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64);
dlog_print(DLOG_INFO, LOG_TAG, "BestPattern(char[]) : %s \n", bestPatternString);
i18n_udatepg_destroy(pattern_generator);

i18n_udate_format_h formatter_Current = NULL;
i18n_uchar formatted[64] = {0,};
char result[64] = {0,};
int formattedLength;
i18n_udate date;
char *timezone_Current;
i18n_uchar utf16_timezone_Current[64] = {0,};

if (SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &timezone_Current))
return false;

i18n_ustring_copy_ua_n(utf16_timezone_Current, timezone_Current, strlen(timezone_Current));
if (I18N_ERROR_NONE != i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale,
utf16_timezone_Current, -1, bestPattern, -1, &formatter_Current))
return false;

if (utf16_timezone_Current)
{
i18n_ucalendar_get_now(&date);
i18n_udate_format_date(formatter_Current, date, formatted, 64, NULL, &formattedLength);
i18n_ustring_copy_au_n(result, formatted, 64);
dlog_print(DLOG_INFO, LOG_TAG, "Current Date : %s\n",result);
}
i18n_udate_destroy(formatter_Current);
return true;
}

<결과>

Current Locale Country : en_US
BestPattern(char[]) : EEE, MMM d, yyyy, h:mm:ss a zzz
Current Date : Thu, May 12, 2016, 11:22:56 AM GMT+9

Current Locale Country : de_DE
BestPattern(char[]) : EEE, d. MMM yyyy HH:mm:ss zzz
Current Date : Do., 12. Mai 2016 11:23:33 GMT+9

Current Locale Country : ko_KR
BestPattern(char[]) : yyyy년 MMM d일 (EEE) a h시 m분 s초 zzz
Current Date : 2016년 5월 12일 (목) 오전 11시 24분 13초 GMT+9

Current Locale Country : zh_CN
BestPattern(char[]) : yyyy年M月d日EEE zzzah:mm:ss
Current Date : 2016年5月12日星期四 GMT+9AM11:24:48

Current Locale Country : ja_JP
BestPattern(char[]) : yyyy年M月d日(EEE) H:mm:ss zzz
Current Date : 2016年5月12日(木) 11:25:13 GMT+9

Current Locale Country : hi_IN
BestPattern(char[]) : EEE, d MMM yyyy h:mm:ss a zzz
Current Date : गुरु, 12 मई 2016 11:26:29 AM GMT+9

2016년 5월 6일 금요일

Tizen Native app 개발 시 crash information에서 crash point file, line number 확인 방법

Tizen Native App의 crash 발생 시
crash information을 통해 crash가 발생된 file과 위치(line number)를 확인하는 방법을 정리함.

Native app 개발 하다 보면 Crash를 자주 보게 되는데
그냥 log만 사용해서 확인하자니 빌드 및 실행, 로그 추가로 좀 비효율적임.

다른 디버깅 방법으로 crash 발생 시 생성되는 crash information 중  callstack과
linux에서 개발을 하여 shell을 사용할 수 있다면
간단하게 crash가 발생한 위치를 addr2line을 사용하여 파악할 수 있다.



[Crash information 획득]


Tizen SDK를 사용하고 단말(Gear S2)가 연결이 되어 있는 상태라면
Crash 발생 시 자동으로 SDK에서 call stack view(Window > Show View > Call Stack)를 통해서 보여주게 된다.

Call Stack View를 통해 Crash information, Call stack, Crash 발생 당시 Log를 확인 가능하며
아래 사진은 Sample app을 사용하여 crash를 발생 시킨 것이라 다소 call stack depth가 얕다.

그리고 call stack 내에 app의 binary(ex basicuiw)의 실행 내역이 포함되어 있어야 해당 실행 주소를 사용하여 위치를 확인할 수 있다.




Callstack Information (PID:32525)
Call Stack Count: 1
 0: create_base_gui + 0x1c9 (0x4155e13a) [/opt/usr/apps/org.example.basicuiw/bin/basicuiw] + 0x113a
End of Call Stack


Call Stack에서 basicuiw 앱의 create_base_gui 함수에서 발생되었고 주소는 0x113a임을 알 수 있다.
이를 addr2line을 사용하여 확인하려면 다음과 같이 실행한다.
* 다만 여기서 사용하는 앱 바이너리(basicuiw) crash가 발생된 bianry와 같아야 한다.
   만약 crash 발생 이후 다시 컴파일을 했다면 위치를 확인하기가 어렵다.

hhh@:~/workspace_tizen/BasicUIw/Debug$ pwd
/home/hhh/workspace_tizen/BasicUIw/Debug
hhh@:~/workspace_tizen/BasicUIw/Debug$ addr2line -C -f -e basicuiw 0x113a
create_base_gui
/home/hhh/workspace_tizen/BasicUIw/Debug/../src/basicuiw.c:71

Crash는 basicuiw.c의 71번 line에서 발생한 것을 확인하였고
해당 위치를 확인하면 다음과 같이 crash가 발생하도록 작성한 코드가 맞음을 알 수 있음.




참고로 crash information들은 다음의 위치들에 저장이 된다.
SDK가 설치된 host pc의 app project 내 crash-info 폴더(연결 중 crash가 발생했다면)나
단말내 /opt/usr/share/crash/report 에서 확인할 수 있다.



2016년 4월 25일 월요일

Visual Studio emulator for Android 사용 시 adb reverse 안되는 현상

Windows에서 Visual Studio emulator for Android를 사용하던 중
adb reverse 가 안되는 현상이 있어서 찾아보니
원인은 emulator의 Android 버전이었음.

adb reverse가 Android 5.0(API21) 이상에서 부터 사용되는 기능이므로
emulator Android 버전이 그 미만이면 사용 불가능함.

[증상]
D:\>adb reverse tcp:8081 tcp:8081
error: closed

[참고]
http://facebook.github.io/react-native/docs/running-on-device-android.html#using-adb-reverse

* Emulator에서 Reload JS를 하기 위해서 Developer menu를 여는 방법은 다음과 같다.
 : adb shell input keyevent 82

2016년 4월 20일 수요일

Xamarin.Forms Guide, Webinar 대충 정리

죄송하게도 본 게시물은
아래 Xamarin 가이드를 보고 개인적으로 필요한 부분만을 정리한 것이므로
해당 링크를 직접 보시는 것이 좋습니다.
https://docs.xamarin.com/guides/xamarin-forms/


[Xamarin.Forms]

 : Cross-platform UI tookit으로 Android, iOS, Windows Phone에서 사용 할 수 있는 Native UI를 쉽게 만들 수 있게 해준다.
 : Xamarin.Forms을 사용하여 작성된 app은 결과적으로 Native application이므로 hybrid app과 같이 browser sand-boxing, limited APIs, performance 이슈가 없고 Platform에서 제공하는 feature들(CoreMotion/PassKit/StoreKit on iOS, NFC/Google Play Service on Android, Tiles on Windows)을 사용할 수 있음.
 : UI를 구현함에 있어 C#으로 모든 부분을 구현할 수 있고 XAML(Extensible Application Markup Language)을 사용하여 UI를 구성할 수도 있다.

[Xamarin.Forms Guide]

 : https://docs.xamarin.com/guides/xamarin-forms/

PDF Book Download
 : https://docs.xamarin.com/guides/xamarin-forms/creating-mobile-apps-xamarin-forms/

Xamarin에서 UI를 제공하는 방법에는 Xamarin.Forms을 사용하여 UI 관련 코드를 재사용하거나 Xamarin.iOS, Xamarin.Andoid를 사용하여 직접 Platform-specific API를 사용하는 두가지 방법이 있음.

Xamarin.Forms 사용이 적절한 App 종류는
 - Data entry apps
 - Prototypes and proofs-of-concept
 - Apps that require little platform-specific functionality
 - Apps where code sharing is more important than custom UI


Xamarin.iOS, Xamarin.Android 사용이 적절한 App 종류는
 - Apps that require specialized interactions
 - Apps with highly polished design
 - Apps that use many platform-specific APIs
 - Apps where custom UI is more important than code sharing


즉 GUI적으로 platform specific한 부분이 사용되거나
GUI적으로 좀 더 뭔가 advance한 처리가 필요한 경우에는 Xamarin.Forms가 부적절하겠음.


[Requirements]
: https://developer.xamarin.com/guides/xamarin-forms/getting-started/installation/

amarin.Forms applications can be written for the following operating systems:
  • Android 4.0.3 (API 15) or higher #
  • iOS 6.1 or higher
  • Windows Phone 8.1 (WinRT, using Visual Studio) #
  • Windows 8.1 Tablet/Desktop Apps (WinRT, using Visual Studio) #
  • Windows 10 Universal Apps (Phone/Tablet/Desktop, using Visual Studio)#
  • Windows Phone 8 Silverlight (using Visual Studio) DEPRECATED #

: iOS, OS X용을 개발하려면 Xcode 7이 필요하구나...

Any Xamarin Studio version from 5.0 can be used to develop Xamarin.Forms applications on OS X Yosemite (10.10) or newer. To develop iOS applications, Xcode 7 is also required.


[An Introduction to Xamarin.Forms]

: https://developer.xamarin.com/guides/xamarin-forms/getting-started/introduction-to-xamarin-forms/

UI를 구성하는데 있어 두가지의 방법이 있음.
 - C# 코드로 모두 구현하는 방법
 - XAML(Extensible Application Markup Language)을 사용하여 구성하는 방법

"Hello, Forms !"
public class App : Application
{
  public App ()
  {
    MainPage = new ContentPage {
      Content =  new Label
      {
        Text = "Hello, Forms !",
        VerticalOptions = LayoutOptions.CenterAndExpand,
        HorizontalOptions = LayoutOptions.CenterAndExpand,
      }
    };
  }
}

[View and Layouts]

1. Pages
 : cross-platform mobile application screens
 : Xamarin.Forms Pages


2. Layouts
 : View를 담은 container의 역할
 :  Xamarin.Forms Layouts



3. Views
 : UI controls (ex labels, buttons, text entry boxes, etc.)
 : ActivityIndicator, BoxView, Button, DatePicker, Editor, Entry, Image, Label, ListView, OpenGLView, Picker, ProgressBar, SearchBar, Slider, Stepper, Switch, TableView, TimePicker, WebView
 :  Xamarin.Forms Views

4. Cells
 : list의 item 표시에 특화되어 각 item을 표시할 때 사용 됨.
 : EntryCell, SwitchCell, Text Cell, ImageCell
 : Xamarin.Forms Cells


[Model-View-ViewModel (MVVM)]

 : http://hackersstudy.tistory.com/71
 : http://secretroute.tistory.com/entry/%EB%94%94%EC%9E%90%EC%9D%B8%ED%8C%A8%ED%84%B4MVC-MVP-and-MVVM
 : 기존 MVC의 문제와 MVP의 문제를 해결하고자 나온 Architectural model 이며 View Model와 View간의 dependency를 줄이고자 나온 것이며 Command와 Data binding을 사용하여 해결한다고 함.

[Data Binding]

Data binding은 source와 target를 연결한다. source는 data를 제공하고 target은 source에서 제공한 data를 사용한다.


binding의 이점은 data와 view간의 동기화를 걱정할 필요가 없다는 점이고 data 변경 시 source object는 자동으로 binding framework에 등록된 target object로 변경사항을 보내게 된다.

View의 control(target)과 ViewModel의 model(source)을 binding을 위해 다음 두 절차가 필요하다. (하단 샘플 참고)
- View의 BindingContext property로 source(ViewModel의 model)이 지정 되어야 한다.
- View의 control과 ViewModel의 model간의 binding은 XAML의 Binding markup extension이나 C#의 SetBinding() 방법을 사용해야 한다.

[Xamarin.Forms Webinar]

 : Xamarin.Forms 관련 개념 설명, 기본 Layout, View 예제 code, MVVM 관련 예제 code와 설명이 괜찮다.
 : https://fast.wistia.net/embed/iframe/w2p6ayviev?popover=true
 : http://www.slideshare.net/Xamarin/introduction-to-xamarinforms


[Page, Layout, Controls Demo 예제인 ListPage 코드]
 : Demo에서는 TabbedPage(TimeListPage)를 사용하여 두개의 ContentPage를 사용하는 예제임.
 : ContentPage 중 하나인 ListPage에서는 StackLayout를 사용하여 Button Control과 버튼 클릭 시간을 보여주는 ListView를 보여주며 Page, Layout, Control들의 간단한 사용, 추가 방법에 대해서 알려줌.

using Xamarin.Forms;

namespace App1
{
    public class ListPage : ContentPage
    {
        ObservableCollection<string> Items;
        public ListPage()
        {
            Title = "List Page";
            Items = new ObservableCollection<string>();
            var list = new ListView();

            list.ItemsSource = Items;
            list.ItemSelected += (sender, args) =>
            {
                if (list.SelectedItem == null)
                    return;

                this.Navigation.PushAsync(new ContentPage
                {
                    Title = "page 2",
                    Content = new Label
                    {
                        Text = args.SelectedItem as string
                    }
                });
                list.SelectedItem = null;
            };

            var button = new Button
            {
                Text = "Add Time"
            };

            button.Clicked += (sender, args) =>
            {
                Items.Add(DateTime.Now.ToString("F"));
            };

            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing = 10,
                Children = { list, button }
            };

            Content = stack;
        }
    }

    public class TimeListPage : TabbedPage
    {
        public TimeListPage()
        {
            this.Title = "Time List";
            Children.Add(new ListPage());
            Children.Add(new ContentPage
            {
                Title = "Tab2",
                Padding = 10,
                Content = new Label
                {
                    Text = "Hello from Tab 2"
                }
            });
        }
    }
}

[MVVM, Binding 예제인 LoginPage 관련]





: username, display 변경 관련
 . View(LoginPage)의 entry가 UsernameViewModel의 Username과 Binding 되었음.
 . ViewModel(UsernameViewModel)에서 INotifyPropertyChanged의 PropertyChanged()를 호출하여 username과 Display가 변경되었음을 알릴 수 있음.
 . View(LoginPage)의 label이 UsernameViewModel의 Display와 Binding 되어 있기 때문에 label의 text property가 업데이트 되게 됨.


Command, Action
 : Command에는 실행할 Action과 실행 가능여부를 확인하는 Action이 정의 됨.

namespace Xamarin.Forms
{
    //     Defines an System.Windows.Input.ICommand implementation wrapping a generic Action<T>.
    //
    //     The following example creates a new Command and set it to a button.
    public sealed class Command<T> : Command
    {
        public Command(Action<T> execute);
        public Command(Action<T> execute, Func<T, bool> canExecute);
    }
}

namespace System
{
    public delegate void Action<in T>(T obj);
}

 : button 클릭 시
  . loginCommand은 실행할 ExeuteLoginCommand Action과 실행 여부를 확인하는 CanLogin Action을 가지는 Command로 초기화 됨.
  . View(LoginPage)의 button은 UsernameViewModel의 LoginCommand와 binding되어 있어 button 클릭 시 LoginCommand에 Username 값을 parameter로 넘겨 실행한다.
 . ViewModel(UsernameViewModel)의 CanLogin에서 username을 확인한 뒤 ExecuteLoginCommand가 호출되어 TimeListPage로 이동하게 된다.


using Xamarin.Forms;

namespace App1
{
    public class UsernameViewModel : INotifyPropertyChanged
    {
        private INavigation navigation;
        public UsernameViewModel(INavigation navigation)
        {
            this.navigation = navigation;
        }
        private string username = string.Empty;
        public string Username
        {
            get { return username; }
            set
            {
                if (username == value)
                    return;

                username = value;
                OnPropertyChanged("Username");
                OnPropertyChanged("Display");
            }
        }

        private Command<string> loginCommand;
        public Command LoginCommand
        {
            get { return loginCommand ?? (loginCommand = new Command<string>(ExecuteLoginCommand, CanLogin)); }
        }

        private bool CanLogin(string name)
        {
            return !string.IsNullOrWhiteSpace(name);
        }

        private void ExecuteLoginCommand(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
                return;
            navigation.PushAsync(new TimeListPage());
        }

        public string Display
        {
            get { return "Hello there: " + username; }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string name)
        {
            if (PropertyChanged == null)
                return;

            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }

    public class LoginPage : ContentPage
    {

        public LoginPage()
        {
            this.BindingContext = new UsernameViewModel(Navigation);

            var entry = new Entry
            {
                Placeholder = "Enter Username"
            };

            entry.SetBinding<UsernameViewModel>(Entry.TextProperty,
                vm => vm.Username, BindingMode.TwoWay);

            var label = new Label
            {

            };

            label.SetBinding<UsernameViewModel>(Label.TextProperty,
                vm => vm.Display);

            var button = new Button
            {
                Text = "Login"
            };

            button.SetBinding<UsernameViewModel>(Button.CommandProperty,
               vm => vm.LoginCommand);
            button.SetBinding<UsernameViewModel>(Button.CommandParameterProperty,
               vm => vm.Username);

            Content = new StackLayout
            {
                Padding = 10,
                Spacing = 10,
                Children = { entry, label, button }
            };

        }
    }
}

XAML도 봐야 하는데...

2016년 4월 18일 월요일

Build a Cross Platform Application with Xamarin

죄송하게도 본 게시물은
아래 Xamarin 가이드를 보고 개인적으로 필요한 부분만을 정리한 것이므로
해당 링크를 직접 보시는 것이 좋습니다.

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/


[Shared Projects vs Portable Class Libraries]

 : https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/

갑자기 좀 처음에 이게 나와서 좀 생뚱맞긴 하지만 Xamarin 개발 시 아래 두 방법 중 하나를 선택하는 것이 필수 이므로 설명하고 들어가는게 아닌가 함.

[Shared Projects]
 : Source code 수준(#if compiler를 사용)에서 platform-specific requirement를 처리하는 shared project를 만들어 Cross platform app 개발 방법
 : 장점은 잘 모르겠고 #if의 폐혜가 그대로 나오지 않을까 생각함.
 : 좀 더 찾아보니 Portable class libraries 방법에 비해 .NET framework feature를 모두 사용할 수 있다고 함.







[Portable Class Libraries]
 : Platform specific 기능을 사용할 수 있도록 Interface를 제공하는 PCL(Portable Class Library)를 만들어 사용하는 Cross platform app 개발 방법

 : 공통의 기능을 별도의 DLL로 분리해서 업데이트 함에 있어 코드의 분리, 유지보수의 편의성, 일관적인 공통 기능 제공 등에서의 장점을 가지겠지만 공통의 기능이 최소화 되어 도출 될 수 밖에 없고 platform specific한 부분이 각 app에서 따로 구현이 되어야 하는 점이 있음.



좀 더 찾아보니 장단점이 다양해서 각자 판단하시길.
사실 어찌 보면 다양함을 지원함과 공통의 부분을 최대화 하는 것은 상반되는지라 적당한 수준을 찾는게 맞을듯?

http://www.slideshare.net/gilbok/xamarinforms-mvp-comcamp-2015?qid=490ed12a-a153-4a9c-aa83-8d35eb19e105&v=&b=&from_search=1
 : PCL과 Shared Project의 장단점을 잘 소개 하고 있는 PT. 내용 괜찮음.

http://stackoverflow.com/questions/30634753/what-is-the-difference-between-a-shared-project-and-a-class-library-in-visual-st
http://hotkrossbits.com/2015/05/03/xamarin-forms-pcl-vs-shared-project/

[Overview]

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_0_-_overview/

 : 일반 적인 Cross Platform은 "write-once, run everywhere" 즉, Common set을 정의하여 여러 플랫폼을 대응하는 방법을 취해 비용 최소화의 장점을 가지나 common set이 각 platform의 최소 기능으로 이뤄지는 점 GUI가 general 하게 구성된다는 단점이 있음.
그에 반해 Xamarin에서는 Naitve UI을 구현/제공할 수 있는 방법 제공과 UI를 제외한 data storage, business logic 등을 재사용할 수 있음 점을 장점으로 내세우고 있는 듯하다.



Xamarin Cross-Platform App을 만들 때 필요한 주요 Feature들은 다음과 같음.

 - C# 사용
  : C#으로 코드를 작성하고 iOS, Android, Windows Phone 대상 app으로 변환 가능
 - MVC design pattern
  : Core, User-Interface을 분리하여 app 개발을 할수 있다. MVC(Model-View-Controller), MVVM(Model-View-ViewModel) design approach를 사용할 수 있음.
 - Native UIs
  : 각 OS에 특화된 application을 작성하기 위해 다른 UI layer를 사용 가능?
  : iOS (MonoTouch), Android (Android.Views), Windows Phone (XAML/Silverlight), Windows 8 (Metro APIs)

Code Reuse를  확대를 위해 다음의 sub-system들을 사용할 수 있다고 함.

  1. SQLite-NET for local SQL storage,
  2. Xamarin Plugins for accessing device-specific capabilities including the camera, contacts and geolocation,
  3. Using framework features for networking, web services, IO and more.



[Part 1 – Understanding the Xamarin Mobile Platform]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_1_-_understanding_the_xamarin_mobile_platform/

Mobile에서 app개발을 할 수 있도록 하는 Xamarin platform은 다음으로 구성됨.
 - C# language
 - Mono .NET framework :
 - Compiler : Target OS, Platform 대상으로 필요한 것들을 빌드하고 최적화도 수행
 - IDE tools : Xamarin Studio IDE, plugin for VS

Complication
 - iOS
  : AOT(Ahead-Of-Time) 컴파일을 통해 C# 코드에서 ARM assembly 결과물로 생성함
  : iOS는 runtime code generation을 허용하지 않아 제약 존재 (Xamarin.iOS Limitations)
 - Android
  : 컴파일을 통해 C# 코드에서 IL 결과물을 생성하고 MonoMV, JIT 컴파일러?와 함께 packaging됨. App은 JAVA/ART(Android RumTime)와 함께 실행되며 JNI를 통해 native type을 접근할 수 있음.
  : Android에서의 제약들( Xamarin.Android Limitations)
 - Windows Phone
  : C#은 IL로 컴파일 되어 build-in된 runtime에서 실행된다. 뭐 당연하겠지..

[IDE]

Development OS
Mac OS X
Windows
IDE
Xamarin Studio
Xamarin Studio
Visual Studio
iOS
Y
-
Y
Android
Y
Y
Y
Windows Phone
-
-
Y
Visual Studio 2015 Update 2 부터는 Xamarin 포함

 - iOS 개발 시 Mac OS X 필요

[UI]
 - 코드로 UI를 작성할 수 도 있고 Visual Designer를 사용해서 편하게 만들 수도 있음.
 - 하지만 각 OS의 metaphor(일반적인 Look and feel?)를 참고할 필요 있음.
  : iOS
   . hierarchical navigation with soft back button, tabs on the bottom of the screen.
   . Apple's Human Interface Guidelines
  : Android
   . hardware/system-software back button, action menu, tabs on the top of the screen.
   . Google's User Interface Guidelines
  : Windows Phone
   . hardware back button, panorama layout control, live tiles.
   . User Experience Design Guidelines for Windows Phone

[Library and Code Re-Use]
 - C# library야 당연히 사용할 수 있겠고
 - Objective-C Bindings + Binding Projects : btouch 제공
  : Binding Objective-C Types documentation
 - .jar Bindings + Binding Projects
  : Binding a Java Library documentation 
 - C via PInvoke
  : P/Invoke(Platform Invoke)를 사용하여 C#에서 native library들 사용이나 native library에서 callback 호출을 하게할 수 있음.
  :  linking native libraries

예시 - SQLite-NET
[DllImport("sqlite3", EntryPoint = "sqlite3_open", CallingConvention=CallingConvention.Cdecl)]
public static extern Result Open (string filename, out IntPtr db);
 - C++ via CppSharp
  : https://github.com/mono/CppSharp

[Part 2 - Architecture]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_2_-_architecture/

[OOP 개념]
 : 참고
  . 나무위키 객체 지향 프로그래밍
  . 객체지향 개념 (쫌 아는체 하기) http://www.slideshare.net/plusjune/ss-46109239
 - Encapsulation
 - Separation of Responsibilities
 - Polymorphism

[Application Layers]
 : 누가 정의했는지는 모르겠지만 용어는 알아두자.
 - Data Layer
  : SQLite 같은 DBMS가 여기에 해당 될듯
 - Data Access Layer
  : Data Layer를 사용(CRUD)하기 위한 wrapper/DAO 같은 부분?
 - Business Layer/Business Logic Layer
 - Service Access Layer
  : Cloud나 다른 web service들을 Application이나 UI layer에서 사용하기 위한 API들을 제공한다.
 - Application Layer
  : platform/application specific한 code를 포함하는 layer.
  : User Interface Layer와의 차이는 UI component를 포함하는지 여부와 다른 screen이나 device에 대해서 공유되는지 여부라고 함.
 - User Interface Layer
  : 사용자가 직접 대면하는 화면들(screens, widgets 등)을 관리하고 제공함.

[Common Mobile Software Patterns]
 - MVC(Model, View, Controller) pattern
 - Business Facade (Manager Pattern) pattern
  : 복잡한 처리를 간단하게 수행할 수 있도록 단순화된 entry point(ex API, etc?)를 제공함.
  : https://ko.wikipedia.org/wiki/%ED%8D%BC%EC%82%AC%EB%93%9C_%ED%8C%A8%ED%84%B4
 - Singleton pattern
 - Provider (Strategy) pattern?
  : http://hyeonstorage.tistory.com/146
 - Async pattern?
  : Async keyword는 아니며 보통 network 처리 같이 시간이 필요한 동작 수행 시 UI나 application이 pending되거나 영향을 받지 않도록 처리할 때 사용하며 주로 thread를 사용한다. 이 때 thread life cycle 관리, 수행 후 notification등을 고려해야 함.

[Part 3 - Setting Up A Xamarin Cross Platform Solution]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_3_-_setting_up_a_xamarin_cross_platform_solution/

처음에 설명된 PCL 방법을 쓰던지 Shared Project 방법을 쓰던지 간에 Xamarin에서는 Core project와 Platform-specific application project로 나뉜다.



Core Project
 : 플랫폼에 상관없이 재사용 가능한 코드들로 구성
 : Data Layer, Data Access Layer, Service Access Layer, business Layer 들이 존재

Platform-Specific Application Projects
 : platform-specific한 feature들을 사용하고 platform SDK과 binding된 코드들이 포함됨
 : Application Layer, User Interface Layer 들이 존재


[Part 4 - Dealing with Multiple Platforms]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_4_-_platform_divergence_abstraction_divergent_implementation/

Universal UI attributes
 - Feature selection via tabs or menus
 - Lists of data and scrolling
 - Single views of data
 - Editing single views of data
 - Navigating back

Platform-specific attributes
 - Screen sizes
 - Navigation metaphors
 - Keyboards
 - Touch and gestures
 - Push notifications

Device-specific features
 - Camera
 - Geo-location & maps
 - Accelerometer, gyroscope and compass
 - Twitter and Facebook
 - Near Field Communications (NFC)

[Platform Divergence를 처리하는 방법]
 - Platform Abstraction
  : Facade pattern을 사용해서 unified API를 제공하여 platform 특화된 구현부를 추상화하는 방법
  : Interface나 상속을 통해서 class를 추상화하는 방법
  : Xamarin.Forms
  : Cross-Platform Plug-ins

 - Divergent Implementation
  : Conditional compilation을 이용하여 platform에 특화된 부분을 처리하는 방법

[Platform Abstraction]
- Class Abstraction
 : Interface를 사용하거나 Inheritance을 통해 처리하거나

- Xamarin.Forms
 : A cross-platform UI toolkit that allows developers to easily create native user interface layouts that can be shared across Android, iOS, and Windows Phone.

- Plug-in Cross-Platform Functionality
 : https://github.com/xamarin/plugins

- Other Cross-Platform Libraries
 - MvvmCross - https://github.com/slodge/MvvmCross/
 - Vernacular (for localization) - https://github.com/rdio/vernacular/
 - MonoGame (for XNA games) - http://monogame.codeplex.com/
 - NGraphics - NGraphics and its precursor https://github.com/praeclarum/CrossGraphics

[Divergenct Implementation]
- Conditional compilation
#if __MOBILE__
// Xamarin iOS or Android-specific code
#endif

iOS

Xamarin.iOS defines __IOS__ which you can use to detect iOS devices.
#if __IOS__
// iOS-specific code
#endif
There are also Watch- and TV-specific symbols:
#if __TVOS__
// tv-specific stuff
#endif

#if __WATCHOS__
// watch-specific stuff
#endif

Android

Code that should only be compiled into Xamarin.Android applications can use the following
#if __ANDROID__
// Android-specific code
#endif
Each API version also defines a new compiler directive, so code like this will let you add features if newer APIs are targeted. Each API level includes all the ‘lower’ level symbols. This feature is not really useful for supporting multiple platforms; typically the __ANDROID__ symbol will be sufficient.
#if __ANDROID_11__
// code that should only run on Android 3.0 Honeycomb or newer
#endif

[Part 5 - Practical Code Sharing Strategies]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_5_-_practical_code_sharing_strategies/

필요할 때 참고하면 될 듯
DBMS, File System, Network, Web Services 관련 Solution들


[Part 6 - Testing and App Store Approvals]

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_6_-_testing_and_app_store_approvals/


[Case Study: Tasky]

https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/case_study-tasky/