copy an Xcode project and work on it without changing the original

Discussion in 'Mac Programming' started by grandM, Sep 11, 2015.

  1. grandM, Sep 11, 2015
    Last edited: Sep 11, 2015

    grandM macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #1
    Hi Guys

    I'm trying to do something but it keeps failing. I have a working project. I want to hold on to this project A. Nevertheless I want a new project B to make some adjustments to project A. So I duplicated the project A in finder and opened the .xcodeproj file in my finder. It opens up but then the trouble starts.

    I can type in new code. Upon running B nothing is changed. Apparantly project A makes the same changes. When I hit the run button over there the project runs. However this wasn't my intention.

    I want two independent projects. How can I achieve this goal in an easy way?

    Once again: THANKS.
    ps: apparantly I can use snapshots but I do wonder how the copying is done
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
  3. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #3
    I'm using Xcode 6.4 and Yosemite
     
  4. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #4
    Put the one you want to preserve in a .tar.gz archive or a .dmg?
     
  5. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #5
    Make a git branch. Then you can change between the branches all you want with the click of a button. Uses the same directory.
     
  6. chown33, Sep 11, 2015
    Last edited: Sep 11, 2015

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    I don't have Xcode 6 live on anything at hand, so some of the following may require you to post screenshots or give verbatim lists.

    First, review this info:
    https://developer.apple.com/library....html#//apple_ref/doc/uid/TP40009934-CH22-SW1

    Second, open the original project (Proj-A) in Xcode. Select one of its files in the Navigator, and show its properties in the File Inspector. Tell us what the popup next to "Location" says, and what its Full Path is.

    Third, do the same thing for the same file in Proj-B (the duplicate). If both Proj-A and Proj-B have the same Full Path for the file, then that's the problem. There may be other problems, too, such as the two projects having the same "Derived" files location, i.e. the intermediate object files (.o) and such.

    If the Location popup shows something like "Absolute Path", then change it to one of the Relative options. You'll have to review the options and maybe experiment.

    If you don't want to experiment on Proj-A or Proj-B, then create a new throwaway project containing a single source file (helloworld.c). Change how Xcode refers to the source file. Then duplicate the project and see if it still refers to the original source.

    The goal is simply to learn how Xcode manages references to files in a project. Sometimes it's safest to learn how Xcode works on something you don't care about losing.

    In earlier Xcode versions, you could choose the "reference type" for any file in the project. You could also change the reference type for any file (or selected sets of files) quite easily. One of the options was "Relative to Project", which means relative to the .xcodeproj file. Since the typical starting point was to put a project file into a new folder for the project, simply duplicating the containing folder (i.e. the folder containing the .xcodeproj) would create a separate duplicate project.
     
  7. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #7
    What I do to be safe (in addition to checking stuff into a source control repository):

    Copy the entire folder containing source code, assets, and project file to another drive, then take that drive offline.

    Then change the bundle ID of the new clone project to something different before editing, building or running it.
     
  8. gnasher729, Sep 12, 2015
    Last edited: Sep 15, 2015

    gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #8

    Check the paths for your files. You might have used absolute paths, which means the project refers to files in their original location. Rename the folder containing the original project. Does the project still work? If not then you have used absolute paths, which is an absolute no-no.

    Please explain how git is supposed to help here.
     
  9. ocabj macrumors 6502a

    ocabj

    Joined:
    Jul 2, 2009
    #9
    Learn to use git. You don't have to store it remotely (e.g. github). You can keep it all locally.
     
  10. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #10
    I checked in the file inspector as Chown suggested. It seems it's absolute indeed. However I cannot changed it. When was this set to absolute? How can this be fixed?
     
  11. Sandy.ios macrumors newbie

    Joined:
    Mar 25, 2016
    #11
    --- Post Merged, Mar 25, 2016 ---
    Hi,

    Have you achieved this making of separate new xcode project without making any changes to the original?

    I'm in a need to making copy of the existing xcode project to a new project?

    Thanks in advance for your suggestions
     

Share This Page