{"id":1194,"url":"https://github.com/kirankunigiri/Apple-Family","last_synced_at":"2025-07-30T20:33:05.251Z","repository":{"id":99289559,"uuid":"76707186","full_name":"kirankunigiri/Apple-Family","owner":"kirankunigiri","description":"A simple framework that brings Apple devices together - like a family","archived":false,"fork":false,"pushed_at":"2017-06-15T21:35:58.000Z","size":12170,"stargazers_count":67,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-19T23:51:34.215Z","etag":null,"topics":["bluetooth","connectivitiy","data","ios","macos","usb","wifi"],"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/kirankunigiri.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-12-17T06:05:07.000Z","updated_at":"2024-04-18T08:35:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"9f73fa4c-f647-4f51-8726-fed00b0bb0d8","html_url":"https://github.com/kirankunigiri/Apple-Family","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirankunigiri%2FApple-Family","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirankunigiri%2FApple-Family/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirankunigiri%2FApple-Family/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirankunigiri%2FApple-Family/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirankunigiri","download_url":"https://codeload.github.com/kirankunigiri/Apple-Family/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187610,"owners_count":17882335,"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":["bluetooth","connectivitiy","data","ios","macos","usb","wifi"],"created_at":"2024-01-05T20:15:40.975Z","updated_at":"2024-12-04T20:31:10.305Z","avatar_url":"https://github.com/kirankunigiri.png","language":"Swift","funding_links":[],"categories":["Hardware"],"sub_categories":["Bluetooth","Other free courses"],"readme":" ![Banner](Images/Banner.gif)\n# Apple Family ![Platform](https://img.shields.io/badge/platform-iOS+macOS-677cf4.svg)\n![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n![Build Passing](https://img.shields.io/badge/build-passing-brightgreen.svg)\n\nA simple framework that brings Apple devices together - like a family. It will automatically use bluetooth, wifi, or USB to connect and communicate with other Apple devices and share information. Currently supports iOS and macOS.\n\nThis library is a combination of 2 others I wrote: [Apple Signal](https://github.com/kirankunigiri/Apple-Signal) for wifi and bluetooth communication, and [Peertalk Simple](https://github.com/kirankunigiri/peertalk-simple) for USB communication. Check them out if you only want one of these features.\n\n## Demo\n\n ![Banner](Images/FamilyDemo.gif)\n\n\n## Installation\n\nGrab the files from the source folder and drag them to your project! You also need to have [peertalk](https://github.com/rsms/peertalk) by Rasmus installed.\n\n\n## Example\n\nFamily is simple to setup. Just start the connection, and you can start sending and receiving data! **Check out the  Xcode demo project for a full implementation .**\n\n#### Setup\n\nStart the connection. Specify a port number, which can be any 4 digit number, and a service type, which is a string limited to 15 characters and 1 hyphen. In order to be discovered, a device must use the same port number and service type. There are also multiple connection types for wifi/bluetooth connectivity. Check the [Signal](https://github.com/kirankunigiri/Apple-Signal) docs for a description of each Signal type.\n\n```swift\nFamily.instance.delegate.addDelegate(delegate: self)\nFamily.instance.initialize(portNumber: 2345, serviceType: \"family-example\", signalType: .Automatic)\n```\n\nNext, we also need to run a method in the App Delegate when the app restarts because the usb connection automatically disconnects when the iPhone is put to sleep. \n\n```swift\nfunc applicationDidBecomeActive(_ application: UIApplication) {\n    Family.instance.reconnect()\n}\n```\n\n#### Send Data\n\nIn Family, you can add a tag to the data you send so that the receiver knows what the data is. You can create a `UInt32` enum to manage them. Here's an example:\n\n```swift\nenum DataType: UInt32 {\n    case string = 100\n    case image = 101\n}\n```\n\nSend some text, and specify its type using our enum. Family automatically converts objects to data using `NSKeyedArchiver`, so if you want to send your own data, use the `sendData` method instead.\n\n```swift\nFamily.instance.sendObject(object: \"Hello World!\", type: DataType.string.rawValue)\n```\n\n#### Receive Data (Protocol)\n\nThe protocol conformation. We get the data, check its type, convert it back to the according object, and update our UI. The class has an extension to the Data class - the method `convert()` - that uses the NSKeyedArchiver class to convert data back into the object you need. You can also update the list of connected devices with the second method.\n\n```swift\nfunc family(didReceiveData data: Data, ofType type: UInt32) {\n    if type == DataType.string.rawValue {\n        let string = data.convert() as! String\n    } else if type == DataType.image.rawValue {\n        let image = UIImage(data: data)\n    }\n}\n\nfunc family(connectedDevicesChanged devices: [String]) {}\n```\n\nAnd we just setup communication session between devices. It's that simple!\n\n\n## Contribute\nFeel free to to contribute to the project with a pull request or open up an issue for any new features or bug fixes.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirankunigiri%2FApple-Family","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirankunigiri%2FApple-Family","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirankunigiri%2FApple-Family/lists"}