Search code examples
xcodemacosgithubbundle

How to prevent Github from treating Mac OS bundles as folders and zipping them?


I recently started my own GitHub repo where I uploaded an Xcode plugin. This plugin is basically a folder with files inside. For some reason Github placed the plugin into a zip file. How can I change this so the plugin is uploaded without being zipped?


Solution

  • macOS bundles are indeed folders with files inside. Typically, the way that you handle this using Git from the command line is with the mv command. Starting from your repository:

    $ mv $PLUGIN_DIR .
    $ git add .
    $ git commit
    # Enter your commit message.
    

    Then you can push using git push.

    However, it is generally not a good idea to store binaries in your repository. You should instead store the source of your plugin in your repository and upload the binaries as a release asset, which typically should be a tarball or zip file (because that makes it easier to download). To do that, build your plugin into a directory (say, foo), and then do one of the following (on macOS):

    # For a tarball.
    $ tar -czf plugin.tar.gz foo
    # For a zip file.
    $ tar --format zip -cf plugin.zip foo
    

    Then, create a release in the GitHub web interface and drag and drop the tarball or zip file as one of the assets (or use the gh command line tool to upload it), and you can then publish the release.

    The reason that GitHub doesn't allow you to upload whole recursive folders in the release asset interface is that there's no good way to download those in an easy way (through the UI or the API). You can really only download one thing at a time, which necessitates some sort of archive.