如何使用 iCloud 访问 Xcode 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12133490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to access Xcode project with iCloud
提问by user700352
I recently bought a MacBook Pro that I will use to develop an iPhone app. I want to be able to transfer the Xcode project between my Macbook and my iMac in the same manner that Word documents can be transferred using iCloud. Is there a secure way this can be done?
我最近买了一台 MacBook Pro,我将用它来开发 iPhone 应用程序。我希望能够以与使用 iCloud 传输 Word 文档相同的方式在我的 Macbook 和 iMac 之间传输 Xcode 项目。有没有安全的方法可以做到这一点?
采纳答案by Seb
I'm using dropboxto sync my xcode projects across 2 macs. I had no issues so far but I would recommend not to work on a project simultaneously, so make sure to close it on one machine before you open it on another.
我正在使用dropbox在 2 台 Mac 上同步我的 xcode 项目。到目前为止,我没有遇到任何问题,但我建议不要同时处理一个项目,因此请确保在一台机器上关闭它,然后再在另一台机器上打开它。
回答by D.A.H
iCloud or version management?
iCloud 还是版本管理?
iCloud might sound good idea for syncing Xcode projects, but it actually leads to problems. You should use gitinstead. I recommend to use bitbucket (online git repos), which is free. You can host private or public projects on bitbucket. I like bitbucket because of free private repos. GitHub does not provide free private repositories!
iCloud 可能听起来是同步 Xcode 项目的好主意,但它实际上会导致问题。你应该改用git。我建议使用免费的 bitbucket(在线 git repos)。您可以在 bitbucket 上托管私人或公共项目。我喜欢 bitbucket 因为免费的私人回购。GitHub 不提供免费的私有仓库!
Easy to share
易于分享
When you are done editing your code in one machine, you can commit changes and then push your committed changes into a remote repository. When you are open your project on another computer, you have to fetch it (pull) from the remote repository.
在一台机器上完成代码编辑后,您可以提交更改,然后将提交的更改推送到远程存储库中。当您在另一台计算机上打开您的项目时,您必须从远程存储库中获取(拉取)它。
By using git, you can share your code easily with other team members, too.
通过使用 git,您也可以轻松地与其他团队成员共享您的代码。
How to
如何
See more here:
在此处查看更多信息:
回答by Mojo66
Here is how I use iCloud Drive as a remote git repo:
以下是我如何使用 iCloud Drive 作为远程 git 存储库:
- Create a new Xcode Project (with git versioning turned on) in a local directory, for example
~/Xcode-Projects-Local/GiTest
Clone the new local directory to a remote directory, for example iCloud Documents:
git clone --bare --no-hardlinks ~/Xcode-Projects-Local/GiTest ~/Documents/Xcode-Projects/git/GiTest.git
Add the cloned directory as a remote to the local repo:
cd ~/Xcode-Projects-Local/GiTest
git remote add -f iCloud ~/Documents/Xcode-Projects/git/GiTest.git
On a different Mac, clone the remote repo into a new local directory:
git clone ~/Documents/Xcode-Projects/git/GiTest.git ./GiTest
Enjoy!
- 例如,在本地目录中创建一个新的 Xcode 项目(打开 git 版本控制)
~/Xcode-Projects-Local/GiTest
将新的本地目录克隆到远程目录,例如 iCloud Documents:
git clone --bare --no-hardlinks ~/Xcode-Projects-Local/GiTest ~/Documents/Xcode-Projects/git/GiTest.git
将克隆的目录作为远程添加到本地存储库:
cd ~/Xcode-Projects-Local/GiTest
git remote add -f iCloud ~/Documents/Xcode-Projects/git/GiTest.git
在另一台 Mac 上,将远程存储库克隆到新的本地目录中:
git clone ~/Documents/Xcode-Projects/git/GiTest.git ./GiTest
享受!
For an existing project, just skip step 1. Note the --no-hardlinks
option to make sure that hard links won't confuse iCloud drive.
对于现有项目,只需跳过步骤 1。注意--no-hardlinks
确保硬链接不会混淆 iCloud 驱动器的选项。
For those wondering 'why not just put the project dir directly on the iCloud drive': Xcode always had and -- as of Xcode 10 -- still has problems with that eventually resulting in a corrupted repo.
对于那些想知道“为什么不将项目目录直接放在 iCloud 驱动器上”的人来说:Xcode 总是有并且 - 从 Xcode 10 开始 - 仍然存在最终导致存储库损坏的问题。
If you are planning to work on machines with different screen resolutions, for example Macbook and iMac, you should git-ignore directories named project.xcworkspace/xcuserdata
.
如果您打算在具有不同屏幕分辨率的机器上工作,例如 Macbook 和 iMac,您应该 git-ignore 名为 .gitignore 的目录project.xcworkspace/xcuserdata
。