Getting started
Stay organized with collections
Save and categorize content based on your preferences.
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
In Xcode, install the Google-SearchInApps-SDK Swift Package by navigating to File > Add Packages....
In the prompt that appears, search for the Google-SearchInApps-SDK Swift Package GitHub repository:
https://github.com/google/search-in-apps.git
- 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:
- A
GSAAPIKey
key with a string value of your SDK api key (see above).
- 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
Objective-C
ContextualSearchRuntime
ContextualSearchRuntime *searchRuntime = [[ContextualSearchRuntime alloc] init];
Next: Search featuresarrow_forward
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-05 UTC."],[[["\u003cp\u003eThis guide explains how to integrate the iOS SDK for Google Search in Apps, covering setup, dependency management, and initialization.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure you have fulfilled the prerequisites mentioned in the linked documentation.\u003c/p\u003e\n"],["\u003cp\u003eYou can add the SDK to your project using either Swift Package Manager or CocoaPods, with instructions provided for both methods.\u003c/p\u003e\n"],["\u003cp\u003eRemember to update your app's \u003ccode\u003eInfo.plist\u003c/code\u003e file with your API key and client identifier for the SDK to function correctly.\u003c/p\u003e\n"],["\u003cp\u003eFinally, initialize the \u003ccode\u003eContextualSearchRuntime\u003c/code\u003e to begin utilizing the search functionalities.\u003c/p\u003e\n"]]],["To set up the iOS SDK, first install the Google-SearchInApps-SDK via Swift Package Manager or CocoaPods. For Swift Package Manager, add the package via Xcode using the provided GitHub repository URL. For CocoaPods, add `pod 'Google-SearchInApps-SDK'` to your Podfile and run `pod install --repo-update`. Then, update your app's `Info.plist` by adding `GSAAPIKey` and `GSAClientIdentifier`. Finally, initialize a `ContextualSearchRuntime` instance in either Swift or Objective-C.\n"],null,["# Getting started\n\nThis page describes how to get set up with the iOS SDK. If you haven't\ncompleted the [prerequisites](/search-in-apps/ios/prerequisites), complete\nthem first.\n\nDependency\n----------\n\n### Swift Package Manager\n\n1. In Xcode, install the Google-SearchInApps-SDK Swift Package by navigating to File \\\u003e Add Packages....\n\n2. In the prompt that appears, search for the Google-SearchInApps-SDK Swift Package GitHub repository:\n\n https://github.com/google/search-in-apps.git\n\n1. 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**\n\nOnce you're finished, Xcode will begin resolving your package dependencies and\ndownloading them in the background. For more details on how to add package\ndependencies, see [Apple's article](//developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).\n\n### CocoaPods\n\nImport the Google-SearchInApps-SDK into an iOS project using\n[CocoaPods](https://guides.cocoapods.org/using/getting-started). Open your\nproject's Podfile and add this line to your app's target: \n\n pod 'Google-SearchInApps-SDK'\n\nThen from the command line run: \n\n pod install --repo-update\n\nIf you're new to CocoaPods, see their [official\ndocumentation](https://guides.cocoapods.org/using/using-cocoapods) for info on\nhow to create and use Podfiles.\n\nUpdate your Info.plist\n----------------------\n\nUpdate your app's `Info.plist` file to add two keys:\n\n1. A `GSAAPIKey` key with a string value of your SDK api key (see above).\n2. A `GSAClientIdentifier` key with a string value of your app's client identifier (see above).\n\nSample `Info.plist` \n\n \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n \u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n \u003cplist version=\"1.0\"\u003e\n \u003cdict\u003e\n \u003ckey\u003eGSAAPIKey\u003c/key\u003e\n \u003cstring\u003eABC123...xyz890\u003c/string\u003e\n \u003ckey\u003eGSAClientIdentifier\u003c/key\u003e\n \u003cstring\u003ems-demo-app-sia\u003c/string\u003e\n ...\n \u003c/dict\u003e\n \u003c/plist\u003e\n\nInit\n----\n\nCreate an instance of the\n[`ContextualSearchRuntime`](/search-in-apps/ios/reference/api/swift_reference/Classes/ContextualSearchRuntime) \n\n### Swift\n\n[`ContextualSearchRuntime`](/search-in-apps/ios/reference/api/swift_reference/Classes/ContextualSearchRuntime) \n\n let contextualSearchRuntime = ContextualSearchRuntime()\n\n### Objective-C\n\n[`ContextualSearchRuntime`](/search-in-apps/ios/reference/api/objc_reference/Classes/ContextualSearchRuntime) \n\n ContextualSearchRuntime *searchRuntime = [[ContextualSearchRuntime alloc] init];\n\n[Next: Search featuresarrow_forward](/search-in-apps/ios/features)"]]