Xcode Tips and Tricks - Part 3: Preferences and | Ray Wenderlich

Learn how to use Markdown for README files and create custom file headers.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3199-xcode-tips-and-tricks/lessons/3
1 Like

Very helpfull!

I found a quicker shortcut for the Shit+Command+A, just Hold Command and click the method name, it will display all actions :slight_smile:

1 Like

@giguerea - good one :]

1 Like

Great functionality, however I am getting a “Rename Failed” message, do you have any idea why?

@gaboalvarado - it’s new.

I keep pressing too quickly and only half of them get renamed

1 Like

@caroline How do I add xcshareddata and the plist file that you mentioned ?

@caroline Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @mausam

First create the plist file in Xcode. File Menu \ New File; scroll down and choose the Property List template under Resource. Name the file IDETemplateMacros and save it.

Still in Xcode, open the new file and Ctrl-click Root. Choose Add Row and name the new row key FILEHEADER. Change the Value to your header text. I find it easier to copy and paste from elsewhere, as Xcode only gives you one line to look at.

For example:

/
/* This is header text
That will go over many lines
*/

Don’t put /* on the first line, because Xcode creates an extra // at the start of the first line.

In Finder, locate your project file AppName.xcodeproj.

Ctrl-click this file and choose Show Package Contents from the menu.

Now you can create the new folder xcshareddata by pressing Shift-Cmd-N (or ctrl-click and choose New Folder).

In Xcode, Ctrl-click IDETemplateMacros.plist and choose Show in Finder. Drag your IDETemplateMacros.plist file from the new Finder window to the xcshareddata directory in Finder and delete the one in Xcode

Now choose File Menu \ New File and create a new Swift File. Your header text should be at the top of the new Swift file.

2 Likes

Thank you so much @caroline :smile:

This topic was automatically closed after 166 days. New replies are no longer allowed.

They video was very nice. Thanks
It seems like markdown is nice but kinda not worth it. Why not just drop a text edit file into the project and you have wysiwyg editing and not burden yourself learning a side mark down language.

@caroline Can you please help with this when you get a chance? Thank you - much appreciated! :]

@artnyoga - yes, you could drop a text edit file into the project, but that is:

a. non-standard
b. if you want text formatting, eg bold, then the text edit file will require non-printable characters. The point of markdown is that all characters are printable, but a markdown editor will recognize a certain sequence of characters.

I have found knowing markdown to be useful not only in Xcode. Github’s license and readme files are markdown files. Slack uses a form of markdown - to put in bold in a Slack response, you surround with * and italic is _.

If you want to document your methods in Xcode, or write shareable playgrounds, you’ll need markdown: https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_markup_formatting_ref/index.html

To be honest, I didn’t learn markdown until I needed it. If you learn on a need-to-know basis, then the knowledge tends to stick better, but if you’re on a deadline, then it takes that extra amount of time to learn it.

Edit:
Even this forum uses a form of markdown. You can use the formatting icons, but I tend to just type in the characters without having to click the icons. Much easier :slight_smile:

bold is **bold**
italic is _italic_

1 Like

Caroline,

I just gripe because I spent 3 hours and learn it then come 3 months later and forget it. I am sure it useful when using it all the time.

Thanks,

Art