The struggling with CocoaPods seems got ending

CocoaPods is really cool tool to incorporate 3rd party open source library,  it is even cooler with the app built-in framework support added in recent (since 0.36) and  dedup-ing of targets along with simpler name in 0.38.

Naturally, I’m considering to use CocoaPods as a primary tool to organize the project, which means private repo and destruct the project into pods.

At beginning, I made my mind up like:

屏幕快照 2015-09-19 下午1.14.32

But soon I got a lot issue to struggle with, thus the working environment is involuted to:

CocoaPods repo setup with struggling env

Yep, I had to draw this to clear my mind.

One of those modules  come with CoreData model (.xcdatamodeld) and the model just didn’t appear after pod install. And lately I get it, the bundle folder itself is better to be added as a source file, but I still need to add it back to project, or it will not be compiled. And, I can’t.

After quite a lot struggling, I believe the answer can only dig out from its source code. CocoaPod is written in Ruby, which I haven’t learn yet, which means I have to learn Ruby firstly, which is why I didn’t read its code at first time.

Fortunately, Ruby is a simple language, it took about half day to learn the syntax. Thanks a lot to a good tutorial ( and a great quick reference ( Here is my study notes:

Ruby Language

— Oh, no, I should have read ( at first moment, it is way far efficient written for me.

Reading source code of CocoaPods is a little confusing, I cannot find the entry point until reading its CLAide sub project. Other parts are quite readable, soon I located the file_accessor using Dir glob to list files survived cleaning, which doesn’t understand specific folder is a bundle and will list its contents, those contents obviously are not recognized as source file. Considering I haven’t read all the source code and it is quite possible to have side effects to patch glob-ing part, I decided to insert the patch in adding source reference part.

So that a quick and a little dirty patch is created and PR is submitted. If you happen having same idea by now, try my fork (  After cloned, you may install it by:

gem build ./cocopods.gemspec
sudo gem install --local ./cocoapods-0.39.0.beta.4.gem

BTW, CocoaPods includes 1645 spec requirements (unit tests) and 1650 integration test requirements, really surprised me.



Update ordered ToMany relationship in CoreData

It is a well known bug, when a relationship is checked with ordered, some Dynamically-Generated accessor Methods (add*) will throw exception, some others (insert*) are just not generated.

I ran into this issue again. Yeah, I met it about 1 year ago. I’m one hundred percent sure it is a bug. And a patch is created by someone long ago

But, it seems Apple guys had decided not to fix it. The radar item are closed now!

Fortunately,  -mutableOrderedSetValueForKey: method mentioned by document always works. I guess it is the time for Apple to update their document ( :

Typically, however, you do not want to set an entire relationship, instead you want to add or remove a single element at a time. To do this, you should usemutableSetValueForKey: or one of the automatically-generated relationship mutator methods (see Dynamically-Generated Accessor Methods): unless it is order!

Yet another trap of CocoaPods

Creating a pod in my private repo, it worked fine till I made some uncertain changes. Now running ‘pod install’ in Example will complain:

Resolving dependencies of `Podfile`
[!] Unable to satisfy the following requirements:

– `DataModel (from `../`)` required by `Podfile`
– `DataModel (from `../`)` required by `Podfile`
– `DataModel (= 0.1.0)` required by `Podfile.lock`

And eventually, I figured it out, it is caused by iOS platform version which I just modified to reflect truth of framework in bundle requires 8.0.

  s.platform     = :ios, ‘8.0’

It works like a charm when the version is 7.0 or 7.1 . How could it be so weird?! Well, it is not weird indeed, I just didn’t give the iOS version in Podspec file. It will work with right iOS platform version, like:

platform :ios, ‘8.0’

The error information didn’t mention platform version, it should have saved my day!

Xcode7 的两个小坑

Xcode7 还在 beta,时不时崩一下什么的倒也是预料之中的事,没料到的是之前用着好好的,今天升完 El Capitan 之后,模拟器居然不见了,设备倒是在 schema 栏右边里能看到,不过注明不能用。

看了看系统日志是 Simulator 服务不停的崩。查了查,有人已经分析过了:
简单点说,去把7.x / 8.x 的 simulator 映像文件都移走或者干脆删除,就好了。

另外,beta4 会报怨 CoreData 模型文件没有指定版本号,这新建的文件哪来的版本好,在 Editor 里给建了一个版本终于不 warning 了。

Install MacPorts on Mac OS X 10.11

Just notice MacPorts is missing after upgraded to 10.11 beta, need re-installing.

Downloaded MacPorts 2.3.3 source tar ball, but configure complains there is no Foundation framework. And it is solved by xcode-select -s to switch to Xcode7-beta:

sudo xcode-select -s /Applications/

Little tricks with XCTest

Tried to call all other tests in one test function.

    // alternate what setup done
    // full tests in alternated state
    NSArray * tests = [FileLibraryTests testInvocations];
    for (NSInvocation * inv in tests ) {
        NSString * sel = NSStringFromSelector(inv.selector);
        if (![sel containsString:@"WithInit"] && ![sel containsString:@"Monitoring"]) {
            [inv invokeWithTarget:self];
    //back to normal state

And just noticed XCode6 added XCTestExpetation, no longer need semaphore like:

dispatch_semaphore_t sema = dispatch_semaphore_create(0);
dispatch_after(dispatch_time(0, (int64_t)(0.2 * NSEC_PER_SEC)), 
        dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), 
            ... dispatch_semaphore_signal(sema); ...
dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, 30*NSEC_PER_SEC));

It is much simple to test async operations now:

    XCTestExpectation *expectation = [self expectationWithDescription:@"xxx"];
// invoke it in code async executing
    ... ^(){
        [expectation fulfill];
    } ...
[self waitForExpectationsWithTimeout:1 handler:^(NSError *error) {
        // cleanup.

CocoaPods and objc_msgSend

I got this “Too Many arguments to function call, expected 0, have 3” error while compiling a project relies on QuickDialog.

According “”, it is easy to fix, just cast the function to right prototype, like:

int (*action)(id, SEL, int) = (int (*)(id, SEL, int)) objc_msgSend;

But, the invocation is in a pod project which is locked for editing and even if I unlock it, the change will lose at next checking out of the project.

Further peek at objc/message.h shows it is a trick to help compiler ensuring the call is with right frame, the signature is still available with OBJC_OLD_DISPATCH_PROTOTYPES micro. Then I found the:Screen Shot 2015-06-12 at 9.27.25 AM

Set “Enable Strict Checking of objc_msgSend Calls” in QuickDialog target of Pod project, done.



  1. 动图型:已经有界面的图片了,不管是手绘还是 PS / Sketch 3,有许多工具都可以导入后加上热区跳转和交互效果了。
  2. 描绘型:提供各种图形组件,可以快速描画界面,普通可以快速实现界面跳转,复杂的交互和条件处理只有少量组件可以了。
  3. 编程型:无论是直接拿 html/js 开练,还是拿 Quartz Composer 用图形语言写,本质上都是在编程了,看用的人会写js还是熟图形处理了。

目前看下来,还是 Axure 功能比较全面,其它的工具处理处理小项目还成,管理复杂项目还是费劲点。Pencil 这个开源项目其实很不错,就是蛮久没人维护了。

Apple Watch 使用小结

Apple Watch 到手有些日子了,用下来还不错。





现在改用太阳表盘了,每天看看日出日落时间还蛮酷的, Module 表盘太快就看疲劳了。




Twitter 做得还是不错的,可惜没 wi-fi 时翻墙比较烦人,基本只拿来收通知了。丫的 iOS 客户端我没找到在哪里设置代理,Android 版本倒是很好找。

搜狐视频动作很快,已经有表上的播放控制和个人收藏查看功能了,不过它没法控制 iPad 上的播放呀,手机我就拿手上看了,放远了看不清楚呀。也试了 AirPlay 到 Apple TV 上,这个不知道是我不会用还是咋得,音量似乎控制不了,也不能控制 airplay 切换。顺便吐个槽,在 iPad 上做个看得见的 AirPlay 目标切换菜单就那么有挑战性?


听说这货防水其实很 NB,不过坏了不保,想来想去还是没带它去游泳,反正也没有游泳统计模式。

最后越来越觉得还是应该买 42mm 的,特别是被某人吐槽说 38mm 的在我手上颇有基佬范以后。