Skip to content

Commit

Permalink
Convert to framework and add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
watsonbox committed Feb 15, 2015
1 parent 908c3d0 commit ca8bc30
Show file tree
Hide file tree
Showing 197 changed files with 13,347 additions and 248 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,19 @@

# Exclude personal Xcode user settings
xcuserdata/

build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -6,4 +6,4 @@ before_install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet

script:
- set -o pipefail && xcodebuild -project GooglePlacesAutocomplete.xcodeproj -scheme "GooglePlacesAutocomplete" -sdk iphonesimulator -configuration Release ONLY_ACTIVE_ARCH=NO test | xcpretty -c
- set -o pipefail && xcodebuild -workspace GooglePlacesAutocomplete.xcworkspace -scheme "GooglePlacesAutocompleteExample" -sdk iphonesimulator -destination 'name=iPhone 5S' -configuration Release ONLY_ACTIVE_ARCH=NO test | xcpretty -c
336 changes: 195 additions & 141 deletions GooglePlacesAutocomplete.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Expand Up @@ -14,8 +14,8 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D431A8A1E8500E0760A"
BuildableName = "GooglePlacesAutocomplete.app"
BlueprintIdentifier = "1EC16D801A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocomplete.framework"
BlueprintName = "GooglePlacesAutocomplete"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
</BuildableReference>
Expand All @@ -28,7 +28,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D581A8A1E8500E0760A"
BlueprintIdentifier = "1EC16D8B1A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocompleteTests.xctest"
BlueprintName = "GooglePlacesAutocompleteTests"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
Expand All @@ -46,7 +46,7 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D581A8A1E8500E0760A"
BlueprintIdentifier = "1EC16D8B1A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocompleteTests.xctest"
BlueprintName = "GooglePlacesAutocompleteTests"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
Expand All @@ -56,8 +56,8 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D431A8A1E8500E0760A"
BuildableName = "GooglePlacesAutocomplete.app"
BlueprintIdentifier = "1EC16D801A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocomplete.framework"
BlueprintName = "GooglePlacesAutocomplete"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
</BuildableReference>
Expand All @@ -72,15 +72,15 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D431A8A1E8500E0760A"
BuildableName = "GooglePlacesAutocomplete.app"
BlueprintIdentifier = "1EC16D801A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocomplete.framework"
BlueprintName = "GooglePlacesAutocomplete"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -90,15 +90,15 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1EC16D431A8A1E8500E0760A"
BuildableName = "GooglePlacesAutocomplete.app"
BlueprintIdentifier = "1EC16D801A8E1D0100E0760A"
BuildableName = "GooglePlacesAutocomplete.framework"
BlueprintName = "GooglePlacesAutocomplete"
ReferencedContainer = "container:GooglePlacesAutocomplete.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
13 changes: 13 additions & 0 deletions GooglePlacesAutocomplete.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions GooglePlacesAutocomplete/GooglePlacesAutocomplete.h
@@ -0,0 +1,19 @@
//
// GooglePlacesAutocomplete.h
// GooglePlacesAutocomplete
//
// Created by Howard Wilson on 13/02/2015.
// Copyright (c) 2015 Howard Wilson. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for GooglePlacesAutocomplete.
FOUNDATION_EXPORT double GooglePlacesAutocompleteVersionNumber;

//! Project version string for GooglePlacesAutocomplete.
FOUNDATION_EXPORT const unsigned char GooglePlacesAutocompleteVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <GooglePlacesAutocomplete/PublicHeader.h>


61 changes: 37 additions & 24 deletions GooglePlacesAutocomplete/GooglePlacesAutocomplete.swift
Expand Up @@ -8,15 +8,15 @@

import UIKit

