SwiftypeTouch is a library that makes it easy to add Swiftype-powered search to your iOS application.
- Get the code (
git clone git@github.com:swiftype/SwiftypeTouch.git) and copy the top-levelSwiftypeTouchdirectory to the directory that containsYourProject.xcodeproj(or use a git submodule). - Add
SwiftypeTouch/SwiftypeTouch.xcodeprojto your Xcode project.- This can be done by dragging and dropping
SwiftypeTouch.xcodeprojinto the project browser from Finder.
- This can be done by dragging and dropping
- In
YourProject.xcodeprojBuild Settings add to yourHEADER_SEARCH_PATHSthe following:$(SRCROOT)/SwiftypeTouch/. - Add
-ObjCand-all_loadto your project'sOTHER_LDFLAGS. - Now make sure to link
libSwiftypeTouch.awith your target. Under your Target settings go to Build Phases. Expand "Link Binary With Libraries" hit the "+" button and selectlibSwiftypeTouch.afrom the dialog. - Add SwiftypeTouch to the "Target Dependencies" list.
You are now ready to use SwiftypeTouch in your project.
If your Swiftype search engine was created with the Swiftype crawler, you can follow these steps to quickly add search that displays results in a table view. Results will load in a webview when selected.
-
First, makes sure you've followed the steps above.
-
Add
#import <SwiftypeTouch/STPageDocumentTypeResultsObject.h>to the view controller implementation that will place the search bar on the screen. -
Create a private property for
STPageDocumentTypeResultsObjectcalledresultObjectin your view controller:@property (nonatomic, strong) STPageDocumentTypeResultsObject *resultObject; -
In the view controller's
viewDidLoadadd the following code to get the search bar to appear:self.resultObject = [[STPageDocumentTypeResultsObject alloc] initWithViewController:self clientEngineKey:@"yourEngineKey"]; [self.view addSubview:self.resultObject.searchBar];
To see an example of this, view the source of the SwiftypeTouchExample application.
This code is made available under the MIT License. Seee LICENSE.txt for details.