Skip to content

MacVim: Missing vim directory in MacVim.app/Contents/Resources #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
7 tasks
mario-grgic opened this issue Nov 3, 2022 · 11 comments · Fixed by #1336
Closed
7 tasks

MacVim: Missing vim directory in MacVim.app/Contents/Resources #1335

mario-grgic opened this issue Nov 3, 2022 · 11 comments · Fixed by #1336
Labels
Updater Issues related to Sparkle updater

Comments

@mario-grgic
Copy link

mario-grgic commented Nov 3, 2022

Steps to reproduce

I am building macvim from source (I do this couple of times a week to keep up to date). Today I am building as of commit d311aae, using the following configure options

./configure --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-python3interp --enable-perlinterp --enable-luainterp=yes --with-lua-prefix=/usr/local --enable-cscope --enable-terminal

which produces MacVim.app without vim directory in MacVim.app/Contents/Resources/ directory, so entire runtime directory is not available. This is a recent regression.

By the way I am building on macOS 10.15 Catalina, with Xcode 12.1.

This does not happen on macOS 13.0 Ventura and Xcode 14.1.

Expected behaviour

vim and runtime directories should be installed in Runtime.

Version of Vim and architecture

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 3 2022 13:19:30) macOS version - x86_64 Included patches: 1-827

Environment

macOS 10.15.7 Catalina
Built in Terminal.app
echo $TERM
xterm-256color
shell: GNU bash, version 5.2.0(1)-release (x86_64-apple-darwin19.6.0)

How MacVim was installed

Built from git

Logs and stack traces

No response

Vim configuration where issue is reproducable

No response

Issue has been tested with given configuration

  • by running MacVim.app from GUI macOS interface
  • by running vim/gvim/etc installed by MacVim
  • by running other versions of vim (e.g. /usr/bin/vim)

Issue has been tested with no configuration

  • by running mvim --clean (or gvim, supplied by MacVim distribution)
  • by running vim --clean (in terminal, supplied by MacVim distribution)
  • by running vim --clean (in terminal, other suppliers, e.g. /usr/bin/vim)

Other conditions

  • The both Homebrew packages "vim" and "macvim" are installed
@eirnym
Copy link
Contributor

eirnym commented Nov 3, 2022

It's important, that if you need both python3 and python2, dynamic option is required. It's neither possible to build Vim with both versions of Python statically, nor use both Python versions in the same Vim session.

@ychin
Copy link
Member

ychin commented Nov 3, 2022

Do you see any error messages @mario-grgic? Your issue report seems to suggest it completed building but didn't include the "vim" folder but I'm guessing that the build just failed?

I have seen that Sparkle 2's framework doesn't really work well with older versions of Xcode before. I have been wondering about filing a bug report on Sparkle. Can you try this and see if it fixes the issue locally (run it from repo root folder)?

ln -fhs Sparkle_1.framework src/MacVim/Sparkle.framework

If it does fix the issue, you can just use that for now. I'll think about if there's a way to handle this better.

@ychin
Copy link
Member

ychin commented Nov 3, 2022

Actually, I think this may be related to a code signing bug in older Xcode versions (sparkle-project/Sparkle#2069). Can you try the following @mario-grgic (apply the patch) instead of what I mentioned above? You didn't include an error message so I'm guessing that you are failing at the code signing stage, but if it's something else then we have to debug further:

diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj
index 010838316e..0ca1b98705 100644
--- a/src/MacVim/MacVim.xcodeproj/project.pbxproj
+++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj
@@ -65,7 +65,7 @@
                52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
                528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
                52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
-               52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+               52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };

If you don't want to apply the patch you can just go to Xcode, select MacVim.xcodeproj, go to Build Phases -> Copy Framework, and then turn off Code Sign On Copy for Sparkle.framework.

@ychin ychin added the Updater Issues related to Sparkle updater label Nov 3, 2022
@mario-grgic
Copy link
Author

This is a build failure, which I didn't originally notice since post build I run a few scripts to copy over custom MacVim icons, etc. But here is build failure:

    cd /Volumes/ramdisk/macvim.git/src/MacVim
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-debug-symbols -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/PSMTabBarControl.framework /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks
warning: skipping copy phase strip, binary is code signed: /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/PSMTabBarControl.framework/Versions/A/PSMTabBarControl (in target 'MacVim' from project 'MacVim')

CodeSign /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/PSMTabBarControl.framework/Versions/A (in target 'MacVim' from project 'MacVim')
    cd /Volumes/ramdisk/macvim.git/src/MacVim
    export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    