enum PlaceType: Printable {
public enum PlaceType: Printable {
case All
case Geocode
case Address
case Establishment
case Regions
case Cities

var description : String {
public var description : String {
switch self {
case .All: return ""
case .Geocode: return "geocode"
Expand All @@ -28,27 +28,37 @@ enum PlaceType: Printable {
}
}

struct Place {
let id: String
let description: String
public class Place: NSObject {
public let id: String
public let desc: String

override public var description: String {
get { return desc }
}

init(id: String, description: String) {
self.id = id
self.desc = description
}
}

protocol GooglePlacesAutocompleteDelegate {
func placeSelected(place: Place)
func placeViewClosed()
@objc public protocol GooglePlacesAutocompleteDelegate {
optional func placesFound(places: [Place])
optional func placeSelected(place: Place)
optional func placeViewClosed()
}

// MARK: - GooglePlacesAutocomplete
class GooglePlacesAutocomplete: UINavigationController {
var gpaViewController: GooglePlacesAutocompleteContainer!
var closeButton: UIBarButtonItem!
public class GooglePlacesAutocomplete: UINavigationController {
public var gpaViewController: GooglePlacesAutocompleteContainer!
public var closeButton: UIBarButtonItem!

var placeDelegate: GooglePlacesAutocompleteDelegate? {
public var placeDelegate: GooglePlacesAutocompleteDelegate? {
get { return gpaViewController.delegate }
set { gpaViewController.delegate = newValue }
}

convenience init(apiKey: String, placeType: PlaceType = .All) {
public convenience init(apiKey: String, placeType: PlaceType = .All) {
let gpaViewController = GooglePlacesAutocompleteContainer(
apiKey: apiKey,
placeType: placeType
Expand All @@ -64,13 +74,13 @@ class GooglePlacesAutocomplete: UINavigationController {
}

func close() {
placeDelegate?.placeViewClosed()
placeDelegate?.placeViewClosed?()
}
}

// MARK: - GooglePlacesAutocompleteContainer
class GooglePlacesAutocompleteContainer: UIViewController {
@IBOutlet weak var searchBar: UISearchBar!
public class GooglePlacesAutocompleteContainer: UIViewController {
@IBOutlet public weak var searchBar: UISearchBar!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var topConstraint: NSLayoutConstraint!

Expand All @@ -80,7 +90,9 @@ class GooglePlacesAutocompleteContainer: UIViewController {
var placeType: PlaceType = .All

convenience init(apiKey: String, placeType: PlaceType = .All) {
self.init(nibName: "GooglePlacesAutocomplete", bundle: nil)
let bundle = NSBundle(forClass: GooglePlacesAutocompleteContainer.self)

self.init(nibName: "GooglePlacesAutocomplete", bundle: bundle)
self.apiKey = apiKey
self.placeType = placeType
}
Expand All @@ -89,11 +101,11 @@ class GooglePlacesAutocompleteContainer: UIViewController {
NSNotificationCenter.defaultCenter().removeObserver(self)
}

override func viewWillLayoutSubviews() {
override public func viewWillLayoutSubviews() {
topConstraint.constant = topLayoutGuide.length
}

override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()

NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWasShown:", name: UIKeyboardDidShowNotification, object: nil)
Expand Down Expand Up @@ -124,11 +136,11 @@ class GooglePlacesAutocompleteContainer: UIViewController {

// MARK: - GooglePlacesAutocompleteContainer (UITableViewDataSource / UITableViewDelegate)
extension GooglePlacesAutocompleteContainer: UITableViewDataSource, UITableViewDelegate {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return places.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

// Get the corresponding candy from our candies array
Expand All @@ -141,14 +153,14 @@ extension GooglePlacesAutocompleteContainer: UITableViewDataSource, UITableViewD
return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
delegate?.placeSelected(self.places[indexPath.row])
public func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
delegate?.placeSelected?(self.places[indexPath.row])
}
}

// MARK: - GooglePlacesAutocompleteContainer (UISearchBarDelegate)
extension GooglePlacesAutocompleteContainer: UISearchBarDelegate {
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
public func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
if (searchText == "") {
self.places = []
tableView.hidden = true
Expand Down Expand Up @@ -214,6 +226,7 @@ extension GooglePlacesAutocompleteContainer: UISearchBarDelegate {

self.tableView.reloadData()
self.tableView.hidden = false
self.delegate?.placesFound?(self.places)
}
})
}
Expand Down
22 changes: 4 additions & 18 deletions GooglePlacesAutocomplete/Info.plist
Expand Up @@ -13,28 +13,14 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

0 comments on commit ca8bc30

Please sign in to comment.