Skip to content

Segment: Bootstrapping Integrations

William Johnson edited this page Apr 26, 2016 · 9 revisions

This wiki is for Segmented hosted iOS integrations. If you are a partner, please refer to https://github.com/segmentio/analytics-ios/wiki/Bootstrapping-Integrations instead.

Create the Pod

Run pod lib create Segment-{Service}

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

  • Select ObjC for language.
  • Select Yes for demo app.
  • Select Specta for the testing framework.
  • Skip view based testing.
  • Select SEG for the class prefix.

Rename directory

The pod lib create command will create a directory Segment-{Service}. Rename it to match our convention mv Segment-{Service} analytics-ios-integration-{service}

Podspec

The generated template will contain a file named Segment-{Service}.podspec. Replace it's contents with this file. https://raw.githubusercontent.com/segment-integrations/analytics-ios-integration-mixpanel/master/Segment-Mixpanel.podspec.

Replace any references to Mixpanel with the partner's name. Also take note of the following steps.

  • Downgrade s.version to 0.1.0
  • The Analytics library dependency: s.dependency 'Analytics', '~> 3.0.7'. Always specify the latest version of the iOS library released.
  • Replace the mixpanel dependency with the partner library dependency, e.g: s.dependency 'Mixpanel', '~> 2.9.0'. Always use the latest version at the time of the release.

Add Makefile.

Copy the template below into Makefile at the root of your integration directory. Remember to replace {Service} with the integration name.

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

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

install: Example/Podfile $(PROJECT).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 install build xcbuild test xctest to verify everything is working.

Open in Xcode

Run open Example/Segment-{Service}.xcworkspace

Add your logic!

Now that you have your template setup, you can implement your own custom integration logic.

https://github.com/segmentio/analytics-ios/wiki/Writing-Integrations

Clone this wiki locally