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 服务不停的崩。查了查,有人已经分析过了:
http://stackoverflow.com/questions/31551480/xcode-7-beta-4-ios-simulators-missing-and-not-installable
简单点说,去把7.x / 8.x 的 simulator 映像文件都移走或者干脆删除,就好了。

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

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:

    #import 
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.
    }];