11

我想澄清这个问题。我在 iMac 上安装了 Cocos2d 1.01 rc,安装了 XCode 4.3,现在我已经下载了 v2.0 并想安装模板(按照官方指南)。不幸的是,终端在尝试此操作时允许我拒绝消息。

我认为我需要做的只是一个“sudo su”命令,然后是一个 chmod,这就是我试图做的:

sudo su
chmod -R 0777 /Users/xxx/Library/Developer/Xcode/Templates/*

结果对我来说似乎很好(在模板的所有子目录上读取、写入和执行):

ls -l /Users/xxxx/Library/Developer/Xcode/Templates/
total 0
drwxrwxrwx   4 root  staff  136 20 Giu 17:30 File Templates
drwxrwxrwx  19 root  staff  646 15 Mar 15:14 cocos2d

但是当我安装模板时,我得到以下内容,我不会安静地得到..它说“完成!” 但是终端中有几个错误表明由于权限而无法创建目录(即使它们似乎都设置了 r,w,x )。另外,我尝试通过 XCode 创建一个空的 Cocos2d 项目(重新启动 XCode 后),cocos2d.m 仍然显示版本 v1.0.1。

为了清楚起见,这里是尝试安装模板后来自终端的日志(我有点迷茫):

./install-templates.sh -f
cocos2d-iphone template installer



Installing Xcode 4 cocos2d iOS template
----------------------------------------------------

...creating destination directory: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/
mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying cocos2d files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocos2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocos2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying CocosDenshion files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshion.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshion.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying CocosDenshionExtras files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshionextras.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Kazmath files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_kazmath.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_kazmath.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
...copying template files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x" failed: Permission denied (13)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 Chipmunk iOS template
----------------------------------------------------

mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Chipmunk files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_chipmunk.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_chipmunk.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 Box2d iOS template
----------------------------------------------------

mkdir: /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Box2d files
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_box2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_box2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 CCNode file templates...
----------------------------------------------------

...creating destination directory: /Users/xxx/Library/Developer/Xcode/Templates/File Templates/cocos2d v2.x/
mv: rename /Users/xxx/Library/Developer/Xcode/Templates/cocos2d v2.x//CCNode class.xctemplate to /Users/xxx/Library/Developer/Xcode/Templates/File Templates/cocos2d v2.x/CCNode class.xctemplate: No such file or directory
done!

任何帮助将不胜感激:),谢谢!

编辑:尝试

sudo ./install-templates.sh -f

给出:

cocos2d-iphone template installer

Error: Do not run this script as root.

'root' is no longer supported

RECOMMENDED WAY:
 ./install-templates.sh -f

编辑2:

我尝试删除 Templates 目录中的 cocos2d 文件夹,如下所示:

drwxrwxrwx  3 root     staff  102 15 Mar 15:14 cocos2d
drwxr-xr-x  2 user  staff   68 20 Giu 17:30 cocos2d v2.x
imac-di-user:File Templates user$ cd ..
imac-di-user:Templates user$ ls 
File Templates  cocos2d
imac-di-user:Templates user$ sudo rm -rf *
Password:
imac-di-user:Templates user$ ls

并显示没有留下任何目录。然后我回到包含下载的 Cocos2d 2.x 文件的文件夹,我启动了安装脚本,如下所示:

imac-di-daniele:cocos2d-iphone-2.0-rc2 user$ ./install-templates.sh -f

不幸的是,它仍然无法安装它们,现在我没有模板了。这是控制台的输出:

./install-templates.sh -f
cocos2d-iphone template installer



Installing Xcode 4 cocos2d iOS template
----------------------------------------------------

...creating destination directory: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/
mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying cocos2d files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocos2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocos2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying CocosDenshion files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshion.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshion.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying CocosDenshionExtras files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_cocosdenshionextras.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Kazmath files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_kazmath.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_kazmath.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
...copying template files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x" failed: Permission denied (13)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 Chipmunk iOS template
----------------------------------------------------

mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Chipmunk files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_chipmunk.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_chipmunk.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 Box2d iOS template
----------------------------------------------------

mkdir: /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x: Permission denied
...copying Box2d files
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_box2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
rsync: mkdir "/Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x/lib_box2d.xctemplate/libs" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
done!



Installing Xcode 4 CCNode file templates...
----------------------------------------------------

...creating destination directory: /Users/user/Library/Developer/Xcode/Templates/File Templates/cocos2d v2.x/
mkdir: /Users/user/Library/Developer/Xcode/Templates/File Templates: Permission denied
mv: rename /Users/user/Library/Developer/Xcode/Templates/cocos2d v2.x//CCNode class.xctemplate to /Users/user/Library/Developer/Xcode/Templates/File Templates/cocos2d v2.x/: No such file or directory
done!
4

7 回答 7

18

在 Finder 中导航到此文件夹:

/Users/xxx/Library/Developer/Xcode/Templates

找到所有以“cocos2d”开头的文件夹。应该有两个,一个用于项目模板,另一个用于文件模板。

删除这些文件夹。系统会要求您输入密码,因为它需要超级用户权限。旧文件夹消失后,您可以安装模板。

发生错误是因为您之前使用sudo. 当前的模板安装程序脚本不能运行sudo(如果您尝试已经发现,则会失败),因此无法删除/替换以前由超级用户创建的模板文件。因此,只需删除文件夹即可解决问题,而chmod不能。

于 2012-06-20T18:37:19.187 回答
11
  1. Command + Shift + G
  2. ~/库/开发者/Xcode
  3. 删除 Templates 文件夹并重新创建它
  4. cd ....../cocos2d-iphone-2.0
  5. ./install-templates.sh –f
于 2012-07-22T11:47:43.027 回答
8

经过几次尝试,这对我有用。这只是对上面答案的澄清,还有更多细节。注意:我使用的是带有 MountainLion 10.8.2 的 MacBook Pro)。而且,我有一个很好的 coco2d v1.x 安装。

** 此过程将安装 cocos2D v2.0 和模板 **

下载后cocos2d-iphone-2.0.tar (解压缩并保留在桌面上)

  1. 点击Command++ (打开您的目录搜索 ShiftG
  2. 输入搜索:/Library/Developer/Xcode(定位 cocos2d 模板文件夹)
  3. 删除(并备份)“模板”文件夹(因为安装程序不会覆盖内容)
  4. 在 xCode 文件夹中创建一个新的“模板”文件夹(这样安装程序就会知道在哪里编写新模板)
  5. 打开终端,然后键入 cd,然后按回车键(获取新行)使终端保持打开状态。
  6. 现在转到并打开新的 cocos2d-iphone-2.0 文件夹,然后查找“install-templates.sh”文件。
  7. 您应该将该文档拖到当前行的终端中,然后按 enter(return)
  8. 安装应该开始。
  9. 开始 xcode > 寻找你的新 coco2s v2.x 模板

注意:我没有使用sudo, -u, or -f. 我也没有cocos2d-iphone-2.0在终端中引用文件夹(只是安装文档)。

于 2012-09-27T09:27:04.217 回答
3

1: sudo chmod -R 777 /用户/你的名字/图书馆/开发者/Xcode/模板

2:./install-templates.sh -f

3: sudo chmod -R 755 /用户/你的名字/图书馆/开发者/Xcode/模板

祝你好运

于 2012-12-19T09:08:56.720 回答
0

尝试

sudo ./install-templates.sh -f
于 2012-06-20T16:14:27.853 回答
0

执行以下黑客操作:打开文件 install-templates.sh 并将退出命令注释为:

# Make sure root is not executed
if [[ "$(id -u)" != "0" ]]; then
echo ""
echo "Error: Do not run this script as root." 1>&2
echo ""
echo "'root' is no longer supported" 1>&2
echo ""
echo "RECOMMENDED WAY:" 1>&2
echo " $0 -f" 1>&2
echo ""
#exit 1
fi

我试过了,和我一起工作

于 2013-03-17T09:40:58.407 回答
0

我猜有一些以前由 root 创建的文件夹,您没有权限更改它。

尝试:

sudo chown -R xxx /Users/xxx/Library/Developer/Xcode/Templates
./install-templates.sh -f
于 2013-07-15T08:06:43.647 回答