Created
November 1, 2018 00:31
-
-
Save gdbinit/8282fe8c6b9bc7addb53470615e870ff to your computer and use it in GitHub Desktop.
Xcode Command Line tools template with /usr/local folders in search paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copy folder Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate folder | |
to ~/Library/Developer/Xcode/Templates/Custom/ | |
Modifity the plist to the following. Scroll down when choosing new project template and should be there in Custom area. | |
The trick is this: | |
<key>Project</key> | |
<dict> | |
<key>SharedSettings</key> | |
<dict> | |
<key>HEADER_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/include</string> | |
</array> | |
<key>LIBRARY_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/lib</string> | |
</array> | |
</dict> | |
</dict> | |
References: | |
https://help.apple.com/xcode/mac/10.1/#/itcaec37c2a6?sub=deved642222b | |
https://www.telerik.com/blogs/how-to-create-custom-project-templates-in-xcode-7 | |
https://useyourloaf.com/blog/creating-custom-xcode-project-templates/ | |
$ cat TemplateInfo.plist | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Kind</key> | |
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string> | |
<key>Identifier</key> | |
<string>com.apple.dt.unit.commandLineTool</string> | |
<key>Ancestors</key> | |
<array> | |
<string>com.apple.dt.unit.base</string> | |
<string>com.apple.dt.unit.osxBase</string> | |
</array> | |
<key>Concrete</key> | |
<true/> | |
<key>SortOrder</key> | |
<integer>50</integer> | |
<key>Description</key> | |
<string>This template creates a command-line tool.</string> | |
<key>Targets</key> | |
<array> | |
<dict> | |
<key>ProductType</key> | |
<string>com.apple.product-type.tool</string> | |
<key>TargetIdentifier</key> | |
<string>com.apple.dt.commandLineToolTarget</string> | |
<key>BuildPhases</key> | |
<array> | |
<dict> | |
<key>Class</key> | |
<string>Sources</string> | |
</dict> | |
<dict> | |
<key>Class</key> | |
<string>Frameworks</string> | |
</dict> | |
<dict> | |
<key>Class</key> | |
<string>CopyFiles</string> | |
<key>DstPath</key> | |
<string>/usr/share/man/man1/</string> | |
<key>DstSubfolderSpec</key> | |
<string>0</string> | |
<key>RunOnlyForDeploymentPostprocessing</key> | |
<string>YES</string> | |
</dict> | |
</array> | |
</dict> | |
</array> | |
<key>Options</key> | |
<array> | |
<dict> | |
<key>Identifier</key> | |
<string>languageChoice</string> | |
<key>Name</key> | |
<string>Language:</string> | |
<key>Description</key> | |
<string>The primary implementation language for the command-line tool</string> | |
<key>Default</key> | |
<string>Swift</string> | |
<key>Type</key> | |
<string>popup</string> | |
<key>Values</key> | |
<array> | |
<string>Swift</string> | |
<string>Objective-C</string> | |
<string>C++</string> | |
<string>C</string> | |
</array> | |
<key>Units</key> | |
<dict> | |
<key>C</key> | |
<dict> | |
<key>Project</key> | |
<dict> | |
<key>SharedSettings</key> | |
<dict> | |
<key>HEADER_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/include</string> | |
</array> | |
<key>LIBRARY_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/lib</string> | |
</array> | |
</dict> | |
</dict> | |
<key>Nodes</key> | |
<array> | |
<string>main.c:comments</string> | |
<string>main.c:include</string> | |
<string>main.c:main:content</string> | |
</array> | |
<key>Definitions</key> | |
<dict> | |
<key>main.c:include</key> | |
<string>#include <stdio.h> | |
</string> | |
<key>main.c:main:content</key> | |
<string>// insert code here... | |
printf("Hello, World!\n"); | |
return 0; | |
</string> | |
</dict> | |
</dict> | |
<key>C++</key> | |
<dict> | |
<key>Nodes</key> | |
<array> | |
<string>main.cpp:comments</string> | |
<string>main.cpp:include</string> | |
<string>main.cpp:main:content</string> | |
</array> | |
<key>Definitions</key> | |
<dict> | |
<key>main.cpp:include</key> | |
<string>#include <iostream> | |
</string> | |
<key>main.cpp:main:content</key> | |
<string>// insert code here... | |
std::cout << "Hello, World!\n"; | |
return 0; | |
</string> | |
</dict> | |
</dict> | |
<key>Objective-C</key> | |
<dict> | |
<key>Project</key> | |
<dict> | |
<key>SharedSettings</key> | |
<dict> | |
<key>HEADER_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/include</string> | |
</array> | |
<key>LIBRARY_SEARCH_PATHS</key> | |
<array> | |
<string>/usr/local/lib</string> | |
</array> | |
</dict> | |
</dict> | |
<key>Nodes</key> | |
<array> | |
<string>main.m:comments</string> | |
<string>main.m:include</string> | |
<string>main.m:main:content</string> | |
</array> | |
<key>Definitions</key> | |
<dict> | |
<key>main.m:include</key> | |
<string>#import <Foundation/Foundation.h> | |
</string> | |
<key>main.m:main:content</key> | |
<string>@autoreleasepool { | |
// insert code here... | |
NSLog(@"Hello, World!"); | |
} | |
return 0; | |
</string> | |
</dict> | |
</dict> | |
<key>Swift</key> | |
<dict> | |
<key>Project</key> | |
<dict> | |
<key>Configurations</key> | |
<dict> | |
<key>Debug</key> | |
<dict> | |
<key>SWIFT_OPTIMIZATION_LEVEL</key> | |
<string>-Onone</string> | |
</dict> | |
<key>Release</key> | |
<dict> | |
<key>SWIFT_COMPILATION_MODE</key> | |
<string>wholemodule</string> | |
<key>SWIFT_OPTIMIZATION_LEVEL</key> | |
<string>-O</string> | |
</dict> | |
</dict> | |
</dict> | |
<key>Targets</key> | |
<array> | |
<dict> | |
<key>SharedSettings</key> | |
<dict> | |
<key>SWIFT_VERSION</key> | |
<string>___DEFAULTTOOLCHAINSWIFTVERSION___</string> | |
</dict> | |
</dict> | |
</array> | |
<key>Nodes</key> | |
<array> | |
<string>main.swift:comments</string> | |
<string>main.swift:include</string> | |
<string>main.swift:main:content</string> | |
</array> | |
<key>Definitions</key> | |
<dict> | |
<key>main.swift:include</key> | |
<string>import Foundation | |
</string> | |
<key>main.swift:main</key> | |
<dict> | |
<key>Beginning</key> | |
<string></string> | |
<key>End</key> | |
<string></string> | |
</dict> | |
<key>main.swift:main:content</key> | |
<string>print("Hello, World!") | |
</string> | |
</dict> | |
</dict> | |
</dict> | |
</dict> | |
</array> | |
<key>Definitions</key> | |
<dict> | |
<key>*:main</key> | |
<dict> | |
<key>Beginning</key> | |
<string>int main(int argc, const char * argv[]) {</string> | |
<key>End</key> | |
<string>}</string> | |
<key>Indent</key> | |
<integer>1</integer> | |
</dict> | |
</dict> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment