{"id":20580822,"url":"https://github.com/soffes/x","last_synced_at":"2025-04-09T10:09:41.493Z","repository":{"id":31199173,"uuid":"34759954","full_name":"soffes/X","owner":"soffes","description":"Easier cross platform Mac \u0026 iOS development with Swift","archived":false,"fork":false,"pushed_at":"2021-12-16T18:16:55.000Z","size":93,"stargazers_count":276,"open_issues_count":1,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-02T03:24:04.449Z","etag":null,"topics":["carthage","ios","macos","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":null,"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/soffes.png","metadata":{"files":{"readme":"Readme.markdown","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-04-28T22:46:49.000Z","updated_at":"2025-02-16T02:44:01.000Z","dependencies_parsed_at":"2022-09-18T22:40:36.739Z","dependency_job_id":null,"html_url":"https://github.com/soffes/X","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soffes","download_url":"https://codeload.github.com/soffes/X/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018061,"owners_count":21034048,"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":["carthage","ios","macos","swift","tvos","watchos"],"created_at":"2024-11-16T06:25:39.283Z","updated_at":"2025-04-09T10:09:41.473Z","avatar_url":"https://github.com/soffes.png","language":"Swift","readme":"# X\n\n[![Version](https://img.shields.io/github/release/soffes/x.svg)](https://github.com/soffes/X/releases)\n![Swift Version](https://img.shields.io/badge/swift-5.1-orange.svg)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nEasier *cross* platform Mac and iOS development with Swift 5.1. X was abstracted out of [Redacted](http://useredacted.com) and [Whiskey](http://usewhiskey.com).\n\nXcode 11.1 or higher is required.\n\n\n## Installation\n\n[Carthage](https://github.com/carthage/carthage) is the recommended way to install X. Add the following to your Cartfile:\n\n``` ruby\ngithub \"soffes/X\"\n```\n\n## Usage\n\nX provides several `typealias`es to make dealing with AppKit/UIKit types that are similar. Currently, X includes:\n\n| Name                                                      | UIKit                      | AppKit                     |\n|-----------------------------------------------------------|----------------------------|----------------------------|\n| [`Color`](X/Color.swift)                                  | `UIColor`                  | `NSColor`                  |\n| [`ContentMode`](X/ContentMode.swift)                      | `UIViewContentMode`        |  N/A                        |\n| [`EdgeInsets`](X/EdgeInsets.swift)                        | `UIEdgeInsets`             | `NSEdgeInsets`             |\n| [`Font`](X/Font.swift)                                    | `UIFont`                   | `NSFont`                   |\n| [`GestureRecognizerStateType`](X/GestureRecognizer.swift) | `UIGestureRecognizerState` | `NSGestureRecognizerState` |\n| [`Image`](X/Image.swift)                                  | `UIImage`                  | `NSImage`                  |\n| [`Screen`](X/Screen.swift)                                | `UIScreen`                 | `NSScreen`                 |\n| [`ViewType`](X/View.swift)                                | `UIView`                   | `NSView`                   |\n\n\nIf you wanted to use a color on both platforms, you could write something like this:\n\n``` swift\nlet blueColor = Color(red:0.298, green:0.757, blue:0.988, alpha: 1.0)\n```\n\n\n### View\n\n[`View`](X/View.swift) inherits from `ViewType` (so either `UIView` or `NSView`) and adds some platform specific functionality. This makes methods like `layoutSubviews` work on both platforms. The UIKit API is cleaner, so NSView has methods added in `View` to make it behave more like `UIView`.\n\nHere's the current list of bridged methods that work on both:\n\n``` swift\nvar wantsLayer: Bool      // On iOS, this doesn't do anything and always returns `true`.\nfunc didMoveToWindow()    // Bridged from `viewDidMoveToWindow`\nfunc didMoveToSuperview() // Bridged from `didMoveToSuperview`\nfunc layoutSubviews()     // Bridged from `layout`\n```\n\n### Core Graphics\n\nThere are several extensions for [`CGPoint`](X/CGPoint.swift), [`CGSize`](X/CGSize.swift), and [`CGRect`](X/CGRect.swift) that help with converting to and from strings since UIKit and AppKit have different function names. The UIKit function names are aliased on Mac. There are also initializers and computed properties you can use instead of the functions.\n\nEnjoy.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoffes%2Fx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fx/lists"}