SlideShare ist ein Scribd-Unternehmen logo
1 von 29
CocoaPods




            Trinh Minh Cuong




                   http://techmaster.vn
CocoaPods là gì ? Tại sao?
• Công cụ quản lý các mã nguồn mở viết bằng
  Objective-C cho iOS và MacOSX
• Tại sao dùng CocoaPods?
  – Đơn giản hơn
  – Dễ quản lý hơn
  – Ít bước hơn
                                      http://techmaster.vn
Trước khi có cocoapods
• Dev phải tự quản lý các thư viện 3rd parties
• Vào Build Settings cấu hình Search Paths
• Vào Build Phrase để thêm static libraries…




                                          http://techmaster.vn
CocoaPods đơn giản hoá việc sử dụng 3rd parties libraries

• CocoaPods spec mô tả cách dự án liên kết sử dụng
  thư viện
• Hiện có hơn 977 pod spec được làm sẵn.
• Lập trình viên có thể bổ xung thêm để chia sẻ cho
  cộng đồng
• Tuy nhiên để dùng CocoaPods chúng lại phải cài
  RubyGem trước đã.
                                                     http://techmaster.vn
gem là gì?
• Là trình quản lý các gói ứng dụng hữu ích
  được viết bằng Ruby. gem sẽ tải thư viện về
  từ Internet và cài đặt.
• http://en.wikipedia.org/wiki/RubyGems

• http://docs.rubygems.org/

                                          http://techmaster.vn
Mô tả                                       Lệnh gem

Cài đặt một thư viện mygem                  gem install mygem

Gỡ bỏ một thư viện mygem                    gem uninstall mygem

Liệt kê danh sách các gem cài trên local    gem list --local

Liệt kê danh sách các gem có trên server    gem list --remote

Tạo                                         gem rdoc --all

Tải nhưng không cài đặt                     gem fetch mygem

Tìm một gem có trên là STRING trên server   gem search STRING –remote

Đóng gói một mygem                          gem build mygem.gemspec
                                                                        http://techmaster.vn
brew là gì?
• Homebrew được viết bằng Ruby, cài vào ứng
  dụng vào thư mục /usr/local
• Người dùng không cần phải gõ lệnh sudo
  mà chỉ cần gõ
$brew install appledoc
• http://mxcl.github.com/homebrew/
                                     http://techmaster.vn
Các lệnh brew : Gõ man brew ở terminal

brew list            Liệt kê danh sách các brew đã cài đặt

brew home mongodb    Mở trang chủ một brew có tên là mongodb

brew info mongodb    Xem thông tin về một brew có tên là mongodb

brew search          Liệt kê tất cả brew đang có

brew search STRING   Tìm brew có tên STRING




                                                                   http://techmaster.vn
Ví dụ dự án sử dụng QuickDialog




                             http://techmaster.vn
Để sử dụng QuickDialog trong dự án
• http://escoz.com/open-source/quickdialog
• Phải làm khoảng 15 bước !. Khi chuyển sang
  thư mục khác biên dịch lại bị lỗi. Đến là khổ !




                                           http://techmaster.vn
Trước khi cài CocoaPods
• Cần cài command line tool trong Xcode
Xcode > Settings > Downloads > Components > Command Line Tools


• Nâng cấp Ruby Gem, bằng gõ vào trong Terminal
gem update --system




                                                                 http://techmaster.vn
Cài đặt CocoaPods
$ [sudo] gem install cocoapods
$ pod setup

Nếu có báo lỗi RubyGem quá cũ
Your RubyGems version (1.3.6) is too old, please update with: `gem update --system`
Thì gõ lệnh gem update --system




                                                                                      http://techmaster.vn
Các bước để nhúng QuickDialog
cd project_folder
                     Mở ra trình soạn thảo text mặc định trong Mac
$ edit Podfile
platform :ios           Nhớ có space ở đây


pod 'QuickDialog',         '~> 0.6’
$sudo pod install

                                                            http://techmaster.vn
https://github.com/CocoaPods/Specs/blob/master/QuickDialog/0.1/QuickDialog.po
                                    dspec




                                                                   http://techmaster.vn
Màn hình Terminal khi cài đặt Pod




                               http://techmaster.vn
Khi cài xong pod ở
    Terminal thì
mở WorkSpace chứ
không mở Project




              http://techmaster.vn
Nơi tập trung các thư viện Pod




     Đây là dự án chính


                                 http://techmaster.vn
Gõ pod help để biết thêm các lệnh Pod
Lệnh          Mô tả
pod install   Tải về các thư viện đã được liệt kê trong Podfile, tạo WorkSpace bao lấy
              dự án Pod và dự án hiện thời
pod list      Liệt kê các đóng gói dạng Pod
pod push      Đẩy một định nghĩa mới PodSpec vào local repository sau đó là remote
pod repo      Tập các lệnh xử lý repository
pod search    Tìm kiếm một thư viện Pod
pod setup
pod spec      Tạo định nghĩa đóng gói dạng Pod
pod update    Cập nhật lại các gói Pod nếu trên server có bản mới hơn !!!
                                                                        http://techmaster.vn
Tìm các CocodPods ở đây
https://github.com/CocoaPods/Specs
Vào đây để tham khảo xem có thư viện nào
cool, hay được cộng đồng dùng




                                      http://techmaster.vn
Hứng sự kiện cho nút TestQuickDialog
Sau đó paste đoạn code trang sau vào




                           http://techmaster.vn
- (IBAction)demoQuickDialog:(id)sender {
    QRootElement *root = [[QRootElement alloc] init];
    root.title = @"Hello CocoaPods";
    root.grouped = YES;
    QSection *section = [[QSection alloc] init];
    QLabelElement *label = [[QLabelElement alloc] initWithTitle:@"Hello"
Value:@"world!"];

  [root addSection:section];
  [section addElement:label];

  UINavigationController *navigation = [QuickDialogController
controllerWithNavigationForRoot:root];
  [self presentViewController:navigation animated:YES completion:nil];
}

                                                                           http://techmaster.vn
Chọn version nào cho một CocoaPods
• Xem chi tiết ở đây
https://github.com/CocoaPods/CocoaPods/wiki
/Dependency-version-workflow
• Thông thường cứ để trống có nghĩa lấy thư
  viện mới nhất !
pod ’APodLib’
                                       http://techmaster.vn
Hướng dẫn hay
• http://labs.grupow.com/blog/2012/07/12/co
  coapods-the-objective-c-library-manager-
  part-1-slash-2




                                      http://techmaster.vn
Thực hành một dự án khủng !!!
Đầu tiên dùng AFNetworking sau
     đó chuyển qua RestKit

                           http://techmaster.vn
Ứng dụng địa điểm sử dụng Foursquare
• Lấy địa điểm người dùng đang đứng, hoặc địa
  điểm nhập vào
• Tìm ra các loại địa điểm gần đó: ATM, bar,
  restaurant…
• Tham khảo https://developer.foursquare.com/
• Sử dụng AFNetworking cho dễ trước, sau đó
  dùng RestKit
                                               http://techmaster.vn
Đã có một hướng dẫn lập trình RESTKit kết nối Foursquare API trên
trang Raywenderlich.

http://www.raywenderlich.com/13097/intro-to-restkit-tutorial
Nhưng từ đó đến nay API của RESTKit đã thay đổi rất nhiều. Tutor cho
bản mới thì chưa có?

Làm thế nào bây giờ?


                                                           http://techmaster.vn
RestKit Pod
platform:ios
pod 'RestKit' , '0.20.0pre6’
Lỗi [!] RestKit (0.20.0pre6) is not compatible with iOS
4.3.




                                                 http://techmaster.vn
Correct Pod file
platform:ios, '5.0’ //iOS 5.0 trở lên
pod 'RestKit’ //lấy bản mới nhất




                                        http://techmaster.vn
Học cách dùng RESTKit
http://www.slideshare.net/peterfriese/restkit-
from-zero-to-hero (đã cũ)
http://restkit.tumblr.com/ (blog)
https://github.com/RestKit/RestKit/wiki/Object-
Mapping (tài liệu ánh xạ từ REST vào đối
tượng)

                                          http://techmaster.vn

Weitere ähnliche Inhalte

Was ist angesagt?

イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化Gosuke Miyashita
 
Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Justin Lin
 
