Syntax Highlighting Broken in Xcode 11
JakeTorres opened this issue Β· 24 comments
installed GraphQL.ideplugin in Xcode11, can't get highlight now
Yes. I got the same problem on Xcode 11 from App Store
+1
Looking into this - it seems like at least one other syntax highlighting plugin and is reporting that while Xcode is loading the plugin, it's not actually using the syntax highlighing spec included. :(
Same
Yeah looks like they changed a whole mess of stuff around this in Xcode 11. Whee!
I'm working on finding a better workaround, but here's a temporary one based on this that you can use if you feel comfortable with messing with things within the Xcode path (I generally don't, which is why this is a temporary workaround and not a permanent fix):
-
Move the
GraphQL.xclangspec
file from~/Library/Developer/Xcode/Specifications
to/Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications
-
Add the following as the file
Xcode.SourceCodeLanguage.GraphQL.plist
in/Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageMetadata
:
<?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>commentSyntaxes</key>
<array>
<dict>
<key>prefix</key>
<string>/*</string>
<key>suffix</key>
<string>*/</string>
</dict>
<dict>
<key>prefix</key>
<string>//</string>
</dict>
</array>
<key>conformsToLanguageIdentifiers</key>
<array>
<string>Xcode.SourceCodeLanguage.Generic</string>
</array>
<key>fileDataTypeIdentifiers</key>
<array>
<string>com.netscape.javascript-source</string>
</array>
<key>identifier</key>
<string>Xcode.SourceCodeLanguage.GraphQL</string>
<key>isHidden</key>
<false/>
<key>languageName</key>
<string>GraphQL</string>
<key>languageSpecification</key>
<string>xcode.lang.graphql</string>
<key>supportsIndentation</key>
<true/>
<key>allowWhitespaceTrimming</key>
<true/>
<key>requiresHardTabs</key>
<false/>
<key>indentationTriggers</key>
<array>
<string>{</string>
<string>}</string>
</array>
</dict>
</plist>
- Restart Xcode.
I've found that this works, but there's 100% got to be a better way to do this which does not involve shoving stuff into Xcode's path.
Thanks for digging on this, @designatednerd. I wonder if xCode has plans to add GraphQL as an officially supported language in the editor and the file template menus, or if there's some sort of Apple vs Facebook beef that would slow that from happening.
Hopefully they've just changed where you can add this stuff from the ~/Library
path and forgotten to update the docs. I don't think it's an Apple vs. FB thing, Apollo isn't affiliated with FB, nor are a number of other open-source GQL projects.
I suspect it probably has more to do with the change to using Language Server Protocol with Swift, but that's based on generally following stuff rather than any actual knowledge. π
Filed a Feedback/Radar to try and get some info from Apple on this.
I tried it and it is OK according to the method you provided.
1 Move the GraphQL.xclangspec file from ~/Library/Developer/Xcode/Specifications to /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications
Add the following as the file Xcode.SourceCodeLanguage.GraphQL.plist in /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageMetadata:
@designatednerd Would you be interested in a PR that adds a flag to setup.sh so users could opt-in to this workaround with a command like ./setup.sh --embed-in-xcode /Applications/Xcode-11.app
or would you rather avoid that because of the fragile nature?
Appreciate the offer, but b) - I'd rather avoid it because of the fragile nature.
Not working in Xcode 11.1
Unfortunately I have not received any response from Apple about this yet, so this should be considered broken for any minor point release of Xcode 11. π
Didn't Apple stop supporting plugins some time ago, and favour Xcode Extensions as the way to do things like this now?
Any plans to port these syntax highlighting features to an Xcode Extension any time soon - I would imagine that to be the long term fix for this?
syntax highlighting features
I don't believe syntax highlighting is a feature of an extension.
@gsp100677 You're correct that they mostly stopped supporting plugins when Xcode 8 came out. Unfortunately Xcode extensions can't do any kind of syntax highlighting - they only really permit you to examine one file at a time and make adjustments to its contents. (If you're bored I did a a whole talk on this three years ago, and unfortunately very little has changed since then).
There's an extremely limited (and undocumented) subset of things that Xcode plugins can still do, but one of them is registering file types. If you look at the only file besides the Info.plist
in the plugin, you'll see it's basically telling Xcode that it should look at files with the extension .graphql
as...GraphQL files! There's a similar plugin that does the same thing for Kotlin as well.
The problem at the moment is that @koenpunt is correct - syntax highlighting is supported through a separate, also undocumented API, the one that uses the .xclangspec
file. Previously, if you copied the .xclangspec
to ~/Library/Developer/Xcode/Specifications/
, voila, anything recognized as a GraphQL file (which it would be after adding the plugin) would get GraphQL syntax highlighting. This piece is what broke from Xcode 10 -> 11, and what I'm waiting to hear back from Apple on to see if they intend to restore the ability to recognize this from a folder that isn't part of Xcode's path.
Again, you can use this workaround if you feel comfortable mucking around in Xcode's path.
Hope that helps explain the structure and the problem a bit better!
For the people coming to this issue trying to find a solution for Xcode 11.2.1:
- Do this workaround
- Within the
GraphQL.ideplugin
>Info.plist
file, add the following string valueA74FBA51-FFEA-4409-B976-6FC3225A6F64
in theDVTPlugInCompatibilityUUIDs
section.
You should have a file that looks like this:
<?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>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIdentifier</key>
<string>com.apollographql.xcode.graphql</string>
<key>CFBundleName</key>
<string>GraphQL Xcode Plug-in</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>DVTPlugInCompatibilityUUIDs</key>
<array>
<string>8A66E736-A720-4B3C-92F1-33D9962C69DF</string>
<string>65C57D32-1E9B-44B8-8C04-A27BA7AAE2C4</string>
<string>DA4FDFD8-C509-4D8B-8B55-84A7B66AE701</string>
<string>E0A62D1F-3C18-4D74-BFE5-A4167D643966</string>
<string>DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C</string>
<string>CA351AD8-3176-41CB-875C-42A05C7CDEC7</string>
<string>DF11C142-1584-4A99-87AC-1925D5F5652A</string>
<string>89CB8A86-8683-4928-AF66-11A6CE26A829</string>
<string>C3998872-68CC-42C2-847C-B44D96AB2691</string>
<string>B395D63E-9166-4CD6-9287-6889D507AD6A</string>
<string>EE23884D-A5C0-4163-94CF-DBBF3A5ED8D6</string>
<string>426A087B-D3AA-431A-AFDF-F135EC00DE1C</string>
<string>8B9F56A7-4D8B-41AA-A65D-D4906CDF1539</string>
<string>D7881182-AD00-4C36-A94D-F45FC9B0CF85</string>
<string>72F7D751-F810-43B8-A53F-1F1DFD74FC54</string>
<string>B89EAABF-783E-4EBF-80D4-A9EAC69F77F2</string>
<string>2FD51EF8-522D-4532-9698-980C4C497FD1</string>
<string>92CB09D8-3B74-4EF7-849C-99816039F0E7</string>
<string>A74FBA51-FFEA-4409-B976-6FC3225A6F64</string>
</array>
<key>XCPluginHasUI</key>
<false/>
</dict>
</plist>
FYI I've used this command line to get the UUID
(source):
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
Hey @jbouaziz - that UUID was added to this repo a while back - it's possible you have an older version of the plugin though.
Hello, I did the following but the highlighting still doesn't workοΌ
Xcode Version 11.2.1 (11B500)
1 Move the GraphQL.xclangspec file from ~/Library/Developer/Xcode/Specifications to /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications
2.Add the following as the file Xcode.SourceCodeLanguage.GraphQL.plist in /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageMetadata:
Although it does not affect, it is always a difficult thing
@BecomerichAsun do you have the most recent version of the info.plist that has the 11.2 UUID in it locally?
Is it still broken on 11.3?
Yep - not seeing any indication this is going to get fixed anytime soon, so I will look at making the dirty hack official π
Opened PR #26 to address this, gonna leave that up til the end of the day for comment then merge it if there are no objections.
Dirty hack is now in. Closing this out - if you run into problems, please open a new issue.