Search code examples
iosxcodeios7

How do I copy and rename/refactor ios xcode sample project as my starting point?


How do I copy one of the sample projects from developer.apple.com and use it as a starting point for my own app?

I have searched on-line, but cannot find an explanation of the necessary steps to rename/refactor an existing project.


Solution

  • First, copy the sample project and all files in its directory to a new directory and open the newly created .xcodeproj file in Xcode. Then edit the project file name in the project navigator on the left. Once you save a new name, Xcode will ask you if you want to rename related files and targets that share that name, which you do.

    Now you want to edit your scheme, which is just to the right of the build button in the top left. Click on the scheme (which is likely the name of the sample project), and select manage schemes. Delete the scheme that has the old project name, and click Autocreate Schemes Now to create an appropriately named scheme for your project.

    If you want to rename classes from the sample project, you can do this by right-clicking the class name in the code editor -> refactor -> rename. This will rename all uses of that class in your project along with it's .h and .m files. You can then remove any unneeded files from the sample project, and add any of your own files to the project.