Reputation: 2559
I can't figure out how can I edit a Markdown file in Xcode. The file appears to be rendered in a read only mode. Is there any setting that allows me to edit Markdown files in Xcode?
I'm trying to add note to apple's sample project's README.md https://developer.apple.com/documentation/pencilkit/drawing_with_pencilkit
Upvotes: 8
Views: 6402
Reputation: 17724
As of Xcode 13.2.1 this is still broken. Here's an ugly workaround:
Project.xcodeproj/
directory named .xcodesamplecode.plist
and copy into it the following content:<?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">
<array/>
</plist>
Step 1 will cause Xcode to render README.md
as markdown in read-only mode.
To edit the markdown, close all windows and/or tabs in which README.md
is visible.
Rename README.md
to anything else with a .md
suffix, for example editable.md
.
Now open editable.md
and it will be editable.
When finished editing close all editable.md
windows and rename it back to README.md
.
File a bug report with Apple.
Upvotes: 2
Reputation: 2708
For xcode 12:
Right inspector panel, change Type to be: swift source
Close editor
Right click file, 'open as source code' again
Upvotes: 4
Reputation: 58099
If your .md file is uneditable, you're likely not in Source Code mode. Right click on the file in the Project navigator (the left panel on your screenshot, if it's not visible, press Cmd+1) and select Open As/Source Code.
If you want to edit .md files in an Xcode project downloaded from the Apple Developer site, delete these two files in the project folder before opening the project:
Configuration/SampleCode.xcconfig
[project name].xcodeproj/.xcodesamplecode.plist
Here's how too access the second file:
Upvotes: 13