Setting copyright statement on a per-project basis

2019-01-25 10:21发布

问题:

I'm an independent developer working primarily with iPhone applications, and I'm currently engaged in several different projects. Some are for myself, and others are for one of a number of clients. Because of this, I'd like to have a way to have Xcode set the copyright notice at the top of each source file on a per-project basis.

I've seen these questions, and I understand that Xcode by default pulls the organization on the user's Address Book contact card for the copyright statement, and that you can change the property either in the Address Book or on the terminal. What I'm looking for is a setting that lets that default be changed for each project, and has Xcode remember the copyright assignee (i.e. I don't want to have to change my Address Book organization entry each time I switch projects).

回答1:

Upgrade to Xcode 3.2, which now has a project setting for organization name.



回答2:

You can change the organization Xcode currently uses by issuing the following command in Terminal:

defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME = "Some Company Name"; }'

You can then create scripts that switch the current company for Xcode.



回答3:

You might want to make custom templates. Have a look at this question: Change templates in Xcode



回答4:

look in text macros section:

Change the text used for the header of a new file by setting the value of the FILEHEADER text macro.

The example shows the default definition for the macro. Other macros are included in the definition by including three underscore (___) characters before and after the name of the macro. The line with COPYRIGHT is included only if an organization name is set.

//  ___FILENAME___
//  ___PACKAGENAME___
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//  ___COPYRIGHT___
//