XCode4.6.2编译安装到iOS7

Posted by Jimney Lee at 2013-10-21 with tags ios7, xcode

由于老的工程使用XCode5.0编译到iOS7设备上,总会有莫名其妙的问题,所以一直想法设法仍然通过XCode4.6.2编译安装。经过测试,完美解决了问题。

简要步骤:

1、下载最新的XCode5.x的dmg安装文件,安装后在应用程序目录单独存放如下图:

2 、右击工程文件,用XCode5打开,并运行安装到您的设备上

3、右击工程文件,用XCode4.6.2开发,并运行安装到模拟器上

4、哈哈,用XCode4.6.2选择设备,你会看到设备已经可选

不用感谢我,感谢老外的分享吧,我只是传道士。enjoy it!

以下来自老外原文来自stackoverflow:http://stackoverflow.com/questions/17075894/deploy-from-xcode-4-6-2-to-ios-7-beta-device

Well I dont know If this is of any help to anyone but me. But I have been able to use Xcode 4.6.2 to deploy to my iPhone 5 running iOS 7. I think it is due to a bug in the system but it doesnt matter to me. It works ok. Now to do this, I do as follows:

Make sure you have the latest version of Xcode from the App Store. (Dont know why, but why not?)

Download and Install Xcode 5.

Close all instances of Xcode running in your system (4.6.2 and 5)

Run Xcode 5. you will see it recognises your device, you probably have to activate it as use it for development again.

Run Xcode 4.6.2 simultaneously. You will see it recognises your iPhone as in: make it valid target for development.

close or do whatever you want with Xcode 5. From this point onwards You can keep using xcode 4.6.2

I havent turned my computer off or restarted it in a long time so I dont know if this is a fluke or what. But other people I work with have been able to do the same, so I expect it to work for you.

EDIT:

Better yet. Something I have found useful is building from Xcode 4.6.x to an iOS 7 device, actually makes the phone run it in iOS6 or before Mode which is the way all apps run at the moment. So my guess is that this would be what your app would look like in iOS 7 if deployed from the app store. Assuming you are targeting iOS 4+

Similarly, if you build the same app using Xcode 5, it tries to incorporate some iOS 7 appearance proxies by default and certainly the ui behaves differently. Granted I havent played with Xcode 5 much, there is probably a toggle somewhere to turn this compatibility mode on and off.

解决图片缓存问题

Posted by Jimney Lee at 2013-10-07 with tags ios7, nimbus, AFNetworking

今天编译nimbus项目报错:ADDRESPONSE - not adding TO DISK OR MEMORY

NSURLRequest *request = [NSURLRequest requestWithURL:url
										  cachePolicy:NSURLCacheStorageNotAllowed    
			 						  timeoutInterval:20.f];

今天使用AFNetworking库,UIImaeView缓存图片时,出现这个怪异的警告,图片无法disk缓存。 网上搜了一通,从下面这个帖子找到答案,原来是我的缓存限制了。 http://questiontrack.com/nsurlcache-disk-limit-1203248.html

nimbus官方网站上建议使用SDURL来管理硬盘缓存,代码提供为:

// Nimbus implements its own in-memory cache for network images. Because of this we don't allocate
// any memory for NSURLCache.
static const NSUInteger kMemoryCapacity = 0;
static const NSUInteger kDiskCapacity = 1024*1024*5; // 5MB disk cache
SDURLCache *urlCache = [[[SDURLCache alloc] initWithMemoryCapacity:kMemoryCapacity
                                                      diskCapacity:kDiskCapacity
                                                          diskPath:[SDURLCache defaultCachePath]]
                        autorelease];
[NSURLCache setSharedURLCache:urlCache];

memory缓存被设置为0,故此处要修改为如下:

// any memory for NSURLCache.
static const NSUInteger kMemoryCapacity = 1024*1024*5; // 5MB disk cache
static const NSUInteger kDiskCapacity = 1024*1024*20; // 5MB disk cache
SDURLCache *urlCache = [[[SDURLCache alloc] initWithMemoryCapacity:kMemoryCapacity
                                                      diskCapacity:kDiskCapacity
                                                          diskPath:[SDURLCache defaultCachePath]]
                        autorelease];
[NSURLCache setSharedURLCache:urlCache];

希望对出现同样的问题同学提供及时的参考。

解决iOS7下,NSURLRequest设置NSURLCacheStorageNotAllowed的缓存问题

Posted by Jimney Lee at 2013-10-05 with tags ios7, NSURLRequest, cache

NSURLRequest *request = [NSURLRequest requestWithURL:url											  cachePolicy:NSURLCacheStorageNotAllowed    
			 		  				  timeoutInterval:20.f];

最近发现已发布的app的天气每天获取的都是以前某一天的数据,但是之前没有这个情况,原来ios6下没有问题,但是在ios7下,即使设置了NSURLCacheStorageNotAllowed,仍然缓存旧数据的问题。

根据SO这个帖子可以找到答案: 两种解决方案:

1、每次请求之前先删除旧的缓存

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:request];

2、cachePolicy设置为0,原因不明,先留个备份。 我暂时采用2中方法,简单只是为了效率。后面再深究,先更新app吧,蛋疼,不知今天几个小时能上传成功。

XCode编译iphone opencv2出错

Posted by Jimney Lee at 2013-03-12 with tags opencv2, iphone, xcode

今天发现使用新的opencv2版本的方法显示一张图片时,代码如下:

#include
#include
#include
using namespace cv;
using namespace std;
int main(int argc, const char * argv[])
{
    Mat image;
    image = imread("./baby.jpg");
    if (!image.data) {
        cout << "Could not read the image" <<endl;
        return -1;
    }
    char windowName[] = "Study01";
    namedWindow(windowName, CV_WINDOW_AUTOSIZE);
    imshow(windowName, image);
    waitKey(0);
    return 0;
}

编译器显示如下错误:

Undefined symbols for architecture x86_64: “cv::namedWindow(std::__1::basic_string, std::__1::allocator > const&, int)”, referenced from: _main in main.o “cv::imread(std::__1::basic_string, std::__1::allocator > const&, int)”, referenced from:_main in main.o “cv::imshow(std::__1::basic_string, std::__1::allocator > const&, cv::_InputArray const&)”, referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

google后初步分析为C++库和opencv库编译不一致,将XCode的C++ Standard Library改为GNU C++ standard library即可正常编译显示图片。此处仍有疑问,待日后考虑清楚。

具体见stackoverflow:http://stackoverflow.com/questions/13461400/opencv-unresolved-symbols-name-mangling-mismatch-xcode

备份:版本管理过程中递归删除.svn和.git目录的命令

Posted by Jimney Lee at 2012-12-20 with tags scm, git, svn, hightlight

step1:

$ find . -type d -name ".svn" | xargs rm -rf

step2:

$ find . -name .git -print0 | xargs -0 rm -rf

MacOS Terminal终端配置ls和vi颜色高亮

Posted by Jimney Lee at 2012-12-19 with tags macos, Terminal, hightlight

step1:

$ alias ls='ls -G'

step2:

$ vi .bash_profile

export PS1='\e[0:35m⌘\e[m \e[0:36m\w/\e[m \e[0:33m`git branch 2> /dev/null | g    rep -e ^* | sed -E  s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\e[m'
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

step3:

$ cp /usr/share/vim/vimrc ./.vimrc
$ vi .vimrc
set ai " auto indenting set history=100 " keep 100 lines of history set ruler " >show the cursor position syntax on " syntax highlighting set hlsearch " highlight >the last searched term filetype plugin on " use the file type plugins " When >editing a file, always jump to the last cursor position autocmd BufReadPost * \ >if ! exists("g:leave_my_cursor_position_alone") | \ if line("'\"") > 0 && line >("'\"") <= line("$") | \ exe "normal g'\"" | \ endif | \ endif
  • step4: restart teminal and enjoy it! :)