Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event.

Related tags

Utility Butterfly
Overview

Butterfly

Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event.

Goals of this project

One of the main issues accross the iOS development is the feedback of new features and bug report.

The most common way is to use mailto to send a dry and boring email :

let str = "mailto:[email protected][email protected]&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!"
let url = NSURL(string: str)
UIApplication.sharedApplication().openURL(url)

Butterfly provides an elegant way to present users' feedback as easy as possible.

Quick Look

Installation

via CocoaPod

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Butterfly', '~> 0.3.15'

Manually

$ git submodule add https://github.com/wongzigii/Butterfly.git
  • Open the Butterfly folder, and drag Butterfly.xcodeproj into the file navigator of your app project, under your app project.
  • In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "Build Phases" panel.
  • Add Butterfly.framework within the "Target Dependencies"
  • Click on the + button at the top left of "Build Phases" panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add Butterfly.framework.

Usage

import Butterfly
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    ButterflyManager.sharedManager.startListeningShake()
    let uploader = ButterflyFileUploader.sharedUploader
    uploader.setValue( "sample", forParameter: "folderName" )
    uploader.setServerURLString("https://myserver.com/foo")
    return true
}

Upload

ButterflyViewController protocol method invoked when send button pressed. You can conform this protocol to handle the image uploading. However, in Xcode Version 6.4 (6E35b) with Swift 2.0, there currently seems to be no way to call static (class) methods defined in a protocol (in pure Swift). Considering this issue, Butterfly included the ButterflyFileUploader to handle uploading stuff in v0.3.13. The ButterflyFileUploader class is an encapsulation under Alamofire 's upload API.

func ButterflyViewControllerDidPressedSendButton(drawView: ButterflyDrawView?) {
    if let image = imageWillUpload {
        let data: UIImage = image
        ButterflyFileUploader.sharedUploader.addFileData( UIImageJPEGRepresentation(data,0.8), withName: currentDate(), withMimeType: "image/jpeg" )
    }
        
    ButterflyFileUploader.sharedUploader.upload()
    print("ButterflyViewController 's delegate method [-ButterflyViewControllerDidEndReporting] invoked\n")
}

Configuration of ButterflyFileUploader

// @discussion Make sure your serverURLString is valid before a further application. 
// Call `setServerURLString` to replace the default "http://myserver.com/uploadFile" with your own's.
public var serverURLString: String? = "http://myserver.com/uploadFile"
    
///
/// Set uploader 's server URL
///
/// @param     URL         The server URL.
///
public func setServerURLString( URL: String ) {
    serverURLString = URL
}

///
/// Add one file or multiple files with file URL to uploader.
///
/// @param    url          The URL of the file whose content will be encoded into the multipart form data.
///
/// @param    name         The name to associate with the file content in the `Content-Disposition` HTTP header.
///
/// @param    mimeType     The MIME type to associate with the data in the `Content-Type` HTTP header.
///
public func addFileURL( url: NSURL, withName name: String, withMimeType mimeType: String? = nil ) {
    files.append( ButterflyFileUploadInfo( name: name, withFileURL: url, withMimeType: mimeType ) )
}

///
/// Add one file or multiple files with NSData to uploader.
///
/// @param    data         The data to encode into the multipart form data.
///
/// @param    name         The name to associate with the file content in the `Content-Disposition` HTTP header.
///
/// @param    mimeType     The MIME type to associate with the data in the `Content-Type` HTTP header.
///
public func addFileData( data: NSData, withName name: String, withMimeType mimeType: String = "application/octet-stream" ) {
    files.append( ButterflyFileUploadInfo( name: name, withData: data, withMimeType: mimeType ) )
}

For further information, please check out ButterflyFileUploader.swift.

Contact

Follow me on Twitter

License

Butterfly is under MIT LICENCE, see the LICENCE file for more info.

You might also like...
Simple and Lightweight App Version Tracking for iOS written in Swift

AEAppVersion Simple and lightweight iOS App Version Tracking written in Swift I made this for personal use, but feel free to use it or contribute. For

GenStore is a lightweight swift code generator for your resources.
GenStore is a lightweight swift code generator for your resources.

GenStore is a lightweight swift code generator for your resources. GenStore can create classes for your images, colors and localized strings.

Lightweight utilities for making OSLog more pleasant

UnifiedLoggingPlus Lightweight utilities for making OSLog more pleasant. Integration Swift Package Manager

Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

ZIP Foundation is a library to create, read and modify ZIP archive files.
ZIP Foundation is a library to create, read and modify ZIP archive files.

ZIP Foundation is a library to create, read and modify ZIP archive files. It is written in Swift and based on Apple's libcompression for high performa

Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos)

Focus Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos) that is inspired by Haskell's Lens library. Introduction Foc

📘A library for isolated developing UI components and automatically taking snapshots of them.
📘A library for isolated developing UI components and automatically taking snapshots of them.

A library for isolated developing UI components and automatically taking snapshots of them. Playbook Playbook is a library that provides a sandbox for

A Swift micro library for generating Sunrise and Sunset times.

Solar A Swift helper for generating Sunrise and Sunset times. Solar performs its calculations locally using an algorithm from the United States Naval

Plugin and runtime library for using protobuf with Swift

Swift Protobuf Welcome to Swift Protobuf! Apple's Swift programming language is a perfect complement to Google's Protocol Buffer ("protobuf") serializ

Comments
  • Fixed typographical error, changed accross to across in README.

    Fixed typographical error, changed accross to across in README.

    @wongzigii, I've corrected a typographical error in the documentation of the Butterfly project. You should be able to merge this pull request automatically. However, if this was intentional or if you enjoy living in linguistic squalor, please let me know and create an issue on my home repository.

    opened by orthographic-pedant 1
  • Call protocol method

    Call protocol method

    During Xcode Version 6.4 (6E35b) with Swift 2.0, there currently seems to be no way to call static (class) methods defined in a protocol (in pure Swift).

    See the following radar report: https://openradar.appspot.com/20119848

    For the purpose of sending images or texts by pressing the send button, it is recommend to upload the useful information of you application manually, instead of Butterfly's delegate method.

    Let me know more about what you think if you guys have a greater solution.

    enhancement help wanted 
    opened by wongzigii 1
  • Not working!

    Not working!

    Hi,

    Version 0.3.15 is using some deprecated API. I looked and it seems that Butterfly.podspec latest changes are causing that (hence - 0.3.15 points to a very early version).

    Please fix..

    Thanks!

    opened by SysAider 0
  • Looks Good!

    Looks Good!

    Hi there, I've checked this and it looks good.

    Just wanted to let you know that Zhihu are actually using our product (https://instabug.com) in their production app which provides them with this feature. The product has a lot more interesting features in case you want to check it.

    Let me know if you need any help!

    opened by mzsoliman 1
Releases(0.4.0)
Owner
Zigii Wong
Think different
Zigii Wong
A danger-swift plug-in to report xcresult in your PR

DangerSwiftKantoku A danger-swift plug-in report xcresult in your PR. Install DangerSwiftKantoku SwiftPM (Recommended) Add dependency package to your

YUMEMI Inc. 9 Nov 18, 2022
Swordinator is a simple way of integrating an iOS Coordinator pattern.

Swordinator is a minimal, lightweight and easy customizable navigation framework for iOS applications. Requirements iOS 14.0+, Swift 5.0+ Installation

Timotheus Laubengaier 10 Oct 17, 2022
Steps and files needed to reproduce a CSP bug in Safari Web Extensions

CSP Safari bug repro There appears to be a discrepancy between how Safari handles CSP policies for extension pages compared to how other browsers do s

Brian Birtles 0 Nov 6, 2021
Monitor changes to files and directories using kernel event notifications (kqueue) in Swift

SKQueue SKQueue is a Swift libary used to monitor changes to the filesystem. It wraps the part of the kernel event notification interface of libc, kqu

Daniel Pedersen 86 Oct 26, 2022
Swift 3 framework for accessing data in Event Registry

Swift 3 framework for accessing data in Event Registry

Pavel Pantus 8 Nov 1, 2016
Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.

SheeKit Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of UISheetPresentationController and other UIKit features. Overview She

Eugene Dudnyk 67 Dec 31, 2022
An open source Instapaper clone that features apps and extensions that use native UI Components for Mac and iOS.

TODO: Screenshot outdated Hipstapaper - iOS and Mac Reading List App A macOS, iOS, and iPadOS app written 100% in SwiftUI. Hipstapaper is an app that

Jeffrey Bergier 51 Nov 15, 2022
Showcase new features after an app update similar to Pages, Numbers and Keynote.

WhatsNew Description WhatsNew automatically displays a short description of the new features when users update your app. This is similar to what happe

Patrick Balestra 1.5k Jan 4, 2023
WhatsNewKit enables you to easily showcase your awesome new app features.

WhatsNewKit enables you to easily showcase your awesome new app features. It's designed from the ground up to be fully customized to your needs. Featu

Sven Tiigi 2.8k Jan 3, 2023
A lightweight extension to Swift's CollectionDifference, supporting moves in addition to removals and insertions, critical when updating interfaces and managing reference types.

DifferenceTracker is a lightweight extension to Swift's CollectionDifference. It defines moves in addition to removals and insertions, critical when updating interfaces and managing reference types.

Giles Hammond 2 Nov 25, 2022