问题描述:Xcode报错ARC forbids Objective-C objects in struct
问题解决:问题是struct中不支持NSObject对象,所以在前面加入
__unsafe_unretained脱离ARC解决。
问题描述:Xcode报错ARC forbids Objective-C objects in struct
问题解决:问题是struct中不支持NSObject对象,所以在前面加入
__unsafe_unretained脱离ARC解决。
问题描述:转用CocoaPods作为第三方类库管理加载后,测试提示找不到某类库的.h文件。
问题解决:Project->[Project Name]->Configurations->LogicTests->"None" to "Pods"
问题描述:想更新CocoaPods,在终端运行sudo gem update cocoapods,出现如下错误:
Updating cocoapods
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/xcodeproj-0.13.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/xcodeproj-0.13.1/ext/xcodeproj/gem_make.out
问题解决:Go to Xcode, Preferences -> Downloads,download Command Line Tools.
问题描述:今天在做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了
问题描述:今天在做TAG App 时在Project上不小心“New Group from Selection” 了下。然后无法撤销了。。。Project上就一直顶着一个New Group。
问题解决:
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文件里的设置,每个选项都有详细的说明,这里就不再赘述了。
问题描述:今天安装cocos2d-x出现如下错误:
Last login: Thu Jun 20 11:49:10 on ttys001
Could-HllmatoMacBook-Pro:~ CouldHll$ /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh -u -f
cocos2d-x template installer
Installing Xcode 4 cocos2d-x iOS template
----------------------------------------------------
removing old libraries: /Users/CouldHll/Library/Developer/Xcode/Templates/cocos2d-x/
...creating destination directory: /Users/CouldHll/Library/Developer/Xcode/Templates/cocos2d-x/
...copying cocos2d files
rsync: link_stat "/Users/CouldHll/cocos2dx" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_cocos2d-x.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying CocosDenshion files
rsync: link_stat "/Users/CouldHll/CocosDenshion" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying websockets files
rsync: link_stat "/Users/CouldHll/external/libwebsockets/ios" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying extension files
rsync: link_stat "/Users/CouldHll/extensions" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying template files
rsync: link_stat "/Users/CouldHll/template/xcode4/." failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 Chipmunk iOS template
----------------------------------------------------
...copying Chipmunk files
rsync: link_stat "/Users/CouldHll/external/chipmunk" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_chipmunk.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 Box2d iOS template
----------------------------------------------------
...copying Box2D files
rsync: link_stat "/Users/CouldHll/external/Box2D" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_box2d.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 lua iOS template
----------------------------------------------------
...copying lua files
rsync: link_stat "/Users/CouldHll/scripting/lua" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_lua.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_tolua++.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 JS iOS template
----------------------------------------------------
...copying js files
rsync: link_stat "/Users/CouldHll/scripting/javascript/bindings" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_js.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
...copying spidermonkey files
rsync: link_stat "/Users/CouldHll/scripting/javascript/spidermonkey-ios" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
done!
Could-HllmatoMacBook-Pro:~ CouldHll$ /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh
cocos2d-x template installer
Error: This script must be run as root in order to copy templates to /Library/Application Support/Developer/Shared/Xcode
Try running it with 'sudo', or with '-u' to install it only you:
sudo /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh
or:
/Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh -u
Could-HllmatoMacBook-Pro:~ CouldHll$ /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh
cocos2d-x template installer
Error: This script must be run as root in order to copy templates to /Library/Application Support/Developer/Shared/Xcode
Try running it with 'sudo', or with '-u' to install it only you:
sudo /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh
or:
/Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh -u
Could-HllmatoMacBook-Pro:~ CouldHll$ sudo /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh
Password:
cocos2d-x template installer
Installing Xcode 4 cocos2d-x iOS template
----------------------------------------------------
templates already installed. To force a re-install use the '-f' parameter
Could-HllmatoMacBook-Pro:~ CouldHll$ sudo /Users/CouldHll/Downloads/cocos2d-x-2.1.4/install-templates-xcode.sh -f
cocos2d-x template installer
Installing Xcode 4 cocos2d-x iOS template
----------------------------------------------------
removing old libraries: /Users/CouldHll/Library/Developer/Xcode/Templates/cocos2d-x/
...creating destination directory: /Users/CouldHll/Library/Developer/Xcode/Templates/cocos2d-x/
...copying cocos2d files
rsync: link_stat "/Users/CouldHll/cocos2dx" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_cocos2d-x.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying CocosDenshion files
rsync: link_stat "/Users/CouldHll/CocosDenshion" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying websockets files
rsync: link_stat "/Users/CouldHll/external/libwebsockets/ios" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying extension files
rsync: link_stat "/Users/CouldHll/extensions" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
...copying template files
rsync: link_stat "/Users/CouldHll/template/xcode4/." failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 Chipmunk iOS template
----------------------------------------------------
...copying Chipmunk files
rsync: link_stat "/Users/CouldHll/external/chipmunk" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_chipmunk.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 Box2d iOS template
----------------------------------------------------
...copying Box2D files
rsync: link_stat "/Users/CouldHll/external/Box2D" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_box2d.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 lua iOS template
----------------------------------------------------
...copying lua files
rsync: link_stat "/Users/CouldHll/scripting/lua" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_lua.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_tolua++.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
Installing Xcode 4 JS iOS template
----------------------------------------------------
...copying js files
rsync: link_stat "/Users/CouldHll/scripting/javascript/bindings" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
rsync: link_stat "/Users/CouldHll/licenses/LICENSE_js.txt" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
...copying spidermonkey files
rsync: link_stat "/Users/CouldHll/scripting/javascript/spidermonkey-ios" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
done!
done!
Could-HllmatoMacBook-Pro:~ CouldHll$
问题解决:安装脚本是需要在安装程序目录的,所以要先进入安装目录:
Could-HllmatoMacBook-Pro:cocos2d-x-2.1.4 CouldHll$ cd /Users/CouldHll/Downloads/cocos2d-x-2.1.4
然后安装,一切正常。
两条命令删除xcode
sudo /Developer/Library/uninstall-devtools --mode=all
sudo /Developer/Library/uninstall-developer-folders
Xcode代码提示生成源代码程序块默认格式如下,注意左花括号的位置:
if ( condition ) {
do ...
}
因为以前的使用习惯,我想让自动生成的左右花括号都单独成行,变成下面的样子:
if ( condition )
{
do ...
}
在Terminal里面,运行下面命令,然后重启Xcode:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\n"
这个命令修改了~/Library/Preferences/com.apple.Xcode.plist,这是Xcode的配置文件