On the Renaming of Xcode Projects

One of the FAQs of Xcode is “Why is Save As… disabled for my project file?” Or, put more bluntly, how do you duplicate or rename a project?  It seems such an obvious omission in an ostensibly document-based Mac application.
The motivations to copy or rename a project are clear, but there are several different ones.  Some want to rename the project because Marketing picked a new product name, or because the project with a code name now has a real one.  Some want to archived finished project A and begin project B based on its skeleton.  Some want to fork project A into a new project A-prime to do parallel development.
And at the root is a fundamental confusion about the naming of three different things: your product, the target that builds it, and the project that contains them.  When you create a New Project from the template, Xcode only asks you for one name.  It uses that name  in dozens of different places.
  • It creates a directory with that name to put everything in.
  • It creates a project file wrapper with that name as the basename.
  • It creates a target in the project file with that name.
  • It creates source code files in the project with that basename.
  • It creates auxiliary files, like Info-plists and prefix headers, with that name.
  • It sets the appropriate build settings in the target to point to the auxiliary files.
  • It sets the product name of the target to that name, which propagates to the executable name, to Info.plist settings, etc.
  • In some cases it even creates strings in source files, Info.plist files, and .nib or .xib files with that name, so they appear in your application’s source code or user interface.

This is in many ways a trapdoor operation: one name fans out to many uses.  In some cases the relations are durable (you change the name of the product, and the executable name follows); in others, they’re unlinked (the target name, Info.plist file name, Prefix file build setting value, etc. are all independent).  So it’s crucial to know beforehand what you want to change and why you want to change it, because you may not need to, or want to, change all occurrences of the original name.

For example, do you really want a different project or do you just want to change the name of the application that the project builds?  You can do one, or the other, or both, but keep in mind that you can change the name of the build product (the app that the project generates) without changing the project’s own name. That’s a lot easier in itself.  But let’s walk through the steps of renaming or duplicating a project.

1. Know the scope and reach of the project.

Most Xcode projects have a Project Folder (MyProject) containing a project file wrapper (MyProject.xcodeproj) and the files and directories for the source code.  (Often the build folder is in there too; you can ignore it, perhaps Clean the project before starting to empty it out).  If your project has sources that are peer to the project folder, you will have to take some care to find the total extent of the project.  For example, you may have a MyProject folder, and inside it is a sources folder (src), a documentation folder (docs), and your Xcode project folder (Mac).  The Mac/MyProject.xcodeproj project file refers to ../src/MySourceFile.m to get to its source files.  You need to make sure that MyProject/ contains all the parts of your project, and maybe more importantly, doesn’t contain parts of other projects that would be damaged if you moved or renamed them.

2. Ensure the project’s self-relative integrity.

It helps to make sure that the project doesn’t have any embedded absolute paths.  Try dragging the whole project folder to another directory on the same disk.  If you can open it and nothing turns red, and you can build it, you’re in good shape; all your internal references are project-relative.  If anything turns red, select it, Get Info, find the appropriate file, make sure the Reference Style is Relative to Project (Relative to Enclosing Group is usually good enough, and is the Default).

3. Copy and/or Rename the project folder and the project file.

Just do this in the Finder: change MyProject to MyNewProject and MyProject.xcodeproj to MyNewProject.xcodeproj.  There.  You’re done.

No, you aren’t.  But that’s the minimum: now you can build MyProject and MyNewProject, edit their source files separately, and their builds and indexes won’t interfere with each other.

But that’s often not enough.  If you want MyApp.app to be MyNewApp.app, then you need to do a little more.

4. If desired, change the Product Name in the main target’s build settings.

Open the new project, double-click the main target, choose the Build pane, and type “Product” into the search bubble.  Enter the new app name into the Value column.  That changes the value of PRODUCT_NAME, which is used in a lot of places in the build:

  • the wrapper for the built app, $(PRODUCT_NAME).app
  • the name of the executable inside the wrapper, $(PRODUCT_NAME).app/$(EXECUTABLE_NAME)
  • the executable name in the product’s Info.plist file

So in general you’ll get a new app, and when you build MyProject and MyNewProject, you’ll end up with MyApp and MyNewApp separately, even if you use a common build folder.

Remember that if you have hard-coded your bundle identifier (com.myCompany.myApp) into your source code anywhere, you need to change that in the source when you rename the Product Name.

5. And change all the strings relating to the app name in the source and the .nib or .xib files.

If you’ve changed your application name, you probably have references to it all over your source: in constant strings, in the Info.plist’s Copyright string, in string files, and (for Mac applications) in the title of the second menu in the menu bar in the nib file, the name of the About… item, and the string in the About box.  You should remember to change all of these.  Xcode’s Project Find can help find most of them.

6. For completeness and to reduce confusion, rename source and auxiliary files.

If you’re renaming from a code name to a final name, you may or may not want to keep the source files, class names, etc. as they are with the code name.  If you’re spinning off a different project based on the old one’s source code, you probably want to change them.  The Rename refactoring is your best friend here: select the class names and choose Refactor… and pick the Rename refactoring.  It will change all logical references to that class, and optionally change the file and header file names too.

What it won’t pick up is auxiliary files like MyApp-Info.plist.  You’ll have to rename that manually, and make sure to also change the corresponding Info.plist File build setting in the target.  Same for export files, prefix files, or other non-source files referred to in your Target’s build settings.

A note about Source Code Management

If your code is under the aegis of an SCM system like Subversion, Perforce, cvs, git, Mercurial, etc. you are going to have to manage the SCM effects of every change you make.  For Subversion, Perforce, and cvs, if your project is under SCM control in Xcode, file renames will be executed in the SCM system automatically, except for the renaming of the project file itself.  So in step 3 above, do the rename of the project folder and project file wrapper in the SCM system instead of the Finder, then you can do everything else in Xcode.  If you’re using git or Mercurial, you probably know what you have to do.

If you are spinning off a new application, you should probably export the project from the SCM system first.  This ensures it’s not carrying its SCM metadata with it.  (If you just do a Finder copy of MyProject/, rename it, make changes, and try to check it in, hilarity will ensue.)  If you want to branch the project so that it retains the SCM history to date, but allows you to conduct separate future development on both MyProject and MyNewProject, then you should use the branching tools offered by the SCM system.

So I hope you can see why there isn’t yet a Save As… button in Xcode that does what you mean.  What constitutes “renaming” or “cloning” may mean very different things to very different people, and depending on how thoroughly you’ve embedded the old name in source, filenames, build settings, string constants, etc. you may have a lot of manual work to do in order to achieve the results you want.

Update: This blog post was essentially the design spec for the Project > Rename feature in Xcode 3.2, now available in Snow Leopard.  When you choose Rename, you get a dialog box that previews all the above changes, and you check which ones you want applied.  Kudos to Kerry Hazelgren and Daniel Gobera for excellent implementation of this long-needed feature.



It’ll be nice to get our country back.


There are fundamental decencies at the core of conservatism.  It’s hard to tell in this campaign, as McCain and Palin have synthesized a bizarre ideological stew of McCarthyism, populism, Christian fundamentalism, and militarism that combines the cool judgment of Buck Turgidson with the intellectual rigor of Marge Gunderson. The daily defections of lifelong Republicans from the McCain camp show that the level of alarm and disgust at the present state of the movement is rising.  

The traditional circular firing squad is assembling itself now (which is surprising; they usually wait until December or so).  Conservatives are already talking about how long they’re going to have to spend in exile and on what basis they’ll reconstitute the Republican party and the conservative movement.  They’ll assess whether the core strategy of greed, fear, and religious fundamentalism is still a sound electoral coalition, and what, if any, policies their movement stands for.

I have some suggestions.

First, the Republicans have considered themselves the party of fiscal responsibility for the past century.  The actual economic benefits of their governance and their ability to manage spending has not matched their ideals, but they still have that brand.  Once the current recession ends, it’s likely that a balanced budget and paying down the national debt will be popular positions.  The Republican minority in Congress and Republican candidates in 2010 and 2012 could easily reconnect with their traditional voters through fiscal policy.