Dokkuの活用と内部構造
Dokkuの活用と内部構造Dokkuの活用と内部構造
Dokkuの活用と内部構造修平 富田
 
PHP-FPM の子プロセス制御方法と設定をおさらいしよう
PHP-FPM の子プロセス制御方法と設定をおさらいしようPHP-FPM の子プロセス制御方法と設定をおさらいしよう
PHP-FPM の子プロセス制御方法と設定をおさらいしようShohei Okada
 
Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Steven Smith
 
Spring3.1概要 データアクセスとトランザクション処理
Spring3.1概要 データアクセスとトランザクション処理Spring3.1概要 データアクセスとトランザクション処理
Spring3.1概要 データアクセスとトランザクション処理土岐 孝平
 
Building out a Microservices Architecture with WebSphere Liberty Profile and ...
Building out a Microservices Architecture with WebSphere Liberty Profile and ...Building out a Microservices Architecture with WebSphere Liberty Profile and ...
Building out a Microservices Architecture with WebSphere Liberty Profile and ...David Currie
 
Djangoフレームワークの紹介
Djangoフレームワークの紹介Djangoフレームワークの紹介
Djangoフレームワークの紹介Shinya Okano
 
Web開発者にお勧め .NET MAUI Blazor App
Web開発者にお勧め .NET MAUI Blazor AppWeb開発者にお勧め .NET MAUI Blazor App
Web開発者にお勧め .NET MAUI Blazor AppTomomitsuKusaba
 
Spiderストレージエンジンのご紹介
Spiderストレージエンジンのご紹介Spiderストレージエンジンのご紹介
Spiderストレージエンジンのご紹介Kentoku
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js선협 이
 
Spring native について
Spring native についてSpring native について
Spring native についてTakamasa Mitsuji
 
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること 【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること 日本マイクロソフト株式会社
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React NativeEric Deng
 
マジックビーンズ
マジックビーンズマジックビーンズ
マジックビーンズAkira Suenami
 
はじめてのASP.NET MVC5
はじめてのASP.NET MVC5はじめてのASP.NET MVC5
はじめてのASP.NET MVC5Tomo Mizoe
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話dcubeio
 

Was ist angesagt? (20)

イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化
 
Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器
 
Dokkuの活用と内部構造
Dokkuの活用と内部構造Dokkuの活用と内部構造
Dokkuの活用と内部構造
 
PHP-FPM の子プロセス制御方法と設定をおさらいしよう
PHP-FPM の子プロセス制御方法と設定をおさらいしようPHP-FPM の子プロセス制御方法と設定をおさらいしよう
PHP-FPM の子プロセス制御方法と設定をおさらいしよう
 
Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0Introducing ASP.NET Core 2.0
Introducing ASP.NET Core 2.0
 
Node ppt
Node pptNode ppt
Node ppt
 
Spring3.1概要 データアクセスとトランザクション処理
Spring3.1概要 データアクセスとトランザクション処理Spring3.1概要 データアクセスとトランザクション処理
Spring3.1概要 データアクセスとトランザクション処理
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Building out a Microservices Architecture with WebSphere Liberty Profile and ...
Building out a Microservices Architecture with WebSphere Liberty Profile and ...Building out a Microservices Architecture with WebSphere Liberty Profile and ...
Building out a Microservices Architecture with WebSphere Liberty Profile and ...
 
Djangoフレームワークの紹介
Djangoフレームワークの紹介Djangoフレームワークの紹介
Djangoフレームワークの紹介
 
Web開発者にお勧め .NET MAUI Blazor App
Web開発者にお勧め .NET MAUI Blazor AppWeb開発者にお勧め .NET MAUI Blazor App
Web開発者にお勧め .NET MAUI Blazor App
 
Spiderストレージエンジンのご紹介
Spiderストレージエンジンのご紹介Spiderストレージエンジンのご紹介
Spiderストレージエンジンのご紹介
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
Spring native について
Spring native についてSpring native について
Spring native について
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること 【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
【BS11】毎年訪れる .NET のメジャーバージョンアップに備えるために取り組めること
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
マジックビーンズ
マジックビーンズマジックビーンズ
マジックビーンズ
 
