Commit d3d5356a authored by Aral Balkan's avatar Aral Balkan

Update readme

parent 8b875bf9
......@@ -2,8 +2,6 @@
A singleton that broadcasts touch events from the main window as notifications. See the demo app for a use case (to find out the location of a link that was clicked in a WKWebView).
**This is the master branch (Swift 2.2.1).** Also available: [Swift 2.3](https://source.ind.ie/project/global-touch-notifications/tree/swift-2.3) and [Swift 3](https://source.ind.ie/project/global-touch-notifications/tree/swift-3) branch
## Installation
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
......@@ -28,10 +26,13 @@ To stay on Swift 2.2, use the 5.0.0 tag:
git "git@source.ind.ie:project/global-touch-notifications.git" ~> 5.0.0
```
## Demo
### 2. Add the framework to your Xcode project
[Follow the instructions on Carthage’s readme](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
1. Run the `./install` script to install the dependencies for the demo apps.
## Demo
1. Run the `./install` script to install the dependencies for the demo app.
2. Run the `./dev` script and play with the iOS demo app.
## Usage
......@@ -43,63 +44,29 @@ import GlobalTouchNotifications
import Handle
// Initialise the singleton if necessary
GlobalTouchNotifications.sharedInstance
_ = GlobalTouchNotifications.shared
// Register for global touch notification
handle(GlobalTouchNotification.named(.TouchesBegan)
handle(GlobalTouchNotification.named(.touchesBegan))
{
/* with */ notification in
guard let
userInfo = notification.userInfo,
touches = userInfo["touches"] as? Set<UITouch>,
event = userInfo["event"] as? UIEvent
guard
let userInfo = notification.userInfo,
let touches = userInfo["touches"] as? Set<UITouch>,
let event = userInfo["event"] as? UIEvent
else
{
fatalError("Could not unwrap userInfo dictionary for global touches.")
}
// Do something with touches and event here…
print("First touch: \(touches.first)")
}
```
(Above example also uses the [Handle](https://source.ind.ie/project/handle) library for elegant notification handling.)
## Detailed installation instructions
### Carthage
1. Add the framework to your `Cartfile`. e.g.,
```git "git@source.ind.ie:project/global-touch-notifications.git" "swift-3"
2. [Follow the instructions on Carthage’s readme](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
### Manual
#### iOS
This requires hacking the Xcode project file but it’s still the most elegant way of doing things. If you want a better way, [dupe this radar for seamless support of fat frameworks in Xcode](http://openradar.appspot.com/radar?id=4951631992979456).
1. Build the framework target.
2. In Xcode, add the framework to the Embedded Binaries section.
3. Edit the `project.pbxproj` (in the <your-project>.xcodeproj folder) file and replace the line that reads something like:
```A79882251C259F730043754A /* GlobalTouchNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlobalTouchNotifications.framework; path = "../../path/in/DerivedData/to/GlobalTouchNotifications.framework"; sourceTree = "<group>"; };```
With:
```A79882251C259F730043754A /* GlobalTouchNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlobalTouchNotifications.framework; path = "$(CONFIGURATION_BUILD_DIR)/GlobalTouchNotifications.framework"; sourceTree = "<group>"; };```
(In other words, you’re replacing the hardcoded path to the framework within your particular Derived Data folder with a generic one. This means that anyone else who checks out your project will get the correct framework.)
#### OS X
1. Just drag the framework into the Linked Frameworks and Binaries section of your project (under General).
(For an example of manually adding the framework, see the iOS and OS X demo apps that ship with this framework.)
## Credits
Copyright © Aral Balkan.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment