Giter Club home page Giter Club logo

accodesnippetrepositoryplugin's Introduction

ACCodeSnippetRepositoryPlugin

ACCodeSnippetRepositoryPlugin is a Xcode plugin for seemless synchronization of snippets with a git repository.

The snippets are synchronized as human-readable text (and not an obscure .codesnippet plist).

Build Status

If you want to know more about snippets in Xcode, I recommend reading Xcode Snippets on NSHipster.

Want to try the plugin with an existing public repository? Try acoomans or mattt's snippets.

Install

  1. Build the project to install the plugin. The plugin is installed in /Library/Application Support/Developer/Shared/Xcode/Plug-ins/ACCodeSnippetRepository.xcplugin.

  2. Restart Xcode for the plugin to be activated.

Alternatively, install through Alcatraz plugin manager.

Configuration

There should be a Plug-ins item in the xcode menu:

screenshots

First configure the plugin by forking a remote repository:

screenshots

When you fork, all snippets from the repository (with the right format, see below Format) will be imported in Xcode. Your existing snippets, that do not belong to any repository yet, will not be affected.

After forking, you will given the choice to import (user) snippets from Xcode to the repository.

Also, you can remove the system snippets if you don't use them.

In case of any problem (see below, Bugs and limitations), you can go to the user snippets folder and backup your user snippets. Note that user snippets are automatically backed up before any fork.

Usage

Use snippets like you always do in Xcode. Snippets are automatically added/edited/removed and pushed to the git repository.

screenshots

Format

The snippets are text files with a .m file extension, in the following format:

  • a header, containing:
    • the title
    • description
    • various Xcode-related information in a Key: Value format (keys ordered alphabetically)
  • the code

If your snippet does not contain any header, the header will be added, committed and pushed when imported.

Note: do not remove the Xcode-related information as they are needed for synchronization.

Note: if you manually create a snippet by copying an existing one, change or remove the IDECodeSnippetIdentifier as Xcode does not like having two snippets with the same identifier (will crash).

screenshots

Synchronization

Every change in a snippet is commited and pushed independently.

Snippets are synchronized (pulled) with the remote repository is done every 10 minutes (if the option is enabled) or when the Update snippets item was chosen in the menu.

In case of conflict during the merge, the remote repository has priority.

Bugs and limitations

Probably a lot.

Backup your snippets and your git repository. Expect bugs, crashes, synchronization issues, data and hair loss.

Contributing

Architecture

First a quick word on the architecture:

The plugin does some swizzling with the IDECodeSnippetRepository class from IDECodeSnippetLibrary.ideplugin (/Applications/Xcode.app/Contents/PlugIns/IDECodeSnippetLibrary.ideplugin).

IDECodeSnippetRepository is modified so to make it possible to attach data stores (ACCodeSnippetDataStoreProtocol).

Here's a colourful schematic to make you even more confused:

screenshots

Pull requests

If you want to contribute, send me a pull request.

Improvements

Ideas of improvements:

  • synchronize .codesnippet plists
  • multiple data stores (in progress but need to be careful when synchronizing)
  • github's gist support

accodesnippetrepositoryplugin's People

Contributors

b9aobj avatar fcanas avatar nealsun avatar squarefrog avatar zenangst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

accodesnippetrepositoryplugin's Issues

Should 'fork' button say 'clone' instead?

I've just found this plugin, and when initially setup I wasn't entirely sure what the 'fork' button would do. It's clear that it clones the repository and optionally updates the repository.

This behaviour, while correct for the plugin, does not follow GitHub wording, where fork creates a new repository based on another.

Bug in Xcode 6.1?

Hi! I have this plugin installed in Xcode 6.1 running on Yosemite. I have integrated it with my own snippet repo on Github. In Xcode I did a change to an existing custom snippet of mine. But Its not synced with the repo on Github. Selecting Update Snippets from the menu doesn't seem to work either.

Edit: I came across another problem. I added a new snippet in Xcode. And the plugin started 'Updating snippets' and removed the newly added snippet from Xcode!

Add a "Read-Only" option for remote url

Hi,

could you please add a "read-only" option when forking/fetching snippets from a git url.

So basically a read-only plugin xcode will only do a git pull and download/sync the snippets from remote url, but never push local snippet changes to remote. This is to reduce possible errors in a working environment with multiple developers by eg. accidentally deleting a snippet.

Idea is, that only 1 person (who has write access) can push changes to the snippet repo and multiple users can only read/fetch snippets from it.

Thanks a lot

Make one big bulk commit when updating/syncing snippets

Currently you are immediately commiting and pushing to the repo on each single little change. It would look better for the git history of the snippet repo to have a big bulk commit instead of a lot single commits. Eg. there will be one commit/push for each snippet you delete when you delete all local snippets

Just some pseudo code:

for each action/change do
    doChange();
    git commit
    git push
end

This would be better

for each action/change do
    doChange();
end
git commit
git push

commit and push one big change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.