Use _NS_4445425547 or NS🐞 for enables debuggging panel. When enabled it, a ladybug 🐞 menu appears in the app menu bar.
“4445425547” means DEBUG in Unicode table.
0x44=D
0x45=E
0x42=B
0x55=U
0x47=G
Of the many tools available for fuzzing, I've found that LLVM's libfuzzer is the easiest to use for Swift on macOS. Other tools seem to have a list of requirements taht are difficult to meet. libfuzzer on the other hand is built into LLVM and is available on macOS in the custom Swift toolchains: https://www.swift.org/download/
In this document I'll describe how to use libfuzzer with Swift and Swift Packages.
I used this setup to fuzz an SVG Renderer package that I am building. I was able to find and fix a number of bugs in my SVG parsing code using libfuzzer in basically no time at all.
| import SwiftUI | |
| import Combine | |
| public struct ChangeObserver<V: Equatable>: ViewModifier { | |
| public init(newValue: V, action: @escaping (V) -> Void) { | |
| self.newValue = newValue | |
| self.newAction = action | |
| } | |
| private typealias Action = (V) -> Void |
| /// Classes whose initializers actually create derived classes | |
| protocol FactoryInitializable { | |
| /// The type of the least-derived class declared to be FactoryInitializable. | |
| /// | |
| /// - Warning: Do not define this in your FactoryInitializable type! | |
| associatedtype FactoryBase: AnyObject, FactoryInitializable = Self | |
| // This associatedtype is a trick that captures `Self` at the point where | |
| // `FactoryInitializable` enters a class hierarchy; in other contexts, `Self` | |
| // refers to the most-derived type. | |
| } |
| /// A repository of functionality depending on the conformances of `Model`. | |
| /// | |
| /// Conditional conformances provide implementation functions that take a | |
| /// generic argument type with the safe assumption that the argument's concrete | |
| /// type is `Model`. | |
| struct Dispatch<Model> { | |
| /// Returns `f(a as! Model) as! R1` | |
| /// | |
| /// Used by implementation functions to avoid the clutter of casting | |
| /// explicitly. |
| func testIsBidirectional() { | |
| func assert<C: Collection>(_ collection: C, isBidirectional: Bool) { | |
| XCTAssertEqual(collection.isBidirectional, isBidirectional) | |
| } | |
| assert([1, 2, 3], isBidirectional: true) | |
| assert(Set([1, 2, 3]), isBidirectional: false) | |
| } | |
| extension Collection { |
| // | |
| // ContentView.swift | |
| // Layout | |
| // | |
| // Created by Matt Gallagher on 7/6/19. | |
| // Copyright © 2019 Matt Gallagher. All rights reserved. | |
| // | |
| import SwiftUI |
| #!/usr/bin/env python3 | |
| # let's say you have a C++ project in Nix that you want to work on with CLion so that the Nix dependencies are available | |
| # put this script in your project directory | |
| # then, in Settings -> Build, Execution, Deployment -> Toolchains set CMake to this script | |
| # if you need any extra nix-shell arguments, add them to the invocation at the bottom | |
| import os | |
| import sys | |
| import shlex |
| As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation | |
| Strings: | |
| _NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently. | |
| - May have 8 bit (ASCII) or 16 bit (UTF-16) backing store | |
| _NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo" | |
| - May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM | |
| NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings | |
| NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers. |