Second, the Republicans have always successfully branded the Democrats as the ones who use Big Government To Solve Problems.  One of the problems with the McCain campaign is that he almost entirely abandoned the Reagan “small government” message, and Bush has done nothing but hideously expand both the size and the intrusiveness of the Federal government.  A candidate with a specific plan for cutting or reshaping big programs (such as the GOP Congress and Clinton did with Welfare in the 90s) would get a lot of traction.

Republicans are jingoistic; they are nationalistic; they are passionate about traditional displays of love of country.  In this election cycle that’s been used in an ugly fashion, as a cover for xenophobia and racism.  But it can be used in a positive, Reaganesque way, by a candidate who cleanly separates the power of the country from the power of the government.  Adopting some Libertarian attitudes about governmental power, such as taking a strong stand against NSA eavesdropping, restoring Habeas Corpus, and staying out of the medical and sex lives of citizens could give them a message of being pro-liberty that might work well after a decade of Democratic governance.  

The greatest rise in crime in America in the past decade has not been in the inner cities; it’s been in rural areas, associated with poverty and drugs.  The Republicans used to be the Law and Order party.  Addressing the meth epidemic in rural areas for the purpose of getting dealers off the country roads and reducing crime would resonate as much with rural conservatives as the Democrats’ urban initiatives did with liberals in the 60s and 70s.

Finally, the GOP tapped a deep wellspring of populism with the Sarah Palin candidacy.  Combined with the crippling fall of the financial titans and the avaricious wealth those same titans looted from their firms on their departure, the GOP could have been well positioned to defend the “little guy” against the fat cats.  Unfortunately, McCain’s great personal wealth and the traditional big-donor funding base of the GOP made this message fundamentally insincere, with Palin’s $150,000 clothes budget being the most egregious example of the tone-deafness of the actual campaign.  I expect the next GOP cycle will follow the Obama model and raise extremely large amounts of money from millions of small rural and church-based donors, and may actually be able to do some token forays at executive compensation.

I’m afraid that the Republicans are going to have to abandon some of the elements that elected Bush twice.  Fear of Muslims and terrorists is just coming across as simple, stupid racism.  The social-issues package of anti-abortion, anti-gay-marriage, anti-evolution policies just looks bigoted and ignorant.  And while a pro-business bias has always been a Republican hallmark, if the burgeoning business of 2010 is alternative energy, they’re going to have to drop the dispute about climate change and the environment, because that will be the engine of commerce of the next decade.

A Republican party and conservative movement based on efficient, inexpensive government; sound fiscal management; laws and regulations that maximize personal liberty; focus on catching criminals rather than terrorists; and supporting the needs of the middle class over those of the wealthy would be an all-new party with solid connections to its history, but a great deal of distance from what we have seen in 2000–2008.


I have to remember, often, that Obama is right, and I’m often wrong, and that’s why he’s going to be President.  

Like so many on both sides, I want my candidate to land solid hits in the debates, below the belt if possible.  And Wednesday seems primed for it.  McCain has been accusing Obama of lying about his relationship with William Ayers, and Obama has quite correctly pointed out that McCain has said that in speeches and TV commercials but not to his face.  He’s essentially called McCain a coward.  

And McCain’s own supporters are losing patience with his reluctance to throw a punch.  Last time he promised to “get ’im.” And he made no mention of Ayers, Wright, Rezko, or Acorn.  Again this week he’s promised to “whip his a**” but that, too, is probably cowardly bluster.

Should Obama actually call him on it?  

Part of me really, really wants to see the famous McCain temper come out on national teevee, and hear his honest characterization of his African-American fellow Senator.  I think Obama knows the exact few, well-chosen words to say to just make him pop at the seams.

But he won’t, because it’s un-Presidential.  It’s not fitting. It might alienate people who are sympathetic to him but still slightly afraid of him.  And it is completely unnecessary.  McCain is making a hash of his Presidential run all by himself (just as Hillary Clinton did); he needs no push from Obama to complete his descent into blithering irrelevance.  

All Obama needs to do is stay cool, present his case, walk in his own shoes, and let lesser men like McCain use fear, anger, and frustration.  It is not only the way to win, but it’s the way to win over America.


