A guard to help you check if you make UI changes not in main thread

Overview

ODUIThreadGuard

ODUIThreadGuard is a guard to help check if you make UI changes not in main thread.

As Xcode 9 embedded this function into Xcode, there is no reason to maintain this project in the feature, Happy Coding.

Carthage compatible CocoaPods Support Swift Version License MIT

ODUIThreadGuard is a guard to help check if you make UI changes not in main thread. Highly recommend you add this file to your project as early as possible.

ScreenShot

Features

  • Passive implementation
  • Throw an assertion if setNeedsDisplay, setNeedsLayout, or setNeedsDisplayInRect: is called for instantiation of any UIView
  • Get the thread stack to help you locate where you make the mistake

Usage

No matter which way you use ODUIThreadGuard, no need to import any files, it is a extension of UIView, so it will work automatically.

CocoaPods

You can use CocoaPods to install ODUIThreadGuard by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'ODUIThreadGuard'

Then drop ODUIThreadGuard.swift into your porject.

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/YourLibrary.framework to an iOS project.

github "olddonkey/ODUIThreadGuard"

Manually

  1. Download and drop ODUIThreadGuard.swift in your project.
  2. Congratulations!

You can change the pre compile flag to change the setting, in default, this only runs in DEBUG mode, so won't affect users in Release.

Requirements

  • iOS 8.0+
  • Swift 3

The main development of ODUIThreadGuard is based on Swift 3.

Contact

Follow and contact me through email: [email protected]. If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.

License

ODUIThreadGuard is released under the MIT license. See LICENSE for details.

Comments
  • Very confused about usage

    Very confused about usage

    The README says there's "no need to import any files, it is a extension of UIView, so it will work automatically" but then in a later paragraph it seems you need to drag a file into your project to use it? Unclear how to get this working. Dragging and dropping a file into one's project sort of nullifies the point of using Cocoapods. :)

    opened by dlo 2
  • Carthage support

    Carthage support

    opened by TofPlay 2
  • Possible naming problem

    Possible naming problem

    Hi, nice library.

    Not really sure if this is a problem, that's why I did not do the pull request.

    But, shouldn't your own swizzled methods, call the original implementations (and not itself) ?

    func guardSetNeedsLayout() {
            checkThread()
            guardSetNeedsLayout() <----
        }
    
        func guardSetNeedsDisplay() {
            checkThread()
            guardSetNeedsDisplay() <----
        }
    
        func guardSetNeedsDisplayInRect(_ rect: CGRect) {
            checkThread()
            guardSetNeedsDisplayInRect(rect) <-----
        }
    
    opened by danlozano 2
  • 使用时机 Help wanted

    使用时机 Help wanted

    /// It is better to use a debug flag here for not add this extension to Release build. (You don't want user see App crash) 这句注释有点歧义,不应该在Release版本打开,为什么这样?

    我的理解是 在Debug版本去掉,Release打开,把问题尽量暴露在测试开发阶段,上线之后打开,多一层保护,防止异常。

    opened by Beyond-Chao 1
  • I cannot make this run

    I cannot make this run

    Hello, I tried both cocoa pods and manually adding the .swift file but I am still not getting the logs. I tried exactly the same thing as you have in demo but no luck, any idea what could be wrong ?

    opened by SebastianKumor 1
Releases(1.1.0)
  • 1.1.0(Jan 15, 2017)

Owner
Old Donkey
@Google
Old Donkey
Class for logging excessive blocking on the main thread

Watchdog Class for logging excessive blocking on the main thread. It watches the main thread and checks if it doesn’t get blocked for more than define

Wojtek Lukaszuk 1.8k Dec 6, 2022
**`withCheckedContinuation`'s body will run on background thread in case of starting from main-actor.**

ConcurrencyContinuationReproduce Differences of Concurrency behaviors between Xcode 14.0 and 14.1 Xcode 14.0 iOS 13+: Runs on main (inherited same con

Hiroshi Kimura 4 Dec 20, 2022
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Takuya Aso 3 Dec 3, 2021
An iOS app that helps you check, edit and delete metadata of photos, including but not limited to EXIF, TIFF...

MetaX A simple iOS app that helps you check, edit and delete metadata of photos, including but not limited to EXIF, TIFF... Feature List main metadata

Yuhan Chen 189 Dec 29, 2022
Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Not Apple Autolayout wrapper. Provides placeholders. Linux support.

CGLayout Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Has cross-hierarchy coordinate space. Implemen

Koryttsev Denis 45 Jun 28, 2022
A replacement for as which runs in constant time instead of O(n) when the conformance is not satisfiedA replacement for as which runs in constant time instead of O(n) when the conformance is not satisfied

ZConform A replacement for as? which runs in constant time instead of O(n) when the conformance is not satisfied. How it works ZConform does a one-tim

Emerge Tools 20 Aug 4, 2022
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.

TinyConsole TinyConsole is a tiny log console to display information while using your iOS app and written in Swift. Usage Wrap your Main ViewControlle

Devran Cosmo Uenal 2k Jan 3, 2023
Overload +-*/ operator for Swift, make it easier to use (and not so strict)

Easy-Cal-Swift Overview This file is an overloading of +-*/ operator for Swift, to make it easier to use (and not so strict) It can make your life wit

Wei Wang 272 Jun 29, 2022
MyWeight is a body mass tracker focused on make easy to input new data and check your weight history

MyWeight MyWeight is a body mass tracker focused on make easy to input new data and check your weight history. Getting Started Environment prerequisit

Diogo Tridapalli 71 Nov 2, 2022
A platform where NYUAD students can both Help and Seek Help.

A platform where NYUAD students can both Help and Seek Help.

Omar Rayyan 0 Nov 7, 2021
ADVANCED APP DESIGN The main goal of this mini project is to inspire you on what we can accomplish with the SwiftUI framework.

Restart-App.0.2 ADVANCED APP DESIGN The main goal of this mini project is to inspire you on what we can accomplish with the SwiftUI framework. COMPLEX

Noye Samuel 1 Dec 11, 2021
BowTies - The main purpose of this application is to show how you can perform simple operations using Core Data

BowTies The main purpose of this application is to show how you can perform simp

slemeshaev 1 Jan 31, 2022
The main goal of this mini project is to inspire you on what we can accomplish with the SwiftUI framework.

COMPLEX SWIFTUI GESTURES We will create such a custom button with complex gestures that we can not find in Apple’s stock user interface library. PARALLAX EFFECT By using multiple movements in the opposite direction (parallax effect) we can add depth to this amazing onboarding screen.

Ghullam Abbas 4 Oct 17, 2022
ToDoList - An ios app that help users to set their todos and make it easy to remember this todos

An ios app that help users to set their todos and make it easy to remember this todos by reminders them when todo time's up, this app make sure that you don't forget any todos that you want to do just give it to the app and let the app hundle it for you.

Ahmed Mahrous 1 Apr 25, 2022
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 42 Oct 4, 2022
A framework which helps you attach observers to `UIView`s to get updates on its frame changes

FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn't use any Method S

null 11 Jul 25, 2022
Example project guide you schedules multiple thread for network requests in RxSwift, which is optimize your app's performance better.

RxSwift-Multi-Threading-Example Example project guide you schedules multiple thread for network requests in RxSwift, which is optimize your app's perf

Huy Trinh Duc 6 Nov 4, 2022
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
Sample app to demonstrate data sharing between a WatchKit app and its main app using Realm

#Done! A sample app demonstrating how to share data between an app an its Watch extension using Realm. You can read more about it here. ##Screenshot #

Fancy Pixel 147 Dec 8, 2022