Reputation: 8707
how can i change the Xcode Template files, when i want to create a new File? I searched online but the path to changes these wasn't correct with Xcode 11
I tried these:
~/Library/Developer/Xcode/Templates
~/Library/Developer/Xcode/Templates/File Templates/Source
~/Library/Application Support/Developer/Shared/Xcode/File Templates/
But couldn't find the template files.
Upvotes: 1
Views: 2375
Reputation: 4137
Adding/detailling on Mark's answer:
Xcode path is for me:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates
Target path indeed matches (but Templates folder does not exist), so I did:
cp -fr /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates ~/Library/Developer/Xcode
Now, where are the C++ templates? Hidden in:
/Users/michael/Library/Developer/Xcode/Templates/File Templates/MultiPlatform/Source/C++ File.xctemplate
What has <cstdio>
to do in C++ project template files?? Someone at Apple's side has been sleeping here for some decades.
Anyways, it works but I have duplicated entries now. I tried removing the original folder but it does not work:
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates
But anyways. Just picking the right files works. You can also rename the "C++ File.xctemplate" name... whatever is before "File" seems to work as a label in Xcode.
Alternatively, you can just change the templates directly in /Applications/Xcode.app
but then suffer from having them overwritten after update.
Upvotes: 4
Reputation: 20088
Apple's file templates are inside the Xcode app bundle.
Xcode/Contents/Developer/Library/Xcode/Templates/File Templates
You should not modify the file templates in the Xcode app bundle because you will lose them when you update Xcode. Copy the file templates you want to change to the user file template location.
~/Library/Developer/Xcode/Templates/File Templates
You may have to manually create some of the folders in this path. You may also want to create an additional folder to store your templates to make finding them easier when creating a new file.
After copying the file templates to the user file template location, you can make changes to the files.
Upvotes: 1