Though nobody can condone the jeers, name-calling, and intolerant language coming from McCain/Palin rallies, I think the characterization of them as “violent mobs” is overblown. This venting of raw emotion was predictable and, while distasteful, is not the threat to the peace that some are making it out to be.

It could change, of course. If Obama departs from his cool demeanor and actually acts threatened by the rhetoric; if McCain continues to waffle and stoke the anger; if we hear “Drill, Baby, Drill” metastisize into “Kill, Baby,Kill” then we’ve crossed the line from (un)civil discourse into mob mentality.  Then there will be real danger.

But there’s really no percentage in saying that line has been crossed when it hasn’t.  I don’t want to claim false equivalencies, but I’ve called Bush a war criminal and called for his impeachment.  But my own rabble-rousing is mostly issues-based and a result of his actions.  I don’t hate him because he’s Republican, or Texan, or a snide little shit who’s deeply unserious about the dignity of the Presidency.  It’s his war, his giveaways of our money to the ultra-rich, his self-dealing, and his lies that I detest.  This is palpably different than what conservatives fear about Obama: they fear his socialism, his naïevete, his liberalism, his radicalism, and (basically) that he’s going to turn the country over to the enemies who attacked us on 9/11, with whom he is said to be in alliance.  That’s not policy, that’s demagoguery,  and it is so ungrounded in reality that I can only assume that a lot of it is an elaborate euphemism for “black.”

The mindless character assault on Obama can and should be decried on its own merits, without fearmongering that it contains the risk of something worse.  This isn’t 1968 or 1924.  We won’t have cities burning this time around, one way or another.  The ugliness we see is not new; it’s always been there, it’s just now out in sunlight, and exposing it for what it is is a good thing.  We don’t need to exaggerate its danger.


Last night’s debate got astonishingly high ratings, which is excellent it was one of the better national political debates in recent history.

The Governor did a fine job.  Yes, she’s had five weeks to go from zero to National Political Figure, and she faked it well enough.  In an America not in crisis, and with a pre-Cheney, pre-Gore definition of the job of Vice President, and a more physically robust top of the ticket, her effort would have certainly been enough to tread water, and perhaps even to win against a weaker opponent.  

The fact that she hardly answered a single question and instead turned most questions toward her pre-canned answers was typical for national political debates.  Evasion, redirection, and finesse are par for the course, and she did it well.

Getting past personal style, winks, gaffes, there was actually a fair amount of substance to the debate.  The triangulation where both candidates tried to contrast with each other while both distanced themselves from the Bush Administration was fascinating.

When quizzed as to who was responsible for the mortgage meltdown, both sides pointed at the banks.  The current meme in the right wing is that it was irresponsible low-income borrowers (and their liberal advocates).  But while that argument might move the base, it plays less well with the undecided voters than the populist “blame Wall Street greed”  angle.  Palin took that tack, and ended up on the losing side of the regulatory argument.  In this fight a Republican candidate is playing well against type when calling for increased Government intervention in and oversight of the free market.

Similarly, when cornered on gay marriage, both candidates got trapped in ideological dogma versus realpolitik.  Biden was forced to dance around the fact that Democrats are full-throated for gay rights, but have not yet fully accepted gay marriage; and Palin was trapped into acknowledging that the Republican opposition to gay marriage is not ”intolerant” and at least begrudgingly accepts gay rights as civil rights.  This is an amazing turning point for America, in a very short period of time, and indicates to me that the battle for universal gay marriage is nearly won.

Finally, I’m very pleased that the focus on sexual politics was almost nonexistent.  If you recall Ferrarro’s run in 1984, she was overtly asked whether having a female vice president would show weakness to the Warsaw Pact nations.  There was no such piffle this time, even considering the Republican candidate’s brief and superficial exposure to world affairs.  The question of her ability turned on the facts of her experience and knowledge, not on her sex.  Just as with the complete absence of racial dynamics in the Presidential debate, this is a great moment for liberalism.  There will be sexists in the electorate, and there will be racists, but the race and sex of the candidates are not issues in themselves.

