简体   繁体   中英

How to access Xcode project with iCloud

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?

iCloud or version management?

iCloud might sound good idea for syncing Xcode projects, but it actually leads to problems. You should use git instead. 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!

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.

How to

See more here:

I'm using dropbox to 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.

Here is how I use iCloud Drive as a remote git repo:

  1. Create a new Xcode Project (with git versioning turned on) in a local directory, for example ~/Xcode-Projects-Local/GiTest
  2. 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

  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:

    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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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