This open-source Cocoa Touch Static Library allows users of your app to pay or charge with Venmo. It switches to the Venmo app if it's installed on the device. Otherwise, it opens Venmo in a web view. When the transaction is complete, it switches back to your app.
First, create a new Venmo Application by visiting https://venmo.com/
Login and go to: Account > Developers > New Application.
NB: Follow these instructions exactly unless you know what you're doing.
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-your-friends-ios.git Libraries/Venmo
git submodule update --init
git commit -m 'Add Libraries/Venmo Git submodule.'
In Xcode, select your project (DrinksOnMe) at the top of the Project Navigator (⌘1), and press ⌥⌘A (File > Add Files to "DrinksOnMe"...). Select the Libraries
directory (in ~/Projects/DrinksOnMe/
), and confirm that "Copy items..." is unchecked, "Create groups..." is selected, and all targets are unchecked. Then, click Add. Finally, for finess, drag & drop the Libraries group before the Frameworks group.
In Terminal, review and commit your changes:
git diff -w -M --color-words HEAD
git commit -am 'Add Libraries/Venmo to Xcode project.'
In Xcode, select your project (DrinksOnMe) at the top of the Project Navigator (⌘1), and then, select the target (DrinksOnMe) to which you want to add Venmo.
Select the "Info" tab. Add a URL Type with Identifier: Venmo
, Role: Editor
, and URL Schemes: venmo1234
, where 1234
is your app ID.
Select the "Build Settings" tab. (Make sure "All" is selected in the top left.)
- Search for "Header Search Paths," click on it, hit enter, paste
Libraries/Venmo
, and hit enter. (non-recursive) - Do the same for "Other Linker Flags," except paste
-ObjC -force_load ${BUILT_PRODUCTS_DIR}/libVenmo.a
.
Select the "Build Phases" tab.
- Add Venmo to the "Target Dependencies" build phase.
- Add
libVenmo.a
to the "Link Binary With Libraries" build phase.
In Terminal, review and commit your changes:
git diff -w -M --color-words HEAD
git commit -am 'Edit target info, settings, and phases for Venmo.'
-
Import Venmo in any files that use it (and, to reduce build times, in the precompiled header file, e.g.,
DrinksOnMe-Prefix.pch
).#import <Venmo/Venmo.h>
-
Instantiate a
VenmoClient
. Check outVenmoClient.h
. -
Instantiate a
VenmoTransaction
. Check outVenmoTransaction.h
. -
Call
-[VenmoClient viewControllerWithTransaction:]
, which will open the Venmo app or return aVenmoViewController
.
-
#import <Venmo/Venmo.h>
causes the compile-time error'Venmo/Venmo.h' file not found
.This means the Header Search Path build setting doesn't match the Git submodule path (in
.gitmodules
). Both should beLibraries/Venmo
. The Project Navigator group structure is irrelevant because it can differ from the file system's directory structure, which is what really matters.
- 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 commits.'
Some of us find it useful to 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-your-friends-ios.git git push myusername master
-
Send Venmo a pull request on GitHub.