Parse与-ObjC冲突

问题描述:今天做TAG的时候,加入Parse并加好相应的frame,还是报如下错误:
Undefined symbols for architecture i386:
"_FBTokenInformationExpirationDateKey", referenced from:
-[PFFacebookTokenCachingStrategy cacheTokenInformation:] in Parse(PFFacebookTokenCachingStrategy.o)
-[PFFacebookTokenCachingStrategy expirationDate] in Parse(PFFacebookTokenCachingStrategy.o)
-[PFFacebookTokenCachingStrategy setExpirationDate:] in Parse(PFFacebookTokenCachingStrategy.o)
"_FBTokenInformationTokenKey", referenced from:
-[PFFacebookTokenCachingStrategy accessToken] in Parse(PFFacebookTokenCachingStrategy.o)
-[PFFacebookTokenCachingStrategy setAccessToken:] in Parse(PFFacebookTokenCachingStrategy.o)
"_FBTokenInformationUserFBIDKey", referenced from:
-[PFFacebookTokenCachingStrategy facebookId] in Parse(PFFacebookTokenCachingStrategy.o)
-[PFFacebookTokenCachingStrategy setFacebookId:] in Parse(PFFacebookTokenCachingStrategy.o)
"_OBJC_CLASS_$_FBAppCall", referenced from:
objc-class-ref in Parse(PFFacebookAuthenticationProvider.o)
"_OBJC_CLASS_$_FBRequest", referenced from:
objc-class-ref in Parse(PFFacebookAuthenticationProvider.o)
"_OBJC_CLASS_$_FBSession", referenced from:
objc-class-ref in Parse(PFFacebookAuthenticationProvider.o)
"_OBJC_CLASS_$_FBSessionTokenCachingStrategy", referenced from:
_OBJC_CLASS_$_PFFacebookTokenCachingStrategy in Parse(PFFacebookTokenCachingStrategy.o)
"_OBJC_METACLASS_$_FBSessionTokenCachingStrategy", referenced from:
_OBJC_METACLASS_$_PFFacebookTokenCachingStrategy in Parse(PFFacebookTokenCachingStrategy.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
问题解决:
方法一:加入FaceBookSDK.framework(>1M)
方法二:设置单独的静态库,使用-force_load /path/libname.a来替换之前的配置-all_load _ObjC
方法三:使用CocoaPods安装Parse

我选择了第三种方法,还是CocoaPods好啊

Xcode中Git提交问题

问题描述:今天在做TAG App用Xcode中的Git提交代码,出现如下错误:

The working copy "ViewDeck" failed to commit files.

error: pathspec 'IIWrapController.m' did not match any file(s) known to git.
error: pathspec 'IIWrapController.h' did not match any file(s) known to git.
error: pathspec 'IISideController.m' did not match any file(s) known to git.
error: pathspec 'IIViewDeckController.m' did not match any file(s) known to git.
error: pathspec 'IISideController.h' did not match any file(s) known to git.
error: pathspec 'IIViewDeckController.h' did not match any file(s) known to git.

问题解决:用GitHub进行提交,OK了

Undo “New Group from Selection” project

问题描述:今天在做TAG App 时在Project上不小心“New Group from Selection” 了下。然后无法撤销了。。。Project上就一直顶着一个New Group。

问题解决:

  1. close xcode
  2. right click on your project's .xcodeproj, then click "Show Package Contents"
  3. inside .xcodeproj, remove the project.xcworkspace
  4. save it and re-open your xcode project and it would be rebuild the file

 

Base Internationalization需要iOS6以上

问题描述:今天在做TAG Apple 时发现问题。在iOS6-iOS7下,模拟器和真机都运行良好。在iOS5下,模拟器可以运行,但是真机跳出错误,如下:

2013-09-23 10:53:05.199 TAG[2136:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main_iPhone' in bundle NSBundle </var/mobile/Applications/B841AA38-1064-4C47-A560-0C1A8FF003AE/TAG.app> (loaded)'

*** First throw call stack:

(0x3743388f 0x35138259 0x3147f5fb 0x312b63ed 0x3113f6eb 0x3113972f 0x31107ac3 0x31107567 0x31106f3b 0x33b4922b 0x37407523 0x374074c5 0x37406313 0x373894a5 0x3738936d 0x3113886b 0x31135cd5 0x8f68d 0x8e130)

terminate called throwing an exception(lldb)

问题分析:首先想到可能是storyboard,查了一下,是支持iOS5+的。然后找到TARGETS-BUILD Phases,发现是所有storyboard都没找到。最后进入文件系统发现在Base.lproj目录下。

问题解决:原因是Base Internationalization需要iOS6+。在GitHub上找到让其支持iOS5的方法:https://github.com/RolandasRazma/RRBaseInternationalization

使用Uncrustify在Xcode中格式化Objective-C代码(转)

Xcode是开发iOS应用和Mac OS应用的必备工具,但这个工具的辅助功能相对于Eclipse之类的IDE来说,还是比较少,在Eclipse里只要按Ctrl+Shift+F,就可以将Java代码格式化得非常好看。而在Xcode里,只有Re-Indent(Ctrl+I)这一个调整缩进的功能,显然不够用。

如果想要完成完备的代码格式化,得要借助Uncrustify这样的工具。更进一步,我们用Automate配置一个针对Text的Service,再加上快捷键,就可以在Xcode里间接实现和Eclipse同样效果的代码格式化功能了。

首先安装Uncrustify工具。安装的方法很多,推荐用Homebrew来安装。如果机器上没有Homebrew,先用这条命令安装:

/usr/bin/ruby -e "$(curl -fksSL http://u.aodaren.com/homebrew)"

安装好Homebrew后,用这条命令安装Uncrustify:

brew install uncrustify

详细的Automate配置步骤可以参考这篇文章,如果不想自己配置,也可以直接下载已经配置好的workflow包,复制到~/Library/Services/,并解压就可以了:

mv Uncrustify-Objective-C.workflow.tar.gz ~/Library/Services/
cd ~/Library/Services/
tar zxvf Uncrustify-Objective-C.workflow.tar.gz

下载针对Objective-C语言的Uncrustify配置文件,移动到 ~/ 目录,并更名为 .uncrustify_obj_c.cfg,注意目标文件名前面有个 .:

mv uncrustify_obj_c.txt ~/.uncrustify_obj_c.cfg

如果上面已经顺利完成,那么现在到Xcode里选中一段代码,点右键,在Services里面应该已经有一个Uncrustify Objective-C服务了。选择后,即可将代码格式化。当然,如果每次都点鼠标显然太麻烦,下面来配置快捷键。

点屏幕左上角的苹果图标,选 System Preferences – Keyboard – Keyboard Shortcuts – Services,在Text分区里,找到刚添加的服务Uncrustify Objective-C,给这个服务加上快捷键。注意不要和Xcode里其它快捷键冲突,推荐设置为:Opt+Cmd+字母O。

这样以后在Xcode里,先用Cmd+A全选代码,再用Opt+Cmd+O来格式化代码。整个效果和Eclipse基本上差不多。

最后,如果对格式有不同的需求,还可以修改cfg文件里的设置,每个选项都有详细的说明,这里就不再赘述了。

KeychainItemWrapper出现Couldn’t add/update the Keychain Item错误的解决方法

问题描述:使用 Apple 提供的 KeychainItemWrapper,出现了 Assertion 错误: Couldn't add the Keychain Item 或者 Couldn't update the Keychain Item。

问题分析:出现这一问题一般都是由于在一个文件中调用了两个或者两个以上的 keychain ,所以在 update 时候,会出现 kSecValueData 这个 key 的 value 出现重复,所以在 KeychainItemWrapper.m 中会出现
NSAssert( result == noErr, @"Couldn't update the Keychain Item." );

问题解决:setObject时候写一句:
[self.myKeychain setObject:@"YOUR_APP_INFO" forKey:(__bridge id)kSecAttrService];