KISS 🇺🇦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Upgrading Xcode and XVim

| comments

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:

1
2
3
4
5
$ sudo rm -rf /Applications/Xcode.app
$ mv /Applications/Xcode{1131,}.app
$ xcodebuild -version
Xcode 11.3.1
Build version 11C505

Launch Xcode, agree to the useless EULA, let it install some stuff. In a repo with an Xcode project, run:

1
2
$ 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:

1
2
3
4
$ 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.

Clicking “Load Bundle” of course. XVim doesn’t appear. Right, we need to resign Xcode, the instruction is here: https://github.com/XVimProject/XVim2/blob/master/SIGNING_Xcode.md.

Resigning Xcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ 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:

1
2
3
4
5
6
$ 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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ codesign -dvv /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Executable=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Identifier=com.apple.dt.xcodebuild
Format=Mach-O thin (x86_64)
Authority=Software Signing
Authority=Apple Code Signing Certification Authority
Authority=Apple Root CA

$ codesign -v -s XcodeSigner -f --timestamp=none /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild: replacing existing signature
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild: signed Mach-O thin (x86_64) [com.apple.dt.xcodebuild]

$ codesign -dvv /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Executable=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Identifier=com.apple.dt.xcodebuild
Format=Mach-O thin (x86_64)
Authority=XcodeSigner
Signed Time=12. Feb 2020 at 10:05:44

It’s good now:

1
$ xcodebuild -list > /dev/null

Finish him!

To protect the installation, I’m changing the owner:

1
$ sudo chown -R root:wheel /Applications/Xcode.app

Done.

Comments