{"id":17690172,"url":"https://github.com/onmyway133/mainthreadguard","last_synced_at":"2026-03-05T16:02:39.005Z","repository":{"id":62447483,"uuid":"49759841","full_name":"onmyway133/MainThreadGuard","owner":"onmyway133","description":":guardsman: Tracking UIKit access on main thread","archived":false,"fork":false,"pushed_at":"2017-06-07T12:35:03.000Z","size":497,"stargazers_count":59,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-12T06:34:27.655Z","etag":null,"topics":["guard","ios","main","queue","thread","ui"],"latest_commit_sha":null,"homepage":"https://onmyway133.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onmyway133.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-16T04:58:27.000Z","updated_at":"2024-12-18T13:48:47.000Z","dependencies_parsed_at":"2022-11-01T23:46:47.418Z","dependency_job_id":null,"html_url":"https://github.com/onmyway133/MainThreadGuard","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/onmyway133/MainThreadGuard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FMainThreadGuard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FMainThreadGuard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FMainThreadGuard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FMainThreadGuard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onmyway133","download_url":"https://codeload.github.com/onmyway133/MainThreadGuard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FMainThreadGuard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30134574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T15:35:27.018Z","status":"ssl_error","status_checked_at":"2026-03-05T15:35:23.768Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["guard","ios","main","queue","thread","ui"],"created_at":"2024-10-24T11:50:01.220Z","updated_at":"2026-03-05T16:02:38.988Z","avatar_url":"https://github.com/onmyway133.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MainThreadGuard\nTracking UIKit access on main thread\n\n[![Version](https://img.shields.io/cocoapods/v/MainThreadGuard.svg?style=flat)](http://cocoapods.org/pods/MainThreadGuard)\n[![License](https://img.shields.io/cocoapods/l/MainThreadGuard.svg?style=flat)](http://cocoapods.org/pods/MainThreadGuard)\n[![Platform](https://img.shields.io/cocoapods/p/MainThreadGuard.svg?style=flat)](http://cocoapods.org/pods/MainThreadGuard)\n![Swift](https://img.shields.io/badge/%20in-swift%203.0-orange.svg)\n\n![](Screenshots/Banner.png)\n\n## Description\n\nThis is just a Swift port of [PSPDFUIKitMainThreadGuard.m](https://gist.github.com/steipete/5664345) using swizzling on `UIView` extension\n\n## Usage\n\nCall `Guard.setup` \n\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n  // setup\n\n  Guard.setup()\n\n  return true\n}\n```\n\n## Features\n\nIt works by swizzling in the following methods\n\n- setNeedsLayout\n- setNeedsDisplay\n- setNeedsDisplayInRect:\n\nTry accessing UIKit from another thread and MainThreadGuard will assert\n\n```swift\nclass ViewController: UIViewController {\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n    view.backgroundColor = UIColor.white\n\n    let label = UILabel()\n    view.addSubview(label)\n\n    DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {\n      label.text = \"Setting text on background thread\"\n    }\n  }\n}\n```\n\n## Xcode 9+\n\nXcode 9+ has [Main Thread Checker](https://developer.apple.com/documentation/code_diagnostics/main_thread_checker), which detects invalid use of AppKit, UIKit, and other APIs from a background thread.\n\n## Installation\n\nMainThreadGuard is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\nYou should add this to Debug configuration only\n\n```ruby\npod \"MainThreadGuard\", git: 'https://github.com/onmyway133/MainThreadGuard', configurations: 'Debug'\n```\n\n## Author\n\nKhoa Pham, onmyway133@gmail.com\n\n## License\n\nMainThreadGuard is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmyway133%2Fmainthreadguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonmyway133%2Fmainthreadguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmyway133%2Fmainthreadguard/lists"}