Contents

조회 수 4989 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Why use protobuf?
Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. As google puts it: “Protocol buffers are now Google’s lingua franca for data” and if it’s good enough for google, then it must be worth checking out!

We use protocol buffers to serialize persistant data for our IOS and Android games. Creating classes that persist data like shop, high scores, player preferences, achievements can be done in minutes with protobuf. And that why we ♥ protobuf!

This is not a protobuf usage tutorial, for that, you can check out the official documentation: https://developers.google.com/protocol-buffers/docs/overview. What you won’t find in the official documentation is how to make protobuf for iOS, and this is what this tutorial aims to explain. If you need to build protobuf for iOS, then read on :)


Protobuf build process in general for iOS:
I’ll show you how to build protobuf library for armv7, armv7s, and i386 architecture, then merge those libraries together into a single fat library that can be used in iOS projects. This library will work on the simulator as well as on the device.


Download protobuf
- We used protobuf2.4.1 (the last stable version at the time of writing) https://code.google.com/p/protobuf/downloads/list


Update command line tools in Xcode
(you are going to need the latest viersion)
- Command line tools can be updated by going to Xcode->Preferences.. then selecting the Downloads tab and selecting Command Line Tools


Build and install the protobuf compiler
- to convert protobuf files into source code, you will need a protobuf compiler! You can build and install this compiler by going to protobuf directory and executing the following commands:
$ ./configure
$ make
$ make check
$ make install


Build library for iOS
To build the ios protobuf static library
copy this script into protobuf directory and name it build-proto-ios.sh, then execute this to give the file execute privilegies:

$ chmod a+x ./build-proto-ios.sh
$ ./build-proto-ios.sh

Go make a cup of coffie, this will take a few minutes :) You can also download the precompiled fat ios library from here.

After the compilation is done you will see a new folder under protobuf root called: ios-build. This folder contains libprotobuf-lite.a. This is a static library for iOS.


Import library into Xcode
To import libprotobuf-lite.a into Xcode, just right click on a project directory where you want to import the library, from the drop-down list choose “Add Files to project-name…” and add libprotobuf-lite.a library.


Import headers into xcode
You still need to tell Xcode where to look for protobuf headers. To do this go to your project target build settings and under “Header Search Paths” add the path to protobuf-base-folder/src. The “protobuf-base-folder” being the folder in which you have the protobuf library from google.


The compiled protobuf library is the lite version so remember to put
option optimize_for = LITE_RUNTIME;
at the start of your proto definition file.

For a tutorial on how to use protobuf, it’s best to check out googles official documentation: https://developers.google.com/protocol-buffers/docs/overview

Happy protobuffing.

If you got any suggestions or question, feel free to ask/suggest!

[출처] http://www.giraffe-games.com/using-protobuf-protocol-buffers-on-iphone-ios/
[샘플] https://github.com/regwez/protobuf-objc-iOS5

?

  1. [ios] 앱의 로컬 js 파일에서 해당 프로젝트의 이미지 불러오기

    Date2015.02.10 CategoryDevelop Byhooni Views631
    Read More
  2. [ios] 문자열로 함수 실행하기 (eval 함수처럼)

    Date2015.02.10 CategoryDevelop Byhooni Views860
    Read More
  3. [ios] URL 랜딩 속도(OpenURL 10초 정지되는) 이슈

    Date2015.02.09 CategoryDevelop Byhooni Views856
    Read More
  4. [js] 2048 예쁘게 만들고 있는거.. ㅋㄷ

    Date2015.01.30 CategoryDevelop Byhooni Views0
    Read More
  5. [php] XE 스킨에서 특정 도메인 리다이렉션

    Date2015.01.28 CategoryDevelop Byhooni Views583
    Read More
  6. [php] XE에서 도메인 별로 광고 다르게 적용하기

    Date2015.01.28 CategoryDevelop Byhooni Views620
    Read More
  7. [maven] Mac OS에 메이븐(maven) 설치하기

    Date2015.01.21 CategoryDevelop Byhooni Views1112
    Read More
  8. [ios] iOS 앱 아이콘을 만드는 유틸

    Date2015.01.03 CategoryDevelop Byhooni Views875
    Read More
  9. [ios] Xcode의 디버그 모드에서 콜스택

    Date2015.01.03 CategoryDevelop Byhooni Views1006
    Read More
  10. [ios] binary를 C코드로 변환

    Date2015.01.03 CategoryDevelop Byhooni Views1537
    Read More
  11. [ios] APNS에 사용할 인증서 만들기 (KeyChain에 있는 인증서 Export)

    Date2015.01.03 CategoryDevelop Byhooni Views905
    Read More
  12. [ios] iOS앱의 Xcode 빌드 과정

    Date2015.01.03 CategoryDevelop Byhooni Views2286
    Read More
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 ... 71 Next
/ 71