PlacesFinder is a universal iOS app that searches for nearby places, using the Yelp Fusion API as its source backend. Its primary purpose is to demonstrate advanced iOS programming practices, including:
- Coordinators
- Redux
- Deep linking
- Location services
- Auto Layout/split view controllers
- Using Sourcery
- Unit and UI tests
- And more
- Install the following tools if your system doesn't have them already:
- Clone the PlacesFinder repo onto your system.
- Run
$ bundle installto install the dependencies listed in the Gemfile. - Run
$ bundle exec pod installto install CocoaPods dependencies.
-
In order to display results from the Yelp Fusion API in PlacesFinder, you'll need to provide it with an API key from Yelp. You can obtain a limited daily-use token for free.
-
In the Terminal, run the following:
$ cd root/of/PlacesFinder/repo $ echo "PLACE_LOOKUP_KEY=value_of_your_API_key" >> fastlane/.env $ bundle exec fastlane generate_placesfinderThe
generate_placesfinderlane auto-generates all of the Sourcery, CoordiNode, config, and other files for the app. After running it, you'll see your key inserted into AppConfig.plist (be careful not to commit it to Git). -
Open
PlacesFinder.xcworkspacein Xcode 13.3 or later. -
Build and run PlacesFinder; searching will correctly display results. (The app will also run without a valid API key, but searching won't work.)
NOTE: an app intended for App Store deployment (which PlacesFinder is not!) should NEVER bundle or be sent a globally-used private key. Instead, the app's own backend should manage private keys for external services such as Yelp, and provide authenticated client apps with limited-use tokens (such as OAuth tokens).
PlacesFinder supports the following custom URL schemes for deep linking:
placesFinder://com.justinpeckner.PlacesFinder/search?keywords=your_search_string_here: opens/transitions PlacesFinder to the Search tab and automatically searches for the query value specified. Be sure to percent encode the query value, such as replacing space characters with%20. Examples:placesFinder://com.justinpeckner.PlacesFinder/search?keywords=ThaiplacesFinder://com.justinpeckner.PlacesFinder/search?keywords=Greek%20food
placesFinder://com.justinpeckner.PlacesFinder/settings: opens/transitions PlacesFinder to the Settings tabplacesFinder://com.justinpeckner.PlacesFinder/settingsChild: opens/transitions PlacesFinder to the Settings child presentation view
To use a deep link scheme:
-
Install PlacesFinder-Release scheme app on an iOS simulator or device. (Note: to use PlacesFinder-Debug scheme instead, replace the link's
placesFinder://prefix withplacesFinder-dev://). -
Optional: the above URL schemes work even if PlacesFinder isn't currently launched, so kill the running instance of PlacesFinder if you'd like to try this out.
-
Enter one of the URLs in Safari, and tap Go.
-
Tap Open in Safari's confirmation dialog.
-
PlacesFinder will open to the content specified by the link.
NOTE: a business or organization with a website should use universal links rather than a custom URL scheme. However, this in no way lessens the usefulness of PlacesFinder's deep link handling, as there is no significant difference between how it would handle a universal link versus a custom URL scheme link.
PlacesFinder includes a full suite of CI tests, which can be run via bundle exec fastlane ci_tests.
These include UI tests which run against a local HTTP server, at http://localhost, using swifter.
-
By default, the server runs on port 8080, but you can change the port in your fastlane/.env file as follows:
$ cd root/of/PlacesFinder/repo $ echo "TEST_PLACE_LOOKUP_PORT=desired_port_number_here" >> fastlane/.env -
If you have macOS Firewall enabled, each time you run the tests you'll see an annoying pop-up asking if you want to allow an incoming connection. To prevent this, simply run the script at PlacesFinderUITests/add_firewall_exceptions.sh, and provide your password when prompted. (Note that you'll need to re-run it each time you restart your computer.) Credit to Tom Soderling for sharing this script!
The
ci_testslane takes care of everything else, including setting anNSAppTransportSecurityexception forlocalhostin Info.plist.
- Yelp Fusion API - local content and user reviews API
Other libraries by jpeckner
- CoordiNode - predictably and safely manage the flow of coordinators in an app
- Shared - Swift code for networking, location services, UI, and more
- SwiftDux - a straightforward, thread-safe implementation of Redux in Swift
- Kingfisher - download and cache images from the web
- Nimble - Swift matcher framework
- Quick - Swift BDD testing framework
- Reachability.swift - determine status of the device's internet connection
- SkeletonView - easily display progress-indicating "skeleton" views
- SnapKit - a Swift Autolayout DSL
- swifter - a lightweight HTTP server engine written in Swift (used only for UI tests)
This project is licensed under the MIT License - see the LICENSE file for details.