That doesn’t mean that we’re now a sex-blind, race-blind nation, far from it. But I was delighted that the most notable, moving moment of the entire debate focused entirely on sexual politics and was won decisively by Biden:

He was responding to Palin’s personal narrative with his own.  “The notion that somehow because I’m a man I don’t know what it’s like to raise two kids alone… I don’t know what it’s like to have a child who’s… who’s not gonna make it… I understand. I understand.”  I nearly cried.  I still do, watching that again.  The loss of a spouse or child is one of the most powerful fears that humans have, and he experienced that fear, and still does.  And he showed it in a deeply human, deeply connecting way: he used a euphemism and choked up.  In a way that Palin doesn’t when talking about Trig, and that McCain doesn’t when talking about his imprisonment in Viet Nam.  

Watch the CNN response dials.  The men go way up, and the women peg the needle.  Where Palin talks about being a parent connects her with the voters as if it is something novel in politics and proprietary to mothers, Biden just connects, and snatches the issue from her.  “The notion that somehow because I’m a man” is the strongest attack on sexism that we’ve seen in this campaign so far, and it came from the white guy, and it won the day.

Update: Seventy-one million households tuned in. That’s astonishing. And I’m informed that the rules prohibited prepared notes, though both candidates read from their note pads throughout the debate.


There are plenty of good topics in the current political cycle and Presidential race.  And as usual there’s a Silly Season of fake issues that don’t matter in legitimate political discourse.  As much fun as it might be to score these points, let’s get real, people.  

We are the Board of Directors of the United States of America, and every four years we have to hire a CEO.  Do we really want some of these questions to bear heavily on the interview process?

  •  “He/she uses a teleprompter.” So what. Every business, entertainment, and political figure does. Rehearsed versus spontaneous oratorical ability is a test of showmanship, but not a litmus test of knowledge or ability.
  • The gaffe.  It is extremely rare that a gaffe truly betrays bigotry or ignorance, but everybody wants to make it out as if it does.  Chavez doesn’t rule a mideast country. FDR wasn’t president in 1929. There are not 57 states.  To judge a misstatement, I wait until it is confirmed and discussed, to see if it represents actual thinking and policy.  Relentless public speaking is an extremely stressful, adrenaline-infused endeavor, and people say dumb things.
  • Vanity and ambition.  These people are not running for successor to Saint Theresa.  To want to be President of these United States requires massive self-assurance, ego, and to have preened for public appearance your entire life.  Please.  Shoes, haircuts, makeup: it comes with the territory.
  • Reckless supporters.  I have never considered guilt by association to be a valid argument, but the ongoing Festival Of Throwing Supporters Under the Bus has been beyond ridiculous.  While a candidate can control who speaks for the campaign, it ought to be obvious that the surrogate’s views are not necessarily the candidate’s, and the views of unaffiliated supporters are just not relevant at all.
  • Your Crazy Pastor.  Really, no good can come of looking at what church a politician attends.  Ronald Reagan, probably the most revered Conservative of the last half-century, attended church sporadically if at all.  We knew nothing of the pastors of Nixon, Ford, Carter, GHWB, or Clinton, and that was fine.  We have no idea what church McCain attends, and we should really not care about the rites at either Palin’s or Obama’s.
  • Family.  Off-limits except when the campaign places them in the arena.  Children, especially adult children, are not sole products of the parent’s responsibility; siblings, parents, and other relatives even less so.  Judging a candidate’s political management by their family management is folly.
  • Big Contributors.  Somebody once said that anybody who gives you a percentage without telling you the numerator and denominator is lying.  Similarly, absolute dollar amounts allegedly to have been given by contributors may sound large, but out of the context of a) how much they gave others and b) what percentage of the campaign’s income they represent is misleading.  

I’m not enamored with some of Obama’s recent ads.  Foreign cars? Rush Limbaugh an immigrant-hater? Please.  McCain’s have been far worse, with outright lies and fearmongering.  We have plenty to argue about this round: exiting from Iraq, dismantling the castles in the sky the credit industry built, not to mention what to do about the now obvious crimes of the Bush Administration (which has not been a campaign topic.)  Let’s get out of the silly season and on with the election.