• Stars
    star
    330
  • Rank 127,657 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A plugin for Xcode to synchronize code snippets with repositories

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

More Repositories

1

SimulatorRemoteNotifications

Library to send mock remote notifications to the iOS simulator
Objective-C
1,373
star
2

Parallax

Parallax is an iOS library that reproduces the parallax effect of the iOS7 home screen.
Objective-C
407
star
3

ACReuseQueue

A queue to keep and reusing objects.
Objective-C
369
star
4

iOS-MagnifyingGlass

A magnifying glass for iOS
Objective-C
314
star
5

Populate

Populate is both an iOS app and library to easily create random-generated contacts.
Objective-C
120
star
6

instagram-filters

Instagram-like image filters
Python
116
star
7

ACKeyboard

ACKeyboard is a keyboard extension for iOS that mimics the system keyboard, except it has only one 'letter' key: "yo".
Objective-C
104
star
8

flask-autodoc

Flask autodoc automatically creates an online documentation for your flask application.
Python
98
star
9

Segway

Segway is an iOS library for segues but without storyboards.
Objective-C
65
star
10

WebScraper

iOS library for web scraping
Objective-C
37
star
11

ACHalloween

A library with halloween-themed animations for iOS.
Objective-C
21
star
12

xcode-snippets

A set of custom code snippets for Xcode
Objective-C
20
star
13

iOS-Konami-Code

Objective-C
11
star
14

kanjinetworks

kanjinetworks is an interface for the Kanji Networks database.
Python
5
star
15

Spyglass

Events tracking analytics for iOS
Objective-C
4
star
16

NetBrowser

Proof-of-concept: Bonjour services browser
Objective-C
4
star
17

WidgetStoreProduct

Proof of concept: A SKStoreProductViewController replacement using iTunes web widgets
Objective-C
4
star
18

Delirium

Objective-C
4
star
19

Tumblr-backup

Make a local backup of your Tumblr blogs
Shell
3
star
20

esp8266_ddc

C++
3
star
21

gittime

Estimate time spend coding based on commits in a git repository.
Python
2
star
22

Hourglass

iOS library for testing if a time interval is elapsed
Objective-C
2
star
23

lldb_screengraph

LLDB script for creating (dot/graphviz) graphs of iOS screens based on breakpoints.
Python
2
star
24

maskcomp

Maskcomp is a library utility to compare two images, like iPhone screenshots, optionally with a mask.
Python
2
star
25

MultipleStoresTests

Testing multiple persistence store; one in the main bundle and one in the documents directory
Objective-C
1
star
26

IGInterfaceDataTable

Easily build WatchKit tables with complex data structures.
Objective-C
1
star
27

cpp_project_template

CMake
1
star
28

Janus

Proof of concept for building a "multiversal" (x86+arm) fat binary
Objective-C
1
star
29

jquery.formable

JavaScript
1
star
30

tourofcpp

Quick self-practice of C++11 based on the "A Tour of C++" book.
C++
1
star
31

pkunk.com

JavaScript
1
star
32

AsyncTestKit

iOS library for testing asynchronous operations
Objective-C
1
star
33

clang-tutorial

C++
1
star
34

sample-images

Sample images for various uses, resized to iphone and ipad screen sizes.
1
star
35

tome

HTML
1
star
36

WebViewsTests

Test web views performance with sunspider
JavaScript
1
star
37

MessagingTests

Proof of concept: Messing with Objective-C runtime's messages routing
Objective-C
1
star
38

SimulatorPushNotifications

Moved to https://github.com/acoomans/SimulatorRemoteNotifications
1
star