Skip to content

Bootstrapping Integrations

Prateek Srivastava edited this page Nov 15, 2015 · 12 revisions

iOS integrations are very flexible, you need to simply implement a few protocols and users can start using your integration. We recommend developing your integrations in tandem with your own library as a CocoaPods subspec.

Alternatively, you use this guide to bootstrap your integration in it's own repo. You see the Mixpanel integration as the finished example.

Create the Pod

Run pod lib create Segment-{Service}

Replace {Service} with your own service name, e.g. Mixpanel or Flurry.

  • You can select either Objective-C (recommended) or Swift. If you use Swift, be sure to document any additional steps required by users to integrate your library into their app.
  • Creating a demo app is optional, but recommended for manual testing.
  • Any testing framework is fine.
  • Skip view based testing.
  • Pick a three letter class prefix (for Objective C only). Ideally the same one that you are already using for your own library.

Add dependencies

The first command will generate a file Segment-{Service}.podspec. You'll need to add 2 dependencies in this file.

  • The Analytics library dependency: s.dependency 'Analytics', '~> 3.0.2-alpha'. Remember to specify the minimum version of the Analytics library you need.
  • Your own library dependency, e.g:s.dependency 'Mixpanel', '~> 2.9.0'

Add Makefile.

Copy the template below into Makefile at the root of your integration directory. Remember to replace PROJECT := Segment-{Integration} with your own integration name.

XCPRETTY := xcpretty -c && exit ${PIPESTATUS[0]}

SDK ?= "iphonesimulator"
DESTINATION ?= "platform=iOS Simulator,name=iPhone 5"
PROJECT := Segment-{Integration}
XC_ARGS := -scheme $(PROJECT)-Example -workspace Example/$(PROJECT).xcworkspace -sdk $(SDK) -destination $(DESTINATION) ONLY_ACTIVE_ARCH=NO

install: Example/Podfile Segment-Mixpanel.podspec
	pod install --project-directory=Example

clean:
	xcodebuild $(XC_ARGS) clean | $(XCPRETTY)

build:
	xcodebuild $(XC_ARGS) | $(XCPRETTY)

test:
	xcodebuild test $(XC_ARGS) | $(XCPRETTY)

xcbuild:
	xctool $(XC_ARGS)

xctest:
	xctool test $(XC_ARGS)

.PHONY: test build xctest xcbuild clean
.SILENT:

Updates

Update your deployment targets for the test app and the integration to 8.0 in Xcode. Clear your framework search paths.

Verify

Run make test or make xctest to verify everything is working!

Clone this wiki locally