Awesome
Flint Demo for iOS
<img src="https://flint.tools/assets/img/logo-dark-on-white.svg" width="230" alt="Flint framework logo">This is a sample project that uses Flint framework for Feature Driven Design.
This Master/Detail app provides simple "notes" gathering features with photo attachments. It demonstrates the use of Flint to:
- Define the Feature and Actions of an app
- Support conditional features (feature flagging, requiring purchase, platform versions etc.)
- Disabling features for which required system permissions are not authorized (e.g. Photos)
- Use Flint's Routes feature to implement custom URL schemes and deep linking
- Use Flint's Activities to automatically support Handoff, Spotlight search etc.
- Use Flint's Siri Intent extension support to allow getting note contents via a Shortcut with or without voice, without launching the app
- Automatic analytics tracking
- Contextual logging
- Flint's "FlintUI" debug tools for browsing the feature hierarchy, Timeline, Focus logs and Action Stacks
How to build and run
Currently only Carthage is supported, so you'll need that installed.
- Check out the project
- Run
carthage bootstrap --platform iOS --cache-builds
- Build and run the project in Xcode 9.2 or higher
Note that if you change the version of Flint required in Cartfile
, you need to run carthage update
instead.
If you build against Flint master
you will also need to run a git fetch
for the Flint repo URL to force
Carthage to get the latest code if you are expecting new commits.
How the app uses Flint
The app bootstraps Flint with the available features here.
The top-level App Features are defined, with the most interesting being DocumentManagementFeature which exposes actions that are URL mapped and used via Activities.
The App Delegate receives open URL and continue Activity requests from the system and uses Flint to dispatch the relevant actions.
The camera permissions are requested automatically by Flint when trying to perform the Select Photo action, and any causes for failure to perform the conditional actions are handled by the app using Flint's information about the unfulfilled feature constraints.
For Siri Intent handling, the Intent extension's main intent handler sets up Flint. It returns the intent handler for the Get Note intent shortcut which performs the GetNoteAction.
Using the app
The app lets you create "documents" that have a name and some body text and an optional photo attachment. You can edit them, remove them and share them.
Using the "Debug" option you can drill down into the Flint debug UIs to experiment with Flint and the insights it can give you.
To browse the Features and Actions in the app
- Go to the
Debug
option on the main screen - Choose "Browse Features and Actions"
Here you can the hierarchy of Features and their actions, the types they expect, their analytics IDs and so on.
To view the Flint Timeline
- Add and edit some documents. Swipe to delete some.
- Now go to the
Debug
option on the main screen - Choose "Timeline"
Here you can see a Twitter-style feed of the actions you performed. You can tap for more details of what happened.
To test URLs (Routes)
- Create some documents with simple names like "test1", "test2", "test3" and so on and edit the text in some of them
- Switch away and launch Safari
- Enter a URL into the address bar like
fdemo://open?name=test2
where you replace thetest2
part with the document you want to view, and press return/Go
Each time you do this, Flint should open each document you requested with the URL.
You should also find success with the custom "legacy" URL scheme that similates an app that used to have a different scheme, using x-fd://open?name=test2
and so on.
To test Handoff
NOTE: The demo app does not support data sync (if anybody knows how we can make a sample app that works with sync without requiring any developer portal shenanigans to build and run, please let us know!).
So Handoff support is "faked" at the moment in that the demo app will send the name of the file to the receiving device as part of the Handoff data, and if the receiving device has a document of the same name it will open it – but the content will differ and the photo attachment will not be sent across either.
You will need to build the app for two devices. You cannot test Handoff with the simulator.
- Build and run the app on two iOS devices that use the same iCloud account
- Create a series of documents on one device, giving them useful text in the content so you can see which is which
- Tap one of the documents to open it on the first device.
- On the second device, make sure the app is not already running and go to the task switcher, dock or lock screen and look for the Handoff icon from "FlintDemo"
- Tap on the icon / perform the required gesture and the app should open.
To test Spotlight
It's a bit of a hack but as a proof of concept, FlintDemo will register any document you open with Spotlight as part of the Handoff registration also.
To test it:
- Create a series of documents on one device, giving them useful text in the content so you can see which is which, using some unique words
- Go to the home screen, pull down for search, and type in some of those "unique words" or "Flint demo" to see the documents
- Tap a document to open the app on that document
To test Siri
- On your device or simulator, go to Settings > Developer and turn on the debugging options to show all recent shortcuts
- Create at least one document in the app with a simple title like "Testing"
- Pull down to search with Siri and see recent activities and shortcuts listed, there will be "Open Testing" which is an activity, and "Get document with name "Testing"". The latter is the intent-based shortcut. Tap to show the contents of the note in Siri.
- Alternatively, in the FlintDemo app you can view a note and tap the "Add to Siri" button at the top right to add a voice shortcut that will open the app at that document.