This open-source Cocoa Touch Static Library allows users of your app to pay with Venmo.
Add Venmo as a Git submodule to the Libraries directory.
This will help you pull in updates and make contributions.
cd ~/Projects/DrinksOnMe/ # sample project root directory
# Let's make a new directory called Libraries for third-party code.
git submodule add https://github.com/venmo/venmo-ios-sdk.git Libraries/Venmo
git submodule update --init
git commit -am 'Add Venmo as a submodule.'
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.
With the Libraries group selected, press ⌥⌘A to add files, select Venmo.xcodeproj
in Libraries/Venmo
, 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 Venmo.xcodeproj inside.'
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 Venmo. (To allow all your targets, e.g., your tests target (along with your application target), to import Venmo, apply these settings at the project level.)
Select the "Build Phases" tab.
- Under the "Target Dependencies" group, click the plus button, select Venmo from the menu, and click Add.
- Under the "Link Binary With Libraries" group, click the plus button, select
libVenmo.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.
- Search for "Header Search Paths," click on it, hit enter, paste
Libraries/Venmo
, and hit enter. (This leaves "Recursive" unchecked.) - Do the same for "Other Linker Flags," except paste
-ObjC -force_load ${BUILT_PRODUCTS_DIR}/libVenmo.a
Select the "Info" tab. Add a URL Type with Identifier: Venmo
, Role: Editor
, and URL Schemes: venmo1234
, where 1234
is your app ID.
In Terminal, review and commit your changes:
git diff -w -M --color-words HEAD
git commit -am 'Edit target info, phases & settings for Venmo.'
-
Include Venmo in any files that use it:
#import <Venmo/Venmo.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 <Venmo/Venmo.h> #endif
Specify the path to this precompiled header in your test target's Build Settings under Prefix Header.
-
Instantiate a
VenmoClient
. Check outVenmoClient.h
. -
Instantiate a
VenmoTransaction
. Check outVenmoTransaction.h
. -
Call
-[VenmoClient viewControllerWithTransaction:]
, which will open the Venmo app or return aVenmoViewController
.
- VenmoApp (in this project)
- Drinks On Me
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/DrinksOnMe/Libraries/Venmo 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 Venmo a pull request on GitHub.