This is more of a note to self about upgrading Xcode and XVim. XVim2 is a “Vim plugin for Xcode”. A few years ago, Apple released an Xcode Extensions API and broke a lot of third-party plugins by code-signing Xcode and not allowing plugins by plugins. As far as I know, creating a vim plugin using that API is currently impossible, because it’s very limited, so we continue using XVim2. Or you could use the much nicer AppCode with the official IdeaVim plugin if the IDE works with your project (it’s gotten much better last year).
So when I upgraded to Xcode 11.3.1, here’s what I did.
Replacing Xcode
Removing the previous version and replacing it with the newer one:
Launch Xcode, agree to the useless EULA, let it install some stuff. In a repo with an Xcode project, run:
12
$ xcodebuild -list > /dev/null
2020-02-12 09:46:34.850 xcodebuild[49845:1449963][MT] PluginLoading: Required plug-in compatibility UUID BAB79788-ACEE-4291-826B-EC4667A6BEC5 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin' not present in DVTPlugInCompatibilityUUIDs
Updating XVim2
Enter the cloned xvim2 repo:
1234
$ z xvim
$ g pull
$ make
<… build logs …>
Launching Xcode says:
The “XVim2.xcplugin” code bundle is not provided by Apple. Loading code not provided by Apple can have a negative effect on the safety and stability of Xcode or related tools.
$ codesign -dvv /Applications/Xcode.app
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier=com.apple.dt.Xcode
Format=app bundle with Mach-O thin (x86_64)Authority=Software Signing
Authority=Apple Code Signing Certification Authority
Authority=Apple Root CA
…
$ codesign -v -f -s XcodeSigner --timestamp=none /Applications/Xcode.app/Contents/MacOS/Xcode
/Applications/Xcode.app/Contents/MacOS/Xcode: replacing existing signature
/Applications/Xcode.app/Contents/MacOS/Xcode: signed app bundle with Mach-O thin (x86_64)[com.apple.dt.Xcode]$ codesign -dvv /Applications/Xcode.app/Contents/MacOS/Xcode
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier=com.apple.dt.Xcode
Format=app bundle with Mach-O thin (x86_64)Authority=XcodeSigner
Signed Time=12. Feb 2020 at 09:58:12
…
Launch Xcode, now XVim is available!
Resigning xcodebuild
It’s the step that is missing from the guide. Why is it necessary? If you run xcodebuild, it will complain about XVim too:
123456
$ xcodebuild -list > /dev/null
2020-02-12 09:51:29.444 xcodebuild[51011:1458810] WARNING: Failed to load plugin at path: "~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin", skipping. Error: Error Domain=NSCocoaErrorDomain Code=3587"dlopen_preflight(~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2): no suitable image found. Did find: ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2: code signature in (~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2: stat() failed with errno=1"UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2, NSDebugDescription=dlopen_preflight(~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2): no suitable image found. Did find:
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2: code signature in(~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2: stat() failed with errno=1, NSBundlePath=~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin, NSLocalizedDescription=The bundle “XVim2” couldn’t be loaded because it is damaged or missing necessary resources.}
Well, the plugin is code-signed, but the code-signing developer teams don’t match. So resigning it is: