Latest 0.4.0
Homepage https://github.com/matis-schotte/Vifra
License MIT
Platforms osx 10.12, watchos 2.0
Authors

Build Status
codebeat badge
codecov
Maintainability
Docs
license

Version
Open Source Helpers
platform
Twitter

Ethereum
Litecoin

Vifra is a framework for macOS, iOS and watchOS that provides simplified access to the device actuator to provide haptic feedback (vibration through the taptic engine).

Requirements

  • Swift >= 4
  • macOS >= 10.12
  • watchOS >= 2.0

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Vifra does support its use on supported platforms.

Once you have your Swift package set up, adding Vifra as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/matis-schotte/Vifra.git", from: "0.4.0")
]

Do not forget to ensure that the deployment target is set to the correct version (e.g. macOS 10.12), and that all necessary Frameworks are linked (e.g. MultitouchSupport.framework). To avoid getting "undefined symbols" the Bridging header should be used. Possible build command could be:

$ swift build -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.12" -Xswiftc "-import-objc-header" -Xswiftc ".build/checkouts/Vifra.git-6919244937016367571/Vifra/Vifra-Bridging-Header.h" -Xlinker -F/System/Library/PrivateFrameworks -Xlinker -lMultitouchSupport && swift run

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Vifra into your Xcode project using Carthage, specify it in your Cartfile:

github "matis-schotte/Vifra" ~> 0.4

Run carthage update to build the framework and drag the built Vifra.framework into your Xcode project.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Vifra into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Vifra'

Then, run the following command:

$ pod install

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate Vifra into your project manually.

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init
  • Add Vifra as a git submodule by running the following command:
$ git submodule add https://github.com/matis-schotte/Vifra.git
  • Open the new Vifra folder, and drag the Vifra.xcodeproj into the Project Navigator of your application’s Xcode project.
  • Select the Vifra.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "General" panel.
  • Click on the + button under the "Embedded Binaries" section.
  • You will see the Vifra.framework somewhere, just select the correct version.
  • And that’s it, try import Vifra!

Usage

You can issue haptic feedback with just any of the following lines using any of the predefined enum values:

Vifra.feedback(.strong)
Vifra.feedback([.strong, .weak, .delay(usec: 500_000), .strong])

Know problems

  • macOS: A private framework is used; it is therefore unlikely to be accepted in the app store.
  • macOS: You cannot enable the sandboxing entitlement; if you do you’ll encounter the error -536870174 during Vifra.setup() which is internally being called from Vifra.feedback().

ToDo

  • Add Carthage support
  • Add iOS support (UIFeedbackGenerator and AudioServicesPlaySystemSound(kSystemSoundID_Vibrate))
  • Update macOS support (NSHapticFeedbackPerformer)

License

Vifra is available under the MIT license. See the LICENSE file for more info.

Author

Matis Schotte, [email protected]

https://github.com/matis-schotte/Vifra

Latest podspec

{
    "name": "Vifra",
    "version": "0.4.0",
    "summary": "Easy Haptic Feedback (Vibration) in Swift",
    "description": "Vifra is a framework for macOS, iOS and watchOS that provides simplified access to the device actuator to provide haptic feedback (vibration through the taptic engine).",
    "homepage": "https://github.com/matis-schotte/Vifra",
    "documentation_url": "https://matis-schotte.github.io/Vifra",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Matis Schotte": "[email protected]"
    },
    "social_media_url": "https://twitter.com/matis_schotte",
    "source": {
        "git": "https://github.com/matis-schotte/Vifra.git",
        "tag": "0.4.0"
    },
    "source_files": "Sources/*.swift",
    "osx": {
        "source_files": "Sources/macOS/*.{h,swift}",
        "frameworks": "MultitouchSupport"
    },
    "platforms": {
        "osx": "10.12",
        "watchos": "2.0"
    },
    "watchos": {
        "source_files": "Sources/watchOS/*.swift"
    },
    "swift_version": "4.0",
    "xcconfig": {
        "FRAMEWORK_SEARCH_PATHS": "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"
    }
}

Pin It on Pinterest

Share This