{"id":13467159,"url":"https://github.com/wongzigii/Butterfly","last_synced_at":"2025-03-26T01:30:30.175Z","repository":{"id":34154712,"uuid":"37994054","full_name":"wongzigii/Butterfly","owner":"wongzigii","description":":airplane: A tiny library for integrating feedback feature. Compatible with Swift 4.0.","archived":true,"fork":false,"pushed_at":"2018-03-06T14:16:40.000Z","size":5669,"stargazers_count":406,"open_issues_count":2,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-25T11:50:06.429Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wongzigii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-24T15:42:42.000Z","updated_at":"2024-09-10T01:18:23.000Z","dependencies_parsed_at":"2022-08-28T20:52:14.971Z","dependency_job_id":null,"html_url":"https://github.com/wongzigii/Butterfly","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongzigii%2FButterfly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongzigii%2FButterfly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongzigii%2FButterfly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongzigii%2FButterfly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wongzigii","download_url":"https://codeload.github.com/wongzigii/Butterfly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245571671,"owners_count":20637375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:00:53.661Z","updated_at":"2025-03-26T01:30:29.453Z","avatar_url":"https://github.com/wongzigii.png","language":"Swift","funding_links":[],"categories":["Libs","Utility [🔝](#readme)","Swift"],"sub_categories":["Utility"],"readme":"\n# Butterfly\n\n\u003cp align=\"leftr\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/Language-%20Swift%20-orange.svg\"\u003e\n\u003cimg src=\"https://img.shields.io/cocoapods/v/Butterfly.svg?style=flat\"\u003e\n\u003cimg src=\"https://img.shields.io/cocoapods/l/Butterfly.svg?style=flat\"\u003e\n\u003cimg src=\"https://img.shields.io/cocoapods/p/Butterfly.svg?style=flat\"\u003e\n\u003c/p\u003e\n\nButterfly is a **lightweight** library for integrating bug-report and feedback features with shake-motion event. \n\n## Goals of this project\n\nOne of the main issues accross the iOS development is the feedback of new features and bug report.\n\nThe most common way is to use `mailto` to send a dry and boring email :\n\n````swift\nlet str = \"mailto:foo@example.com?cc=bar@example.com\u0026subject=Greetings%20from%20Cupertino!\u0026body=Wish%20you%20were%20here!\"\nlet url = NSURL(string: str)\nUIApplication.sharedApplication().openURL(url)\n````\n\nButterfly provides an elegant way to present users' feedback as easy as possible.\n\n## Quick Look\n\n![](./Screenshot/Demo.gif)\n\n## Installation\n\n### via [CocoaPod](http://cocoapods.org/)\n\n    source 'https://github.com/CocoaPods/Specs.git'\n    platform :ios, '8.0'\n    use_frameworks!\n\n    pod 'Butterfly', '~\u003e 0.3.15'\n\n###  Manually\n    \n    $ git submodule add https://github.com/wongzigii/Butterfly.git\n\n- Open the `Butterfly` folder, and drag `Butterfly.xcodeproj` into the file navigator of your app project, under your app project.\n- 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.\n- In the tab bar at the top of that window, open the \"Build Phases\" panel.\n- Add Butterfly.framework within the \"Target Dependencies\"\n- 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.\n\n## Usage\n\n````swift\nimport Butterfly\n````\n\n````swift\nfunc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -\u003e Bool {\n    ButterflyManager.sharedManager.startListeningShake()\n    let uploader = ButterflyFileUploader.sharedUploader\n    uploader.setValue( \"sample\", forParameter: \"folderName\" )\n    uploader.setServerURLString(\"https://myserver.com/foo\")\n    return true\n}\n````\n\n### Upload\n\n`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).\nConsidering this issue, Butterfly included the `ButterflyFileUploader` to handle uploading stuff in v0.3.13. The `ButterflyFileUploader` class is an encapsulation under [Alamofire](https://github.com/Alamofire/Alamofire) 's upload API.\n\n````swift\nfunc ButterflyViewControllerDidPressedSendButton(drawView: ButterflyDrawView?) {\n    if let image = imageWillUpload {\n        let data: UIImage = image\n        ButterflyFileUploader.sharedUploader.addFileData( UIImageJPEGRepresentation(data,0.8), withName: currentDate(), withMimeType: \"image/jpeg\" )\n    }\n        \n    ButterflyFileUploader.sharedUploader.upload()\n    print(\"ButterflyViewController 's delegate method [-ButterflyViewControllerDidEndReporting] invoked\\n\")\n}\n````\n\n### Configuration of ButterflyFileUploader\n\n````swift\n// @discussion Make sure your serverURLString is valid before a further application. \n// Call `setServerURLString` to replace the default \"http://myserver.com/uploadFile\" with your own's.\npublic var serverURLString: String? = \"http://myserver.com/uploadFile\"\n    \n///\n/// Set uploader 's server URL\n///\n/// @param     URL         The server URL.\n///\npublic func setServerURLString( URL: String ) {\n    serverURLString = URL\n}\n\n///\n/// Add one file or multiple files with file URL to uploader.\n///\n/// @param    url          The URL of the file whose content will be encoded into the multipart form data.\n///\n/// @param    name         The name to associate with the file content in the `Content-Disposition` HTTP header.\n///\n/// @param    mimeType     The MIME type to associate with the data in the `Content-Type` HTTP header.\n///\npublic func addFileURL( url: NSURL, withName name: String, withMimeType mimeType: String? = nil ) {\n    files.append( ButterflyFileUploadInfo( name: name, withFileURL: url, withMimeType: mimeType ) )\n}\n\n///\n/// Add one file or multiple files with NSData to uploader.\n///\n/// @param    data         The data to encode into the multipart form data.\n///\n/// @param    name         The name to associate with the file content in the `Content-Disposition` HTTP header.\n///\n/// @param    mimeType     The MIME type to associate with the data in the `Content-Type` HTTP header.\n///\npublic func addFileData( data: NSData, withName name: String, withMimeType mimeType: String = \"application/octet-stream\" ) {\n    files.append( ButterflyFileUploadInfo( name: name, withData: data, withMimeType: mimeType ) )\n}\n````\nFor further information, please check out ButterflyFileUploader.swift.\n\n## Contact\n\n\u003ca href=\"https://twitter.com/wongzigii\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"./Screenshot/twitter64.png\" /\u003e\n\u003c/a\u003e\n\n## License\n\nButterfly is under MIT LICENCE, see the [LICENCE](https://github.com/wongzigii/Butterfly/blob/master/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongzigii%2FButterfly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwongzigii%2FButterfly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongzigii%2FButterfly/lists"}