Home

Awesome

ObjectiveGit-iOS-Example

This is a quick guide on setting up ObjectiveGit for an iOS project. The example code clones a repository if it doesn't already exist, and displays the latest commit message. Don't expect much; it's only meant to get you started.

Adding the ObjectiveGit framework to a new iOS project

  1. Create a new project on Xcode (make sure to check "initialize a git repository"). Do not use spaces in the project name; the bootstrap script for ObjectiveGit will not work with paths with spaces
  2. At the command line, cd into your project root, and run git submodule add git@github.com:libgit2/objective-git.git.
  3. Make sure you have installed Brew, a package manage for OSX, which the bootstrap script uses to pull dependencies
  4. cd into objective-git, then run ./script/bootstrap. The first build may take a while (~10 minutes)
  5. Open Finder (open .). Drag ObjectiveGitFramework.xcodeproj into Xcode onto your project. Xcode may ask to "Share working copy"; just click yes; it doesn't seem to matter
  6. In the "Build Phases" tab, add ObjectiveGit-iOS-arm64 under "Target Dependencies"
  7. Under "Link Binary With Binaries", add "libObjectiveGit-iOS.a from 'ObjectiveGit-iOS-arm64' target", libz.dylib, and libiconv.dylib
  8. In the "Build Settings" tab, set "Always Search User Paths" to YES
  9. Add $(BUILT_PRODUCTS_DIR)/usr/local/include, and $(PROJECT_DIR)/objective-git/External/libgit2/include to "User Header Search Paths"
  10. Add -all_load to "Other Linker Flags"
  11. Don't forget to #import <ObjectiveGit/ObjectiveGit.h> as you would with any other framework

Cloning/Using this project as a template

  1. git clone ...
  2. git submodule update --init --recursive
  3. cd objective-git
  4. ./script/bootstrap
  5. In Xcode, choose "Open Other" and import the .xcodeproj file
  6. Everything else should already be set up

Notes