不同SDK对pathForResource函数兼容问题

问题描述
前些天做AD iPad版,程序在4.2版本的iPad上运行良好,但是安装到3.2版本的iPad上有些功能点load不出。

问题分析
设置断点,一步一步跟踪,查找到:

// init position
NSString *plistPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d/feature_point",[self getPage]] ofType:@"plist"];
_positions=[[NSDictionary alloc] initWithContentsOfFile:plistPath];

以上代码plistPath值为空,查找这句中所有的语句的SDK支持,都只要SDK2.0,而我们是3.2,完全符合。

问题解决
一步一步排除,最后焦点在pathForResource: ofType:函数,查找SDK的时候发现另有一个函数是pathForResource: ofType: inDirectory:函数,把该句改为:

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"feature_point" ofType:@"plist" inDirectory:[NSString stringWithFormat:@"%d",[self getPage]]];

问题解决了!!!

Project Settings的设置bug

问题描述
帮客户的iPad安装AD demo,机器SDK是4.2.1,客户iPad SDK是3.2,直接developer debug不成功。

问题分析
把“Project Settings”的"Build"选项卡里的"Base SDK"设置为"Latest iOS"(最高),并把"iOS Deployment Target"设置为"iOS 3.0"(最低)。

问题解决
网上查了下,看到一老外的解决办法,如下:

I believe the only requirement is that you edit and resave the info.plist file. I editted to 1.7, saved, and then back to 1.0 and it worked fine.

It may be that XCode is binding in additional details from the build settings at the time of packaging and since the info.plist hadn't changed those additional bindings did not get attached. If this is the case I would consider it a bug.

我也认为是一个iOS的Bug,只有修改info.plist才会导致project settings设置生效。