Getting started

This page describes how to get set up with the iOS SDK. If you haven't completed the prerequisites, complete them first.

Dependency

Swift Package Manager

  1. In Xcode, install the Google-SearchInApps-SDK Swift Package by navigating to File > Add Packages....

  2. In the prompt that appears, search for the Google-SearchInApps-SDK Swift Package GitHub repository:

https://github.com/google/search-in-apps.git
  1. Select the version of the Google-SearchInApps-SDK Swift Package you want to use. For new projects, we recommend using the Up to Next Major Version

Once you're finished, Xcode will begin resolving your package dependencies and downloading them in the background. For more details on how to add package dependencies, see Apple's article.

CocoaPods

Import the Google-SearchInApps-SDK into an iOS project using CocoaPods. Open your project's Podfile and add this line to your app's target:

pod 'Google-SearchInApps-SDK'

Then from the command line run:

pod install --repo-update

If you're new to CocoaPods, see their official documentation for info on how to create and use Podfiles.

Update your Info.plist

Update your app's Info.plist file to add two keys:

  1. A GSAAPIKey key with a string value of your SDK api key (see above).
  2. A GSAClientIdentifier key with a string value of your app's client identifier (see above).

Sample Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>GSAAPIKey</key>
        <string>ABC123...xyz890</string>
        <key>GSAClientIdentifier</key>
        <string>ms-demo-app-sia</string>
        ...
</dict>
</plist>

Init

Create an instance of the ContextualSearchRuntime

Swift

ContextualSearchRuntime

let contextualSearchRuntime = ContextualSearchRuntime()

Objective-C

ContextualSearchRuntime

ContextualSearchRuntime *searchRuntime = [[ContextualSearchRuntime alloc] init];

Next: Search features