はじめてのASP.NET MVC5
はじめてのASP.NET MVC5はじめてのASP.NET MVC5
はじめてのASP.NET MVC5
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話
 

Ähnlich wie Hướng dẫn sử dụng CocoaPods trong dự án iOS hoặc MacOSX

Introduce docker
Introduce dockerIntroduce docker
Introduce dockerRobin Huy
 
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...VKhang Yang
 
Docker Overview
Docker OverviewDocker Overview
Docker OverviewThinh Duc
 
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015IT Expert Club
 
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...DevDay.org
 
Giới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGiới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGMO-Z.com Vietnam Lab Center
 
Vietnam mobile day 2012 i os memory management - techmaster
Vietnam mobile day 2012   i os memory management - techmasterVietnam mobile day 2012   i os memory management - techmaster
Vietnam mobile day 2012 i os memory management - techmasterQuang Anh Le
 
Mobiledaymemorymanagement 120519033851-phpapp02
Mobiledaymemorymanagement 120519033851-phpapp02Mobiledaymemorymanagement 120519033851-phpapp02
Mobiledaymemorymanagement 120519033851-phpapp02Năm Tàn
 
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOS
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOSQuản lý bộ nhớ trong khi phát triển ứng dụng Apple iOS
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOSaction.vn
 
Apple iOS Memory Management - Vietnamese version
Apple iOS Memory Management - Vietnamese versionApple iOS Memory Management - Vietnamese version
Apple iOS Memory Management - Vietnamese versionTechMaster Vietnam
 
Day0: Giới thiệu lập trình ứng dụng Apple iOS
Day0: Giới thiệu lập trình ứng dụng Apple iOSDay0: Giới thiệu lập trình ứng dụng Apple iOS
Day0: Giới thiệu lập trình ứng dụng Apple iOSTechMaster Vietnam
 

Ähnlich wie Hướng dẫn sử dụng CocoaPods trong dự án iOS hoặc MacOSX (20)

Node.js căn bản
Node.js căn bảnNode.js căn bản
Node.js căn bản
 
Introduce docker
Introduce dockerIntroduce docker
Introduce docker
 
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
 
Arrowjs.io
Arrowjs.ioArrowjs.io
Arrowjs.io
 
Docker Overview
Docker OverviewDocker Overview
Docker Overview
 
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015
ITLC - Hanoi - NodeJS - ArrowJS - 27-11 - 2015
 
Phalcon căn bản
Phalcon căn bảnPhalcon căn bản
Phalcon căn bản
 
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
 
Giới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGiới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cd
 
Apache+ q logs
Apache+ q logsApache+ q logs
Apache+ q logs
 
Sfdx jenkins
Sfdx jenkinsSfdx jenkins
Sfdx jenkins
 
WinEoP Framework
WinEoP FrameworkWinEoP Framework
WinEoP Framework
 
Present.pptx
Present.pptxPresent.pptx
Present.pptx
 
Vietnam mobile day 2012 i os memory management - techmaster
Vietnam mobile day 2012   i os memory management - techmasterVietnam mobile day 2012   i os memory management - techmaster
Vietnam mobile day 2012 i os memory management - techmaster
 
Mobiledaymemorymanagement 120519033851-phpapp02
Mobiledaymemorymanagement 120519033851-phpapp02Mobiledaymemorymanagement 120519033851-phpapp02
Mobiledaymemorymanagement 120519033851-phpapp02
 
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOS
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOSQuản lý bộ nhớ trong khi phát triển ứng dụng Apple iOS
Quản lý bộ nhớ trong khi phát triển ứng dụng Apple iOS
 
Apple iOS Memory Management - Vietnamese version
Apple iOS Memory Management - Vietnamese versionApple iOS Memory Management - Vietnamese version
Apple iOS Memory Management - Vietnamese version
 
Day0: Giới thiệu lập trình ứng dụng Apple iOS
Day0: Giới thiệu lập trình ứng dụng Apple iOSDay0: Giới thiệu lập trình ứng dụng Apple iOS
Day0: Giới thiệu lập trình ứng dụng Apple iOS
 
Lab lap trinhmang_v3
Lab lap trinhmang_v3Lab lap trinhmang_v3
Lab lap trinhmang_v3
 
