title: How to automate creation of new Xcode targets from Applescript/Automator/Shell Script
body: <p>I am currently working on a way to automate the process of adding new targets to my Xcode projects. One target has to be added to multiple Xcode projects and each target in the different project needs the same source files to be added, same groups to store the source files in the Xcode project, and the same build settings. Doing this manually can take a while and is very prone to human error, and I have to do this task fairly often. I have already written a script to generate new source files, copy them to system folders, edit source files with new information etc, but now I need to automate the Xcode part.</p>
  
  <p>This sums up what I want my automation to achieve:</p>
  
  <p>Open an Xcode project at /this/path/project.xcodeproj</p>
  
  <p>Duplicate an existing target and rename it</p>
  
  <p>Edit the Build Settings of the new target</p>
  
  <p>Add a group to the Source and Resources section, then rename them</p>
  
  <p>Add source files to the groups, and add the file to the new Target</p>
  
  <p>Close Xcode</p>
  
  <p>Ideally I want this to run from my Bourne Shell script, I know you can launch automator workflows from there. What is the best approach to achieve this though?</p>