其實寫 Mac Apps 這念頭在我腦海中存在已久，但它的技術門檻比 iOS app 高許多，加上不能放廣告，所以一直都提不起勁去寫…
Apple 今年在技術上有很大的變動（Swift, Storyboard… etc），加快了 Mac app 的開發流程，亦使開發過程變得愉快一些。客觀條件成熟，所以決心一試～
寫這 app 是因為我是個執筆忘字很嚴重的人，用同音字去查字，幾乎是我每日的指定動作。
把這些問題加起來，我決定用一個 app 去解決它，於是乎這個 Chinese Helper 便誕生了～
把它做成 Menu Bar app 並設定為 auto start，一開機它便在我的 desktop 了，很方便～
My previous post suggested a simple way for deploying GData Objective-C client in Xcode 4, with a trade-off of using big static library image file (19MB).
By following the official compiling procedures, you may specify which API(s) to compile, and target for specific architecture (device or simulator). Thus the output image file will be significantly smaller (~3MB). However, its not easy to follow by just reading the text description in Google Code. So I prepared a step-by-step tutorial for its setup procedures, hope it helps 😉
- Download the GData sources and drag the GData.xcodeproj from Finder into your project source tree.
- Add a new target dependency: Click your target -> Build Phases -> Target Dependencies -> the + button
- Choose GDataTouchStaticLib and click Add
- In your project target -> Build Phases -> Link Binary With Libraries, add the libGDataTouchStaticLib.a library under the Workspace folder. Its in red after adding, because it will be the build output of the previous step, that is not existed yet.
- Also add the following frameworks at the same place, they are needed by GData.
- In Build Settings, add the following entries under “Other Linker Flags”
- Also in Build Settings, set /usr/include/libxml2 under “Header Search Paths”
- Remove unnecessary APIs:
For instance, if I want Calendar API only, select the GDataTouchStaticLib target of your GData project cross reference. Add the following 2 entries in “Other C Flags” for both Debug and Release settings:
- Note that -DGDATA_REQUIRE_SERVICE_INCLUDES=1 is compulsory (and already added in Release settings), while the others depend on what APIs you want. Say if you want Contacts API, you got to add
and so on..
- Build your project (⌘B), get your build product by opening Organizer -> Projects,then show your derived data in Finder by clicking the little arrow.
- In your derived data directory, browse to Build/Products/Debug-iphonesimulator, then drag the Headers directory to your source tree. (just link the header files is fine, thanks Fistman for correction)
- Thats all! To use the GData classes, just import the following header file and start coding ~
Hope this tutorial helps, happy coding 🙂
When I first came across the GData Objective-C client, I really shocked by its complicated setup procedures. Besides going through the tedious official setup procedures, why couldn’t we make our life easier by just importing the headers and static library image? I searched for such goodies but no luck.. So I compiled one from source and put it on GitHub 😉
How to use:
- First download and put all files into your Xcode project
- In your target -> Build Settings, set /usr/include/libxml2 in Header Search Paths
- In your target -> Build Phases -> Link Binary With Libraries, add libxml2.dylib
- To use the GData classes, just import the header file by: #import “GData.h”
That is! Pretty simple, right? BTW, what are the pros and cons of this method?
Pros: you can deploy GData library quick and easy.
Cons: The static library image file is big (19MB). Because, firstly, it included all APIs provided by Google, you may not want to use all of them. Secondly, its an universal binary work in both simulator and devices. It means both i386 and ARM6 architecture binaries are embed in one file.
Therefore, if quick and easy deployment is your priority, this could be your choice.