Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4: How can I reference project variables/macros in a file template?

Tags:

xcode

xcode4

Ok, so, I've got a relatively complex project template hierarchy that defines code style related macros and variables (curlies on same or new line, indentation, etc). My code style template will probably give more context

Works great when generating a project.

However, I'm not seeing a clear path to reusing these macros/variables when generating new files after the project has been built. Findings so far:

  • macros and variables defined at the project level are not substituted when referenced in a file template

  • popup option definitions in file templates do not seem to support complex definitions (e.g. defining a macro when the drop down is in a given state)

  • project variables do appear to become defaults for options of the same name in the file template wizard

  • file templates don't appear to be able to define other templates as ancestors

Any ideas?

like image 664
Nevir Avatar asked Oct 24 '12 04:10

Nevir


1 Answers

Enter the following line: defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ "ORGANIZATIONNAME" = "Your Company Name" ; }' into a Terminal window, replacing "Your Company Name" with whatever you choose. You can also open the file at ~/Library/Preferences/com.apple.Xcode in "Property List Editor" and insert your company name as a string value for the key "ORGANIZATIONNAME" under the dictionary "PBXCustomTemplateMacroDefinitions". You may need to create "PBXCustomTemplateMacroDefinitions" at the top level if it doesn't already exist.

like image 139
Ashesh Vidyut Avatar answered Nov 08 '22 23:11

Ashesh Vidyut