{"id":15037811,"url":"https://github.com/rebeloper/swiftyplistmanager","last_synced_at":"2025-04-09T23:33:10.276Z","repository":{"id":169311266,"uuid":"88765330","full_name":"rebeloper/SwiftyPlistManager","owner":"rebeloper","description":"Lightweight plist data management framework for iOS 10.3+","archived":false,"fork":false,"pushed_at":"2020-04-10T11:13:12.000Z","size":2740,"stargazers_count":77,"open_issues_count":9,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-08T17:50:11.903Z","etag":null,"topics":["apple","datamanager","ios","plis-tool","plist","read-write","swift-3","swift-4","swift4"],"latest_commit_sha":null,"homepage":"http://rebeloper.com","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/rebeloper.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-19T16:12:53.000Z","updated_at":"2024-08-12T06:47:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"4457578a-26e5-4851-b1ac-76808fda88a7","html_url":"https://github.com/rebeloper/SwiftyPlistManager","commit_stats":null,"previous_names":["rebeloper/swiftyplistmanager"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FSwiftyPlistManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FSwiftyPlistManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FSwiftyPlistManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FSwiftyPlistManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebeloper","download_url":"https://codeload.github.com/rebeloper/SwiftyPlistManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129985,"owners_count":21052676,"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":["apple","datamanager","ios","plis-tool","plist","read-write","swift-3","swift-4","swift4"],"created_at":"2024-09-24T20:35:48.609Z","updated_at":"2025-04-09T23:33:10.245Z","avatar_url":"https://github.com/rebeloper.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![SwiftyPlistManager](https://github.com/rebeloper/SwiftyPlistManager/blob/master/SwiftyPlistManager/SwiftyPlistManagerLogo.gif?raw=true)\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://mit-license.org)\n[![Platform](http://img.shields.io/badge/platform-ios-lightgrey.svg)](https://developer.apple.com/resources/)\n[![Language](https://img.shields.io/badge/swift-3.1-orange.svg)](https://developer.apple.com/swift)\n[![Language](https://img.shields.io/badge/swift-4-orange.svg)](https://developer.apple.com/swift)\n[![Cocoapod](http://img.shields.io/cocoapods/v/SwiftyPlistManager.svg?style=flat)](http://cocoadocs.org/)\n[![Twitter](https://img.shields.io/badge/twitter-@rebeloper-blue.svg?maxAge=2592000)](http://twitter.com/rebeloper)\n\nSwiftyPlistManager is a lightweight plist data management framework for iOS 10.3+\n\n## Step by step tutorial\n\nI have written a [blog post on rebeloper.com](http://rebeloper.com/read-write-plist-file-swift/) with even more info on the usage of SwiftyPlistManager and handy images.\n\n## YouTube series on how to use SwiftyPlistManager\n\nNow you can watch my YouTube video series on how to use SwiftyPlistManager [here](https://www.youtube.com/watch?v=q5v6tqWdXiI\u0026list=PL_csAAO9PQ8bKg79CX5PEfn886SMMDj3j).\n\n## Screenshots\n![Save data](https://github.com/rebeloper/SwiftyPlistManager/blob/master/SwiftyPlistManager/spm019.jpg?raw=true)\n![Get data](https://github.com/rebeloper/SwiftyPlistManager/blob/master/SwiftyPlistManager/spm023.jpg?raw=true)\n![Fetch data](https://github.com/rebeloper/SwiftyPlistManager/blob/master/SwiftyPlistManager/spm024.jpg?raw=true)\n\n## Setup\n\nSwiftyPlistManager needs template plist files to use them as the starting point of your data saving and loading. Basically on the first launch of the app it will copy it into it's Document directory and after that you'll be interacting with this copied version of the plist.\n\nJust drag and drop (or create) your plist file(s) into your project. Optionaly you could edit the values to reflect your desired datastructure.\n\n## Starting SwiftyPlistManager\n\n**IMPORTANT**: You always have to \"start\" SwiftyPlistManager on every launch of your app. Let's assume you have an empty `Data.plist` file added to your project and you want to log Add the next line of code to your `application(_:didFinishLaunchingWithOptions:)` function in `Appdelegate.swift`\n\n```swift\nSwiftyPlistManager.shared.start(plistNames: [\"Data\"], logging: true)\n```\n\nSet `logging` to `true` if you want to log what's going on under the hood. Optionally, set it to `false` before release or when you are fed up with too much text in the console.\n\nThe `plistNames` parameter takes in an array of `String`s. You may start SwiftyPlistManager with as many plist file names as you'd like.\n\n```swift\nSwiftyPlistManager.shared.start(plistNames: [\"Data\", \"OtherData\"], logging: true)\n```\n\n## Usage\n### Add new value\n\nBefore you can interact with any key-value pair you need to add it to your data structure. All types that are supported in plist files are suported. SwiftyPlistManager uses completion handlers so you can know when the operation has completed.\n\n```swift\nSwiftyPlistManager.shared.addNew(\"helloNewValue\", key: \"newKey\", toPlistWithName: \"Data\") { (err) in\n  if err == nil {\n    print(\"Value successfully added into plist.\")\n  }\n}\n```\n\n### Save value\n\nNext you want to edit your value. You just need to `save` a new value.\n\n```swift\nSwiftyPlistManager.shared.save(\"helloNewValue\", forKey: \"newKey\", toPlistWithName: \"Data\") { (err) in\n  if err == nil {\n    print(\"Value successfully saved into plist.\")\n  }\n}\n```\n\n### Get value\n\nIf you want to get back the value in a completion handler you'll get back your `result` as an `Any?` object.\n\n```swift\nSwiftyPlistManager.shared.getValue(for: \"newKey\", fromPlistWithName: \"Data\") { (result, err) in\n  if err == nil {\n    print(\"The Value is: '\\(result ?? \"No Value Fetched\")'\")\n  }\n}\n```\n\n### Fetch value\n\nMost of the times you want to cast yor result into a constant right away and not wait for the completion handler to finish. You can use the following call to do just that. For this example we'll unwrap it with a `guard-let` statement.\n\n```swift\nguard let fetchedValue = SwiftyPlistManager.shared.fetchValue(for: \"newKey\", fromPlistWithName: \"Data\") else { return }\n```\n\n### Remove key-value pair\n\nOnce in a while you might want to remove a key-value pair.\n\n```swift\nSwiftyPlistManager.shared.removeKeyValuePair(for: \"newKey\", fromPlistWithName: \"Data\") { (err) in\n  if err == nil {\n    print(\"Key-Value pair successfully removed from plist\")\n  }\n}\n```\n\n### Remove all key-value pairs\n\nOr you might want to delete all the data from your plist file.\n\n```swift\nSwiftyPlistManager.shared.removeAllKeyValuePairs(fromPlistWithName: \"Data\") { (err) in\n  if err == nil {\n    print(\"Successfully removed all Key-Value pairs from plist\")\n  }\n}\n```\n\nNote: this will not remove the plist from disk. It will just empty it from all the key-value pairs.\n\n### Error handling\n\nLet's talk about error-handling. When performing calls with SwiftyPlistManager you get access to possible errors in the completion handlers.\n\n```swift\npublic enum SwiftyPlistManagerError: Error {\n  case fileNotWritten\n  case fileDoesNotExist\n  case fileUnavailable\n  case fileAlreadyEmpty\n  case keyValuePairAlreadyExists\n  case keyValuePairDoesNotExist\n}\n```\n\n## Installation\n### CocoaPods\n\nSwiftyPlistManager can be installed as a [CocoaPod](https://cocoapods.org/) and builds as a Swift framework. To install, include this in your Podfile.\n\n```ruby\nuse_frameworks!\n\npod 'SwiftyPlistManager'\n```\n\nOnce installed, just ```import SwiftyPlistManager``` in your classes and you're good to go.\n\n### Manualy\n\nClone or download the repo. Find the `SwiftyPlistManager.swift` file. Drag and drop it into your project and you're set up.\n\n## Swift 3.1\n\n| Language  | Branch | Pod version | Xcode version |\n| --------- | ------ | ----------- | ------------- |\n| Swift 3.1 | [master](https://github.com/rebeloper/SwiftyPlistManager/tree/master) | \u003e= 1.0.1 | Xcode 8.3 or greater|\n| Swift 4 | [master](https://github.com/rebeloper/SwiftyPlistManager/tree/master) | \u003e= 1.0.1 | Xcode 9 or greater|\n\n## Change Log\n\nSee the [Releases Page](https://github.com/rebeloper/SwiftyPlistManager/releases)\n\n## Known caveats\n\n* You can manipulate the plist file only on the root-keys. Nested key-value pairs (like elemnts in a dictionary) cannot be accessed directly. You'll need to get the whole dictionary from the plist, make your changes, than finally save your changed dictionary back into the plist.\n* The actual saving takes place under the hood in the Document directory. Because of this your changes will not be reflected in the plist file you added into your project.\n\n## Sample Code\nThe project includes a demo app for iOS with a sample [ViewController.swift](https://github.com/rebeloper/SwiftyPlistManager/blob/master/SwiftyPlistManager/ViewController.swift) showing how to use SwiftyPlistManager.\n\n## License\n\n[MIT License](https://github.com/rebeloper/SwiftyPlistManager/blob/master/LICENSE.md)\n\nCopyright (c) 2017 Alex Nagy\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebeloper%2Fswiftyplistmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebeloper%2Fswiftyplistmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebeloper%2Fswiftyplistmanager/lists"}