All Projects → ToBeDefined → TPreventUnrecognizedSEL

ToBeDefined / TPreventUnrecognizedSEL

Licence: MIT license
Use TPreventUnrecognizedSEL can make you project prevent the unrecognized selector crash

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to TPreventUnrecognizedSEL

RuntimeBPs
This project allows for visual scripting in UE4 similar to Blueprints, but at runtime. The way this is set up does not make use of any UE4 boilerplate and could with a few adjustments be used in another engine.
Stars: ✭ 77 (+352.94%)
Mutual labels:  runtime
openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,973 (+17388.24%)
Mutual labels:  runtime
NetEaseBaymaxDemo
仿网易大白健康系统写的一个小工具,仅当学习交流使用
Stars: ✭ 37 (+117.65%)
Mutual labels:  runtime
blueboat
All-in-one, multi-tenant serverless JavaScript runtime.
Stars: ✭ 1,832 (+10676.47%)
Mutual labels:  runtime
WARDuino
A dynamic WebAssembly VM for embedded systems
Stars: ✭ 51 (+200%)
Mutual labels:  runtime
distribution
Siddhi streaming runtime and tooling distribution
Stars: ✭ 22 (+29.41%)
Mutual labels:  runtime
UnityNativeTool
Allows to unload native plugins in Unity3d editor
Stars: ✭ 147 (+764.71%)
Mutual labels:  runtime
TWVM
A tiny, lightweight and efficient WebAssembly virtual machine.
Stars: ✭ 105 (+517.65%)
Mutual labels:  runtime
lua-in-js
A Lua to JS transpiler / runtime
Stars: ✭ 37 (+117.65%)
Mutual labels:  runtime
m2ee-tools
m2ee, the Mendix runtime helper tools for GNU/Linux
Stars: ✭ 23 (+35.29%)
Mutual labels:  runtime
libclosure-KCBuild
libclosure-74-79编译 - 最新Block底层源码编译,大家可以轻松Block源码调试 查看_Block_copy 还有 __block底层操作...
Stars: ✭ 71 (+317.65%)
Mutual labels:  runtime
hex
An ecosystem delivering practices, philosophy and portability. Powered By Deno and JavaScript.
Stars: ✭ 48 (+182.35%)
Mutual labels:  runtime
inclavare-containers
A novel container runtime, aka confidential container, for cloud-native confidential computing and enclave runtime ecosystem.
Stars: ✭ 510 (+2900%)
Mutual labels:  runtime
quickjs-build
Build for QuickJS JavaScript Engine
Stars: ✭ 25 (+47.06%)
Mutual labels:  runtime
lambda-runtime-pypy3.5
AWS Lambda Runtime for PyPy 3.5
Stars: ✭ 17 (+0%)
Mutual labels:  runtime
node-mini
Mini Node.js runtime built on V8
Stars: ✭ 24 (+41.18%)
Mutual labels:  runtime
wazero
wazero: the zero dependency WebAssembly runtime for Go developers
Stars: ✭ 2,065 (+12047.06%)
Mutual labels:  runtime
permissionUtil
Simple permission helper
Stars: ✭ 64 (+276.47%)
Mutual labels:  runtime
chameleon-runtime
chameleon 运行时框架
Stars: ✭ 32 (+88.24%)
Mutual labels:  runtime
openpai-runtime
Runtime for deep learning workload
Stars: ✭ 17 (+0%)
Mutual labels:  runtime

TPreventUnrecognizedSEL

platform  Carthage compatible  CocoaPods  Build Status  License MIT

Features

  • Using runtime to dynamically add methods to prevent Unrecognized Selector errors prevents the app from crashing due to missing object and class methods.

    Instance method: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TestClass losted:instance:method:]: unrecognized selector sent to instance 0x102c....'

    Class method: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[TestClass losted:class:method:]: unrecognized selector sent to class 0x10000....'

  • Can get the specific information of the missing method, including:

    • The class name of the missing class method or object method;
    • The name of the missing method;
    • The missing object method or class method.

Installation

Source File

The source file contains two module directories: TPUSELNormalForwarding and TPUSELFastForwarding; Drag all the files inside the Sources folder in the corresponding module directory into you project.

⚠️Note: you can only use one of the modules to use, the module directory corresponding to all the files inside the Sources file can be dragged into the project. It is recommended to use TPUSELNormalForwarding because some methods of the system use fast forwarding

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate TPreventUnrecognizedSEL into your Xcode project using CocoaPods, specify it in your Podfile:

# (pod 'TPreventUnrecognizedSEL') default is use (pod 'TPreventUnrecognizedSEL/NormalForwarding')
pod 'TPreventUnrecognizedSEL/NormalForwarding'

or this:

pod 'TPreventUnrecognizedSEL/FastForwarding'

Then, run the following command:

$ pod install

⚠️Note: you can only use one of the subspec, NormalForwarding or FastForwarding

⚠️Use pod 'TPreventUnrecognizedSEL' default is pod 'TPreventUnrecognizedSEL/NormalForwarding'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate TPreventUnrecognizedSEL into your Xcode project using Carthage, specify it in your Cartfile:

github "tobedefined/TPreventUnrecognizedSEL"

Run carthage update to build the framework and drag the built TPUSELNormalForwarding.framework or TPUSELFastForwarding.framework into your Xcode project.

⚠️Note: You can only use one of the two frameworks, TPUSELNormalForwarding.framework or TPUSELFastForwarding.framework.

How to use

Simple Use

After the project is imported, simply set which Classes to forward.

Get Run error message

Import Header
Module and lang \ Import module mode Source File CocoaPods Carthage
TPUSELNormalForwarding & ObjC #import "TPUSELNormalForwarding.h" #import <TPreventUnrecognizedSEL/TPUSELNormalForwarding.h> #import <TPUSELNormalForwarding/TPUSELNormalForwarding.h>
TPUSELNormalForwarding & Swift add in Bridging-Header import TPreventUnrecognizedSEL import TPUSELNormalForwarding
TPUSELFastForwarding & ObjC #import "TPUSELFastForwarding.h" #import <TPreventUnrecognizedSEL/TPUSELFastForwarding.h> #import <TPUSELFastForwarding/TPUSELFastForwarding.h>
TPUSELFastForwarding & Swift add in Bridging-Header import TPreventUnrecognizedSEL import TPUSELFastForwarding
Set Forwarding and Block

In the main() function of the APP's main.m file or in the APP's didFinishLaunching method add the following code to get the specific information about the missing method:

TPUSELNormalForwarding
// Setting does not process NSNull and its subclasses, the default is NO
[NSObject setIgnoreForwardNSNullClass:YES];
// Set the class and its subclasses in the array to not be processed (the class name in the array can be a Class type or an NSString type). By default, no class is ignored.
[NSObject setIgnoreForwardClassArray:@[@"SomeIgnoreClass1", [SomeIgnoreClass2 Class]]];
// Set to process only the classes in the array and their subclasses (the class name in the array can be either a Class or an NSString type). By default, all classes are handled.
[NSObject setJustForwardClassArray:@[@"SomeClass1", [SomeClass2 Class]]];
// Set callback after processing
[NSObject setHandleUnrecognizedSELErrorBlock:^(Class  _Nonnull __unsafe_unretained cls, SEL  _Nonnull selector, UnrecognizedMethodType methodType, NSArray<NSString *> * _Nonnull callStackSymbols) {
    // DO SOMETHING
    // like upload to server or print log or others
}];
TPUSELFastForwarding
// Set to process only the classes in the array and their subclasses (the class name in the array can be either a Class or an NSString type). By default, all classes are NOT handled.
// Set callback after processing
[NSObject setJustForwardClassArray:@[@"SomeClass1", [SomeClass2 Class]]
   handleUnrecognizedSELErrorBlock:^(Class  _Nonnull __unsafe_unretained cls, SEL  _Nonnull selector, UnrecognizedMethodType methodType, NSArray<NSString *> * _Nonnull callStackSymbols) {
       // DO SOMETHING
       // like upload to server or print log or others
   }];
Some Definitions

The following definitions and methods are in NSObject+TPUSELFastForwarding.h or NSObject+TPUSELNormalForwarding.h

typedef NS_ENUM(NSUInteger, UnrecognizedMethodType) {
    UnrecognizedMethodTypeClassMethod       = 1,
    UnrecognizedMethodTypeInstanceMethod    = 2,
};

typedef void (^ __nullable HandleUnrecognizedSELErrorBlock)(Class cls,
                                                            SEL selector,
                                                            UnrecognizedMethodType methodType,
                                                            NSArray<NSString *> *callStackSymbols);
  • cls: Class type; the Class of missing instance method or class method, NSStringFromClass(cls) can be used to return the NSString for the class name
  • selector: SEL type; the missing method name, NSStringFromSelector(selector) can be used to return the NSString for the method name
  • methodType: UnrecognizedMethodType type; for the missing method type (class method or object method)
  • callStackSymbols: NSArray<NSString *> * type; call stack infomations
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].