Phalcon introduction
Phalcon introductionPhalcon introduction
Phalcon introduction
 

Mehr von TechMaster Vietnam

Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservicesTechMaster Vietnam
 
Authentication and Authorization
Authentication and AuthorizationAuthentication and Authorization
Authentication and AuthorizationTechMaster Vietnam
 
Postgresql các vấn đề thực tế
Postgresql các vấn đề thực tếPostgresql các vấn đề thực tế
Postgresql các vấn đề thực tếTechMaster Vietnam
 
Chia sẻ kinh nghiệm giảng dạy CNTT
Chia sẻ kinh nghiệm giảng dạy CNTTChia sẻ kinh nghiệm giảng dạy CNTT
Chia sẻ kinh nghiệm giảng dạy CNTTTechMaster Vietnam
 
Cơ sở dữ liệu postgres
Cơ sở dữ liệu postgresCơ sở dữ liệu postgres
Cơ sở dữ liệu postgresTechMaster Vietnam
 
Tìm nền tảng lập trình cho 5 năm tới
Tìm nền tảng lập trình cho 5 năm tớiTìm nền tảng lập trình cho 5 năm tới
Tìm nền tảng lập trình cho 5 năm tớiTechMaster Vietnam
 
Cấu hình Postgresql căn bản trong 20 phút
Cấu hình Postgresql căn bản trong 20 phútCấu hình Postgresql căn bản trong 20 phút
Cấu hình Postgresql căn bản trong 20 phútTechMaster Vietnam
 
Manage your project differently
Manage your project differentlyManage your project differently
Manage your project differentlyTechMaster Vietnam
 
Bài trình bày cho sinh viên Bách Khoa 9/2012
Bài trình bày cho sinh viên Bách Khoa 9/2012Bài trình bày cho sinh viên Bách Khoa 9/2012
Bài trình bày cho sinh viên Bách Khoa 9/2012TechMaster Vietnam
 

Mehr von TechMaster Vietnam (20)

Neural Network from Scratch
Neural Network from ScratchNeural Network from Scratch
Neural Network from Scratch
 
Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservices
 
Flutter vs React Native 2018
Flutter vs React Native 2018Flutter vs React Native 2018
Flutter vs React Native 2018
 
C đến C++ phần 1
C đến C++ phần 1C đến C++ phần 1
C đến C++ phần 1
 
Control structure in C
Control structure in CControl structure in C
Control structure in C
 
Basic C programming
Basic C programmingBasic C programming
Basic C programming
 
Authentication and Authorization
Authentication and AuthorizationAuthentication and Authorization
Authentication and Authorization
 
Postgresql security
Postgresql securityPostgresql security
Postgresql security
 
Knex Postgresql Migration
Knex Postgresql MigrationKnex Postgresql Migration
Knex Postgresql Migration
 
Postgresql các vấn đề thực tế
Postgresql các vấn đề thực tếPostgresql các vấn đề thực tế
Postgresql các vấn đề thực tế
 
Minimum Viable Products
Minimum Viable ProductsMinimum Viable Products
Minimum Viable Products
 
Chia sẻ kinh nghiệm giảng dạy CNTT
Chia sẻ kinh nghiệm giảng dạy CNTTChia sẻ kinh nghiệm giảng dạy CNTT
Chia sẻ kinh nghiệm giảng dạy CNTT
 
Cơ sở dữ liệu postgres
Cơ sở dữ liệu postgresCơ sở dữ liệu postgres
Cơ sở dữ liệu postgres
 
Tìm nền tảng lập trình cho 5 năm tới
Tìm nền tảng lập trình cho 5 năm tớiTìm nền tảng lập trình cho 5 năm tới
Tìm nền tảng lập trình cho 5 năm tới
 
iOS Master - Detail & TabBar
iOS Master - Detail & TabBariOS Master - Detail & TabBar
iOS Master - Detail & TabBar
 
Cấu hình Postgresql căn bản trong 20 phút
Cấu hình Postgresql căn bản trong 20 phútCấu hình Postgresql căn bản trong 20 phút
Cấu hình Postgresql căn bản trong 20 phút
 
Slide that wins
Slide that winsSlide that wins
Slide that wins
 