Signing Identity:     "-"

    /usr/bin/codesign --force --sign - --timestamp\=none --preserve-metadata\=identifier,entitlements,flags /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/PSMTabBarControl.framework/Versions/A
/Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/PSMTabBarControl.framework/Versions/A: replacing existing signature

CodeSign /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/Sparkle.framework/Versions/A (in target 'MacVim' from project 'MacVim')
    cd /Volumes/ramdisk/macvim.git/src/MacVim
    export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    
Signing Identity:     "-"

    /usr/bin/codesign --force --sign - --timestamp\=none --preserve-metadata\=identifier,entitlements,flags /Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/Sparkle.framework/Versions/A
/Volumes/ramdisk/macvim.git/src/MacVim/build/Release/MacVim.app/Contents/Frameworks/Sparkle.framework/Versions/A: bundle format unrecognized, invalid, or unsuitable
Command CodeSign failed with a nonzero exit code

warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'QuickLookStephen' from project 'QuickLookStephen')
** BUILD FAILED **

and yes it is related to code signing.

I tried applying the patch, but get:

$ patch -p1 < /Volumes/ramdisk/macvim.patch
patching file src/MacVim/MacVim.xcodeproj/project.pbxproj
Hunk #1 FAILED at 65.
1 out of 1 hunk FAILED -- saving rejects to file src/MacVim/MacVim.xcodeproj/project.pbxproj.rej
$ 

And here is the rejects file:

***************
*** 65,71 ****
                 52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
                 528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
                 52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
-                52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
                 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
                 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
--- 65,71 ----
                 52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
                 528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
                 52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
+                52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
                 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
                 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };

@ychin
Copy link
Member

ychin commented Nov 4, 2022

You can just open src/MacVim/MacVim.xcodeproj/project.pbxproj and remove CodeSignOnCopy, from the Sparkle.framework line.

@mario-grgic
Copy link
Author

Fixing the Xcode project to remove code signing step for sparkle framework works.

@eirnym
Copy link
Contributor

eirnym commented Nov 4, 2022

MacPorts removes Sparkle framework entirely

ychin added a commit to ychin/macvim that referenced this issue Nov 4, 2022
Sparkle 2:

Seems like older Xcode versions (before 12.5) have problems signing
frameworks that only have a Versions/B but not a Versions/A folder.
Sparkle 2 moved to only having Versions/B which is causing code sign to
fail on build step. Just fix this issue by disabling Sign on Copy for
Sparkle.framework. We don't really need it because it already comes with
an ad-hoc signature anyway, and for publish we have a custom signing
script (sign-developer-id) to do manual signing.

Also, fix CI to use Sparkle 2 again for old Xcode (11.7) builds to test
this working. Previously we made it use Sparkle 1 because we didn't work
around this issue, which was kind of a hack.

For Sparkle 2, also add a `cleanup-after-build` script to remove the XPC
Services folder in the framework. Sparkle dev added this to the bundle
for sandboxed apps but non-sandbox apps don't really need it and it's
recommended by Sparkle to remove them, so we unfortunately need to
manually do it as a post-build step.

Fix macvim-dev#1335

Signing / notarization scripts:

Make sure to sign Sparkle 2 binaries in `sign-developer-id`. Also, seems
like the "--deep" flag in codesign is now deprecated as of macOS 13, so
just stop using it and manually sign all the relevant binaries
explicitly.

For notarization script, the current behavior doesn't correctly detect
failure as `xcrun notarytool submit` always exits with 0 even if the
submission failed. Add logic to manually query whether the submission
succeeded. If failed, print out the logs for easier diagnosis, and
exits with -1 so it will block progress.
@ychin
Copy link
Member

ychin commented Nov 4, 2022

Fixing the Xcode project to remove code signing step for sparkle framework works.

Cool thanks for confirming. #1336 will fix this. Feel free to try it out once it's merged.

@ychin
Copy link
Member

ychin commented Nov 4, 2022

MacPorts removes Sparkle framework entirely

Yes but it requires a custom patch to manually strip it. Homebrew also disables Sparkle but it only removes Sparkle after the build is done. During build phase it still links against Sparkle.

@ychin
Copy link
Member

ychin commented Nov 4, 2022

Alright this is merged. @mario-grgic you can revert the change and just pull the latest. Let me know if you see more issues with building/running.

@mario-grgic
Copy link
Author

@ychin Just to confirm, the issue is fixed. Thank you all for fast responses and speedy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Updater Issues related to Sparkle updater
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants