简体   繁体   English

如何使用iCloud访问Xcode项目

[英]How to access Xcode project with iCloud

I recently bought a MacBook Pro that I will use to develop an iPhone app. 我最近买了一台MacBook Pro,用于开发iPhone应用程序。 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. 我希望能够以与使用iCloud传输Word文档相同的方式在我的Macbook和iMac之间传输Xcode项目。 Is there a secure way this can be done? 有没有一种安全的方法可以做到这一点?

iCloud or version management? iCloud或版本管理?

iCloud might sound good idea for syncing Xcode projects, but it actually leads to problems. 对于同步Xcode项目,iCloud可能听起来不错,但它实际上会导致问题。 You should use git instead. 你应该使用git代替。 I recommend to use bitbucket (online git repos), which is free. 我建议使用免费的bitbucket(在线git repos)。 You can host private or public projects on bitbucket. 您可以在bitbucket上托管私人或公共项目。 I like bitbucket because of free private repos. 我喜欢bitbucket因为免费的私人回购。 GitHub does not provide free private repositories! 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: 在这里查看更多:

I'm using dropbox to sync my xcode projects across 2 macs. 我正在使用Dropbox在两台Mac上同步我的xcode项目。 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. 到目前为止我没有遇到任何问题,但我建议不要同时处理项目,所以一定要在另一台机器上打开它之前关闭它。

Here is how I use iCloud Drive as a remote git repo: 以下是我使用iCloud Drive作为远程git仓库的方法:

  1. Create a new Xcode Project (with git versioning turned on) in a local directory, for example ~/Xcode-Projects-Local/GiTest 在本地目录中创建一个新的Xcode项目(启用git版本控制),例如~/Xcode-Projects-Local/GiTest
  2. Clone the new local directory to a remote directory, for example iCloud Documents: 将新的本地目录克隆到远程目录,例如iCloud Documents:

    git clone --bare --no-hardlinks ~/Xcode-Projects-Local/GiTest ~/Documents/Xcode-Projects/git/GiTest.git

  3. 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

  4. On a different Mac, clone the remote repo into a new local directory: 在其他Mac上,将远程仓库克隆到新的本地目录中:

    git clone ~/Documents/Xcode-Projects/git/GiTest.git ./GiTest

  5. Enjoy! 请享用!

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名为project.xcworkspace/xcuserdata目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM