https://github.com/leonatan/lnpropertylisteditor
A property list editor for AppKit, similar to the editor in Xcode.
https://github.com/leonatan/lnpropertylisteditor
editor macos objective-c plist property-lists swift
Last synced: 7 months ago
JSON representation
A property list editor for AppKit, similar to the editor in Xcode.
- Host: GitHub
- URL: https://github.com/leonatan/lnpropertylisteditor
- Owner: LeoNatan
- License: mit
- Created: 2018-04-16T02:40:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T21:06:35.000Z (almost 2 years ago)
- Last Synced: 2025-02-11T13:51:15.255Z (8 months ago)
- Topics: editor, macos, objective-c, plist, property-lists, swift
- Language: Objective-C
- Homepage:
- Size: 3.66 MB
- Stars: 103
- Watchers: 12
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# LNPropertyListEditor
A property list editor for macOS, similar to the one implemented in Xcode, but with several quality of life additions, such as a visual date/time picker and a full hex editor for data objects.
The framework has full support for macOS light and dark appearance.
By implementing the `LNPropertyListEditorDataTransformer` protocol, you can significantly augment the way property list data is presented in the editor and represented on-disk.


## Adding to Your Project
### Swift Package Manager
Swift Package Manager is the recommended way to integrate LNPropertyListEditor in your project.
LNPropertyListEditor supports SPM versions 5.1.0 and above. To use SPM, you should use Xcode 11 to open your project. Click `File` -> `Swift Packages` -> `Add Package Dependency`, enter `https://github.com/LeoNatan/LNPropertyListEditor`. Select the version you’d like to use.
You can also manually add the package to your Package.swift file:
```swift
.package(url: "https://github.com/LeoNatan/LNPropertyListEditor.git", from: "1.0")
```And the dependency in your target:
```swift
.target(name: "BestExampleApp", dependencies: ["LNPropertyListEditor"]),
```### Carthage
Add the following to your Cartfile:
```github "LeoNatan/LNPropertyListEditor"```
Make sure you follow the Carthage integration instructions [here](https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos).
### Manual
Drag the `LNPropertyListEditor.xcodeproj` project to your project, and add `LNPropertyListEditor.framework` to **Embedded Binaries** in your project target's **General** tab. Xcode should sort everything else on its own.
### CocoaPods
CocoaPods is not supported. There are many reasons for this. Instead of CocoaPods, use Carthage. You can continue using CocoaPods for for your other dependencies and Carthage for `LNPropertyListEditor`.
## Using the Framework
### Swift
While the framework is written in Objective C, it uses modern Objective C syntax, so using the framework in Swift should be very easy and intuitive.
### Project Integration
Import the module in your project:
```objective-c
@import LNPropertyListEditor;
```### Usage
Either using Interface Builder or in code, add an `LNPropertyListEditor` view to your user interface.
To set a represented object, set the `propertyList` property.
```swift
guard let propertyListURL = Bundle.main.url(forResource: "Some", withExtension: "plist"),
let propertyListData = try? Data(contentsOf: propertyListURL),
let propertyListObject = try? PropertyListSerialization.propertyList(from: propertyListData, options: [], format: nil) as? [String: AnyObject] else {
return
}plistEditor.propertyListObject = propertyListObject
```Supported object types: Dictionaries, arrays, strings, dates, datas, booleans and numbers (dictionaries and arrays can contains nested children of the aforementioned types).
#### Delegate
Implement the `LNPropertyListEditorDelegate` protocol to listen to various events, or control what aspects of the property list can be edited.
```swift
plistEditor.delegate = self
//...
func propertyListEditor(_ editor: LNPropertyListEditor, didChange node: LNPropertyListNode, changeType: LNPropertyListNodeChangeType, previousKey: String?) {
switch changeType {
case .insert:
print("🎉")
case .move:
print("➡️")
case .update:
print("🔄")
case .delete:
print("🗑")
@unknown default:
fatalError()
}
}
```For full documentation, see the `LNPropertyListEditor.h` header.
#### Data Transformer
Implement the `LNPropertyListEditorDataTransformer` protocol to provide display and data transformations for your property list objects.
```swift
plistEditor.dataTransformer = self
//...
func propertyListEditor(_ editor: LNPropertyListEditor, displayNameFor node: LNPropertyListNode) -> String? {
// ...
if let key = node.key,
key == "CFBundleShortVersionString" {
return "Bundle version string (short)"
}
//...
}
```For full documentation, see the `LNPropertyListEditor.h` header.
## Acknowledgements
The framework uses:
* [HexFiend](https://github.com/HexFiend/HexFiend) © ridiculous_fish, 2011-2020