Before you begin, you need a few things set up in your environment:
- Xcode
-
- 8.3 or later
- An Xcode project targeting iOS 10.3 or above
- The bundle identifier of your app
- CocoaPods 1.0.0 or later
NOTE: 1.0.0 Will be built for for 10.3/11 and Xcode 8.3/9
Now it's time to add Trolley to your app. Todo this you will need a Trolley Shop and it's Trolley configuration file for your app.
- Create a Trolley shop in the Trolley console, if you have't already.
- Click Add Trolley to your iOS app and follow the steps, this will automatically download your Trolley configuration file.
- If you haven't already, copy your configuration file to your Xcode project root.
If you are setting up a new project, you need to install the SDK. You may have already completed this as part of creating a Trolley shop.
We recommend using CocoaPods to install the libraries. You can install Cocoapods by following the installation instructions.
If you are planning to download and run one of the quickstart samples, the Xcode project and Podfile are already present, there will also be a sample configuration file present but this is the global tester, so if you wish to see your own products you will have to overwrite this file.
-
If you don't have an Xcode project yet, create one now.
-
Open up terminal.app and create a Podfile if you don't have one:
$ cd your-project directory $ pod init
-
Add the pods that you want to install. You can include a Pod in your Podfile like this:
pod 'Trolley/Core' # OR pod 'Trolley'
NOTE: This will add the prerequisite libraries needed to get Firebase up and running in your iOS app. A list of currently available pods and subspecs is provided below. These are linked in feature specific setup guides as well.
-
Install the pods and open the .xcworkspace file to see the project in Xcode.
$ pod install $ open your-project.xcworkspace
-
Download configuration file...
The final step is to add initialization code to your application. You may have already done this as part of adding Firebase to your app. If you are using a quickstart this has been done for you.
-
Import the Firebase module in your
UIApplicationDelegate
subclass:NOTE: This is usually your AppDelegate.swift or AppDelegate.h File
SWIFT
import Trolley
OBJECTIVE-C
@import Trolley;
-
Configure the Trolley shared instance. This is typically done in the
didFinishLaunchingWithOptions:
method.SWIFT
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Trolley.shared.configure() return true }
OBJECTIVE-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[TRLShop shared] configure]; return YES; }
These pods are available for the different Trolley features
Pod | Service |
---|---|
pod "Trolley" | Prerequisite libraries and Analytics |
pod "Trolley/Database" | For the Product/Basket Management |
See Roadmap for these ideas
A Podfile is a Ruby file that describes the dependencies (Helper Code) for Xcode Projects
Here is an example Podfile, copy and change the with your project and run pod install
to install the pods you need.
NOTE: More details can be found here
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!
target <Project Name> do
# Place Your Pods Here:
pod 'Trolley'
target '<Project Name>Tests' do
inherit! :search_paths
# Pods for testing
end
end