Manage your project differently
Manage your project differentlyManage your project differently
Manage your project differently
 
Bài trình bày cho sinh viên Bách Khoa 9/2012
Bài trình bày cho sinh viên Bách Khoa 9/2012Bài trình bày cho sinh viên Bách Khoa 9/2012
Bài trình bày cho sinh viên Bách Khoa 9/2012
 
Making a living
Making a livingMaking a living
Making a living
 

Hướng dẫn sử dụng CocoaPods trong dự án iOS hoặc MacOSX

  • 1. CocoaPods Trinh Minh Cuong http://techmaster.vn
  • 2. CocoaPods là gì ? Tại sao? • Công cụ quản lý các mã nguồn mở viết bằng Objective-C cho iOS và MacOSX • Tại sao dùng CocoaPods? – Đơn giản hơn – Dễ quản lý hơn – Ít bước hơn http://techmaster.vn
  • 3. Trước khi có cocoapods • Dev phải tự quản lý các thư viện 3rd parties • Vào Build Settings cấu hình Search Paths • Vào Build Phrase để thêm static libraries… http://techmaster.vn
  • 4. CocoaPods đơn giản hoá việc sử dụng 3rd parties libraries • CocoaPods spec mô tả cách dự án liên kết sử dụng thư viện • Hiện có hơn 977 pod spec được làm sẵn. • Lập trình viên có thể bổ xung thêm để chia sẻ cho cộng đồng • Tuy nhiên để dùng CocoaPods chúng lại phải cài RubyGem trước đã. http://techmaster.vn
  • 5. gem là gì? • Là trình quản lý các gói ứng dụng hữu ích được viết bằng Ruby. gem sẽ tải thư viện về từ Internet và cài đặt. • http://en.wikipedia.org/wiki/RubyGems • http://docs.rubygems.org/ http://techmaster.vn
  • 6. Mô tả Lệnh gem Cài đặt một thư viện mygem gem install mygem Gỡ bỏ một thư viện mygem gem uninstall mygem Liệt kê danh sách các gem cài trên local gem list --local Liệt kê danh sách các gem có trên server gem list --remote Tạo gem rdoc --all Tải nhưng không cài đặt gem fetch mygem Tìm một gem có trên là STRING trên server gem search STRING –remote Đóng gói một mygem gem build mygem.gemspec http://techmaster.vn
  • 7. brew là gì? • Homebrew được viết bằng Ruby, cài vào ứng dụng vào thư mục /usr/local • Người dùng không cần phải gõ lệnh sudo mà chỉ cần gõ $brew install appledoc • http://mxcl.github.com/homebrew/ http://techmaster.vn
  • 8. Các lệnh brew : Gõ man brew ở terminal brew list Liệt kê danh sách các brew đã cài đặt brew home mongodb Mở trang chủ một brew có tên là mongodb brew info mongodb Xem thông tin về một brew có tên là mongodb brew search Liệt kê tất cả brew đang có brew search STRING Tìm brew có tên STRING http://techmaster.vn
  • 9. Ví dụ dự án sử dụng QuickDialog http://techmaster.vn
  • 10. Để sử dụng QuickDialog trong dự án • http://escoz.com/open-source/quickdialog • Phải làm khoảng 15 bước !. Khi chuyển sang thư mục khác biên dịch lại bị lỗi. Đến là khổ ! http://techmaster.vn
  • 11. Trước khi cài CocoaPods • Cần cài command line tool trong Xcode Xcode > Settings > Downloads > Components > Command Line Tools • Nâng cấp Ruby Gem, bằng gõ vào trong Terminal gem update --system http://techmaster.vn
  • 12. Cài đặt CocoaPods $ [sudo] gem install cocoapods $ pod setup Nếu có báo lỗi RubyGem quá cũ Your RubyGems version (1.3.6) is too old, please update with: `gem update --system` Thì gõ lệnh gem update --system http://techmaster.vn
  • 13. Các bước để nhúng QuickDialog cd project_folder Mở ra trình soạn thảo text mặc định trong Mac $ edit Podfile platform :ios Nhớ có space ở đây pod 'QuickDialog', '~> 0.6’ $sudo pod install http://techmaster.vn
  • 15. Màn hình Terminal khi cài đặt Pod http://techmaster.vn
  • 16. Khi cài xong pod ở Terminal thì mở WorkSpace chứ không mở Project http://techmaster.vn
  • 17. Nơi tập trung các thư viện Pod Đây là dự án chính http://techmaster.vn
  • 18. Gõ pod help để biết thêm các lệnh Pod Lệnh Mô tả pod install Tải về các thư viện đã được liệt kê trong Podfile, tạo WorkSpace bao lấy dự án Pod và dự án hiện thời pod list Liệt kê các đóng gói dạng Pod pod push Đẩy một định nghĩa mới PodSpec vào local repository sau đó là remote pod repo Tập các lệnh xử lý repository pod search Tìm kiếm một thư viện Pod pod setup pod spec Tạo định nghĩa đóng gói dạng Pod pod update Cập nhật lại các gói Pod nếu trên server có bản mới hơn !!! http://techmaster.vn
  • 19. Tìm các CocodPods ở đây https://github.com/CocoaPods/Specs Vào đây để tham khảo xem có thư viện nào cool, hay được cộng đồng dùng http://techmaster.vn
  • 20. Hứng sự kiện cho nút TestQuickDialog Sau đó paste đoạn code trang sau vào http://techmaster.vn
  • 21. - (IBAction)demoQuickDialog:(id)sender { QRootElement *root = [[QRootElement alloc] init]; root.title = @"Hello CocoaPods"; root.grouped = YES; QSection *section = [[QSection alloc] init]; QLabelElement *label = [[QLabelElement alloc] initWithTitle:@"Hello" Value:@"world!"]; [root addSection:section]; [section addElement:label]; UINavigationController *navigation = [QuickDialogController controllerWithNavigationForRoot:root]; [self presentViewController:navigation animated:YES completion:nil]; } http://techmaster.vn
  • 22. Chọn version nào cho một CocoaPods • Xem chi tiết ở đây https://github.com/CocoaPods/CocoaPods/wiki /Dependency-version-workflow • Thông thường cứ để trống có nghĩa lấy thư viện mới nhất ! pod ’APodLib’ http://techmaster.vn
  • 23. Hướng dẫn hay • http://labs.grupow.com/blog/2012/07/12/co coapods-the-objective-c-library-manager- part-1-slash-2 http://techmaster.vn
  • 24. Thực hành một dự án khủng !!! Đầu tiên dùng AFNetworking sau đó chuyển qua RestKit http://techmaster.vn
  • 25. Ứng dụng địa điểm sử dụng Foursquare • Lấy địa điểm người dùng đang đứng, hoặc địa điểm nhập vào • Tìm ra các loại địa điểm gần đó: ATM, bar, restaurant… • Tham khảo https://developer.foursquare.com/ • Sử dụng AFNetworking cho dễ trước, sau đó dùng RestKit http://techmaster.vn
  • 26. Đã có một hướng dẫn lập trình RESTKit kết nối Foursquare API trên trang Raywenderlich. http://www.raywenderlich.com/13097/intro-to-restkit-tutorial Nhưng từ đó đến nay API của RESTKit đã thay đổi rất nhiều. Tutor cho bản mới thì chưa có? Làm thế nào bây giờ? http://techmaster.vn
  • 27. RestKit Pod platform:ios pod 'RestKit' , '0.20.0pre6’ Lỗi [!] RestKit (0.20.0pre6) is not compatible with iOS 4.3. http://techmaster.vn
  • 28. Correct Pod file platform:ios, '5.0’ //iOS 5.0 trở lên pod 'RestKit’ //lấy bản mới nhất http://techmaster.vn
  • 29. Học cách dùng RESTKit http://www.slideshare.net/peterfriese/restkit- from-zero-to-hero (đã cũ) http://restkit.tumblr.com/ (blog) https://github.com/RestKit/RestKit/wiki/Object- Mapping (tài liệu ánh xạ từ REST vào đối tượng) http://techmaster.vn

Hinweis der Redaktion

  1. http://stackoverflow.com/questions/6991142/writable-atomic-property-result-cannot-pair-a-synthesized-setter-getter-with-a
  2. http://en.wikipedia.org/wiki/RubyGems