Giter Site home page Giter Site logo

cocoaplant's Introduction

Cocoa Plant

Merriam-Webster defines plant as:

1 a : a young tree, vine, shrub, or herb planted or suitable for planting

and the verb to plant as:

1 a : to put or set in the ground for growth

Chief Definite Aim

In that vein, the aim of Cocoa Plant is to grow the Cocoa frameworks & libraries by adding useful classes, categories, and methods to make Cocoa even better.

Summary

Currently, Cocoa Plant is a Cocoa Touch Static Library for use with iOS apps.

Cocoa Plant consists of three parts:

  1. Plantation (Foundation)
  2. UIPlant (UIKit)
  3. PlantData (CoreData)

Plantation

NSString leading & trailing trimming methods, words method.

[[[NSFileManager alloc] init] URLForApplicationDirectory:NSDocumentDirectory]

UIPlant

UIAlertView: showWithTitle:, showWithError:

PlantData

Set up the Core Data stack with one method call:

[NSManagedObjectContext contextWithStoreType:NSSQLiteStoreType error:&error]

Customize fetch requests with blocks:

NSArray *results = [User fetchInContext:context error:&error
                                options:^(NSFetchRequest *request) {
                                    [request setFetchLimit:1];
                                    [request setPredicate:predicate];
                                    [request setSortDescriptors:sortDescriptors];
                                    // ...
                                }];

Project Setup

Add Cocoa Plant as a Git submodule to the Libraries directory.

This will help you pull in updates and make contributions.

cd ~/Projects/Acani/ # sample project root directory

# Let's make a new directory called Libraries for third-party code.
git submodule add https://github.com/acani/CocoaPlant.git Libraries/CocoaPlant
git submodule update --init
git commit -am 'Add CocoaPlant as a submodule.'

Add Cocoa Plant to Your Xcode Project.

Add the Libraries group to your Project.

In Xcode, select your project at the top of the Project Navigator (⌘1), and press ⌥⌘N to create a new group. Name it, e.g., "Libraries." Then, select the Libraries group, press ⌥⌘0 to Show Utilities, click the small icon to the right just below Path, choose the Libraries directory. Drag the Libraries group to move it before the Frameworks group.

Add CocoaPlant.xcodeproj inside the Libraries group.

With the Libraries group selected, press ⌥⌘A to add files, select CocoaPlant.xcodeproj in Libraries/CocoaPlant, and confirm that "Copy items into destination group's folder (if needed)" is unchecked, "Create groups for any added folders" is selected, and all targets are unchecked. Then, click Add.

In Terminal, review and commit your changes:

git diff -w -M --color-words HEAD
git commit -am 'Add Libraries group. Put CocoaPlant.xcodeproj inside.'

Edit Your Application Project Settings.

In Xcode, select your main Xcode project at the top of the Project Navigator (⌘1), and then, select the project (or target) to which you want to add Cocoa Plant. (To allow all your targets, e.g., your tests target (along with your application target), to import Cocoa Plant, apply these settings at the project level.)

Select the "Build Phases" tab.

  • Under the "Target Dependencies" group, click the plus button, select CocoaPlant from the menu, and click Add.
  • Under the "Link Binary With Libraries" group, click the plus button, select libCocoaPlant.a from the menu, and click Add.

Select the "Build Settings" tab. Make sure "All" is selected in the top left of the bar under the tabs.

In Terminal, review and commit your changes:

git diff -w -M --color-words HEAD
git commit -am 'Edit target info, phases & settings for Cocoa Plant.'

Using Cocoa Plant in Your App

  • Include Cocoa Plant in any files that use it:

      #import <CocoaPlant/CocoaPlant.h>
    
  • To reduce build times, create a precompiled header file. E.g., AppName-Prefix.pch:

      #include "AppName-Prefix.pch"
    
      #ifdef __OBJC__
    
      // Frameworks
      #import <Foundation/Foundation.h>
    
      // Libraries
      #import <CocoaPlant/CocoaPlant.h>
    
      #endif
    

    Specify the path to this precompiled header in your test target's Build Settings under Prefix Header.

  • Include Cocoa Plant in your app's prefix header file, e.g., AppName-Prefix.pch:

      #import <CocoaPlant/CocoaPlant.h>
    

Pull in remote updates by running these commands from your project root directory:

git submodule foreach 'git checkout master; git pull --rebase'
git commit -am 'Update submodules to latest commit.'

You can add an alias (to ~/.gitconfig) for the first of the two commands above:

git config --global alias.sup "submodule foreach 'git checkout master; git pull --rebase'"

Then, to pull in remote updates, you can just do:

git sup
  • Commit your changes.

      cd ~/Projects/Acani/Libraries/CocoaPlant
      git add -A
      git commit
    
  • Fork this repo on GitHub, add your fork as a remote, and push.

      git remote add myusername [email protected]:myuser/venmo-ios-sdk.git
      git push myusername master
    
  • Send Cocoa Plant a pull request on GitHub.

Related

cocoaplant's People

Contributors

ma11hew28 avatar johngraham262 avatar diogeneshamilton avatar

Watchers

James Cloos avatar  avatar

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.