View .svg files as text in Xcode?

2019-05-04 10:42发布

I use xcode for my editing environment. I'm editing a few .svg files on a project, and I need xcode to open the files as text. Rather, it renders the documents as svg. While I appreciate how this helps most of the time (working and view svg's as such) its a hinderance to me right now.

Does anyone know how to tell xcode to treat a .svg file as regular text?

标签: xcode svg
4条回答
可以哭但决不认输i
2楼-- · 2019-05-04 11:09

It doesn't appear you can view source for .svg in Xcode, I'd suggest using something like vim or TextEdit.app, both of which are built-in to your system.

查看更多
够拽才男人
3楼-- · 2019-05-04 11:11

In reply to mojuba and using the file inspector, I'm not sure this is what makes the difference but I have Location set to 'Relative to Workspace' (my workspace file and source files are in the same directory) and the settings do survive restarting Xcode. I'm using Xcode 4.2.1.

查看更多
叼着烟拽天下
4楼-- · 2019-05-04 11:15

There is a simple way of changing the editor for any file type, particularly SVG in Xcode 5 (I believe this was possible in previous versions too):

  1. Right click on the file in your Project Navigator, choose "Show File Inspector"
  2. In File Inspector change the Type field to, for example, XML:

enter image description here

You will have to do it for each SVG file though. Seeing the graphical preview of your SVG is still possible via right click in Project Navigator -> Open As -> Preview.

查看更多
一纸荒年 Trace。
5楼-- · 2019-05-04 11:18

Renaming to .xml (make sure Finder isn't hiding the real extension by editing the name in the info panel) did work for me — in my case the SVG wasn't part of a project and so @mojumba's trick did not work.

查看更多
登录 后发表回答