### LookinServer Error Domain and Codes Source: https://context7.com/qmui/lookinserver/llms.txt Example of creating an NSError object for LookinServer timeouts. This demonstrates how to construct error objects with specific domains and codes for LookinServer-related issues. ```objc // Error domain and codes NSError *err = [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_Timeout userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}]; ``` -------------------------------- ### LookinServer Version and Port Constants Source: https://context7.com/qmui/lookinserver/llms.txt Logs framework and protocol versions, and iterates through device port candidates. Ensure LookinServer is integrated and configured for debugging. ```objc // Version negotiation NSLog(@"Framework version : %@", LOOKIN_SERVER_READABLE_VERSION); // "1.2.8" NSLog(@"Protocol version : %d", LOOKIN_SERVER_VERSION); // 7 // Port ranges (server listens on the first available port in each range) // Device : 47175 – 47179 // Simulator: 47164 – 47169 for (int port = LookinUSBDeviceIPv4PortNumberStart; port <= LookinUSBDeviceIPv4PortNumberEnd; port++) { NSLog(@"Device port candidate: %d", port); } ``` -------------------------------- ### Integrate LookinServer via CocoaPods (Swift Project) Source: https://github.com/qmui/lookinserver/blob/develop/README.md Use this command to integrate LookinServer for Swift projects via CocoaPods. Ensure you are using a Debug configuration. ```ruby pod 'LookinServer', :subspecs => ['Swift'], :configurations => ['Debug'] ``` -------------------------------- ### Integrate LookinServer via CocoaPods (Objective-C Project) Source: https://github.com/qmui/lookinserver/blob/develop/README.md Use this command to integrate LookinServer for Objective-C projects via CocoaPods. Ensure you are using a Debug configuration. ```ruby pod 'LookinServer', :configurations => ['Debug'] ``` -------------------------------- ### Integrate LookinServer with CocoaPods (Swift) Source: https://context7.com/qmui/lookinserver/llms.txt Adds the Swift subspec for Swift projects to enable automatic ivar discovery via reflection. This integration is for Debug builds only. ```ruby use_frameworks! target 'MyApp' do pod 'LookinServer', :subspecs => ['Swift'], :configurations => ['Debug'] end ``` -------------------------------- ### Integrate LookinServer with CocoaPods (Swift + NoHook) Source: https://context7.com/qmui/lookinserver/llms.txt Combines Swift reflection support with the NoHook flag to disable Objective-C runtime hooks. Use the SwiftAndNoHook subspec for this configuration. ```ruby # Podfile – CocoaPods does not support mixing subspecs and configurations # so use the combined SwiftAndNoHook subspec instead target 'MyApp' do pod 'LookinServer', :subspecs => ['SwiftAndNoHook'], :configurations => ['Debug'] end ``` -------------------------------- ### Objective-C UIView subclass with custom debug info Source: https://context7.com/qmui/lookinserver/llms.txt Implement `lookin_customDebugInfos` on a UIView subclass to provide custom data to Lookin. This method is called on every refresh, so it must be performant. Use `retainedSetter` with caution to avoid retain cycles. ```objc // CatView.m #import "CatView.h" @implementation CatView // Called on every Lookin refresh — keep it fast. - (NSDictionary *)lookin_customDebugInfos { return @{ // "properties" → shown in Lookin's right-hand attribute panel @"properties": @[ @{ @"section": @"CatInfo", // optional group header @"title": @"Nickname", // required @"value": @"Whiskers", // required (omit key if value is nil) @"valueType": @"string", // required — see value types below // "retainedSetter" lets the user edit the value live in Lookin. // WARNING: Lookin retains this block forever — avoid retain cycles. @"retainedSetter": ^(NSString *newValue) { NSLog(@"User changed nickname to: %@", newValue); } }, @{ @"section": @"CatInfo", @"title": @"Age", @"value": @8, @"valueType": @"number", @"retainedSetter": ^(NSNumber *n) { /* update model */ } } ], // "title" → overrides the default class name shown in the left hierarchy panel @"title": @"CustomCatView", // "subviews" → inject virtual (non-UIKit) children into the hierarchy tree @"subviews": @[ @{ @"title": @"Fake Subview", @"subtitle": @"optional subtitle", // "frameInWindow" draws a wireframe overlay in Lookin's canvas. // CGRect must be expressed relative to the window, not the parent. @"frameInWindow": [NSValue valueWithCGRect:CGRectMake(100, 100, 200, 300)], @"properties": @[ @{ @"section": @"Meta", @"title": @"ID", @"value": @42, @"valueType": @"number" } ], // Virtual subviews can themselves have nested subviews @"subviews": @[ @{ @"title": @"GrandchildNode" } ] } ] }; } @end ``` -------------------------------- ### LookinServer Request Type Constants Source: https://context7.com/qmui/lookinserver/llms.txt Reference for LookinServer request type constants, useful for custom tooling. These constants define the types of requests that can be made to the LookinServer. ```objc // Request type constants (for reference / custom tooling) // LookinRequestTypePing = 200 // LookinRequestTypeApp = 201 // LookinRequestTypeHierarchy = 202 // LookinRequestTypeHierarchyDetails = 203 // LookinRequestTypeInbuiltAttrModification = 204 // LookinRequestTypeCustomAttrModification = 214 ``` -------------------------------- ### Swift UIView Subclass with Custom Debug Info Source: https://context7.com/qmui/lookinserver/llms.txt Implement `lookin_customDebugInfos` in a Swift UIView subclass to provide custom debug information. Use `@objc` for runtime visibility and `unsafeBitCast` for Swift closures as retained setters. ```swift // BirdView.swift import UIKit class BirdView: UIView { // Use lookin_customDebugInfos_1 if a superclass/category already uses // the base name, e.g.: @objc func lookin_customDebugInfos_1() -> [String: Any]? @objc func lookin_customDebugInfos() -> [String: Any]? { return ["properties": makeProperties()] } private func makeProperties() -> [Any] { // --- string --- var strProp: [String: Any] = [ "section": "BirdInfo", "title": "Nickname", "value": "Jerry", "valueType": "string" ] let strSetter: @convention(block) (String?) -> Void = { newValue in print("Nickname changed to \(newValue ?? "nil")") } strProp["retainedSetter"] = unsafeBitCast(strSetter, to: AnyObject.self) // --- number --- var numProp: [String: Any] = [ "section": "BirdInfo", "title": "Age", "value": 4.53, "valueType": "number" ] let numSetter: @convention(block) (NSNumber) -> Void = { newNumber in print("Age changed to \(newNumber.doubleValue)") } numProp["retainedSetter"] = unsafeBitCast(numSetter, to: AnyObject.self) // --- bool --- var boolProp: [String: Any] = [ "section": "BirdInfo", "title": "IsAlive", "value": true, "valueType": "bool" ] let boolSetter: @convention(block) (Bool) -> Void = { print("IsAlive: \($0)") } boolProp["retainedSetter"] = unsafeBitCast(boolSetter, to: AnyObject.self) // --- color --- var colorProp: [String: Any] = [ "section": "Appearance", "title": "FeatherColor", "value": UIColor.yellow, "valueType": "color" ] let colorSetter: @convention(block) (UIColor?) -> Void = { print("Color: \(String(describing: $0))") } colorProp["retainedSetter"] = unsafeBitCast(colorSetter, to: AnyObject.self) // --- rect --- var rectProp: [String: Any] = [ "section": "Geometry", "title": "WingRect", "value": CGRect(x: 1, y: 2, width: 3, height: 4), "valueType": "rect" ] let rectSetter: @convention(block) (CGRect) -> Void = { print("Rect: \($0)") } rectProp["retainedSetter"] = unsafeBitCast(rectSetter, to: AnyObject.self) // --- size --- let sizeProp: [String: Any] = [ "section": "Geometry", "title": "WingSpan", "value": CGSize(width: 30, height: 5), "valueType": "size" ] // --- point --- let pointProp: [String: Any] = [ "section": "Geometry", "title": "NestLocation", "value": CGPoint(x: 7, y: 8), "valueType": "point" ] // --- insets (Objective-C only; use NSValue in ObjC) --- // In Objective-C: [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(1,2,3,4)] // Swift does not have a direct NSValue(UIEdgeInsets:) bridge; use ObjC for insets. // --- shadow --- let shadowProp: [String: Any] = [ "section": "Appearance", "title": "DropShadow", "valueType": "shadow", "value": [ "opacity": 0.5, "offset": CGSize(width: 5, height: 10), "radius": 2.5, "color": UIColor.black // optional; omit key if color is nil ] ] // --- enum --- var enumProp: [String: Any] = [ "section": "BirdInfo", "title": "Gender", "value": "Female", "valueType": "enum", "allEnumCases": ["Male", "Female", "Unknown"] // required for enum type ] let enumSetter: @convention(block) (String) -> Void = { print("Gender: \($0)") } enumProp["retainedSetter"] = unsafeBitCast(enumSetter, to: AnyObject.self) return [strProp, numProp, boolProp, colorProp, rectProp, sizeProp, pointProp, shadowProp, enumProp] } } ``` -------------------------------- ### Custom Debug Info on CALayer Subclass (Objective-C) Source: https://context7.com/qmui/lookinserver/llms.txt Implement `lookin_customDebugInfos` on a CALayer subclass to provide custom debugging information. Supports string, shadow, and JSON value types. Editable string values can be provided with a `retainedSetter` block. ```objc // DogLayer.m #import "DogLayer.h" @implementation DogLayer - (NSDictionary *)lookin_customDebugInfos { return @{ @"properties": @[ // string + editable setter @{ @"section": @"DogInfo", @"title": @"Nickname", @"value": @"Sushi", @"valueType": @"string", @"retainedSetter": ^(NSString *s) { NSLog(@"New name: %@", s); } }, // shadow (read-only — no retainedSetter) @{ @"section": @"Appearance", @"title": @"Shadow", @"valueType": @"shadow", @"value": @{ @"opacity": @0.5, @"offset": [NSValue valueWithCGSize:CGSizeMake(5, 10)], @"radius": @2.5, @"color": UIColor.redColor } }, // JSON structured data (read-only) @{ @"section": @"Debug", @"title": @"StateJson", @"valueType": @"json", @"value": @"[{{\"title\":\"phase\",\"desc\":\"active\"}}]" } ] }; } @end ``` -------------------------------- ### Integrate LookinServer with CocoaPods (Objective-C) Source: https://context7.com/qmui/lookinserver/llms.txt Integrates LookinServer for Debug builds in an Objective-C project using CocoaPods. Ensure LookinServer is only included in Debug configurations. ```ruby use_frameworks! target 'MyApp' do # Objective-C only project — use the Core subspec (default) pod 'LookinServer', :configurations => ['Debug'] end ``` -------------------------------- ### Swift Ivar Tracing with `LKS_SwiftTraceManager.swiftMarkIVars` Source: https://context7.com/qmui/lookinserver/llms.txt For Swift projects, call `swiftMarkIVars(ofObject:)` within an initializer or `viewDidLoad` to traverse the object graph via Swift reflection. This annotates `UIView`, `CALayer`, `UIViewController`, and `UIGestureRecognizer` ivars with `LookinIvarTrace`, making ivar names visible in Lookin's hierarchy sidebar. This is automatically handled when using the `Swift` CocoaPods subspec or the `SwiftAndNoHook` variant. ```swift // Typical usage — call from the owning object's initializer or viewDidLoad import UIKit // LookinServer is compiled only in Debug; guard with #if to keep Release clean #if DEBUG import LookinServer // or LookinServerSwift when using SPM #endif class HomeViewController: UIViewController { private let headerView = HeaderView() private let footerView = FooterView() private let contentScrollView = UIScrollView() override func viewDidLoad() { super.viewDidLoad() setupLayout() // Mark all UIView/CALayer ivars so Lookin can show their variable names #if DEBUG LKS_SwiftTraceManager.swiftMarkIVars(ofObject: self) #endif } private func setupLayout() { view.addSubview(headerView) view.addSubview(contentScrollView) view.addSubview(footerView) // … Auto Layout constraints … } } // In Lookin's hierarchy panel, subviews will now show names like: // "HomeViewController : UIViewController / headerView" instead of just "HeaderView" ``` -------------------------------- ### Naming Conflict Resolution for `lookin_customDebugInfos` (Objective-C) Source: https://context7.com/qmui/lookinserver/llms.txt When a superclass, subclass, or category on `UIView` already implements `lookin_customDebugInfos`, use numbered suffixes (`_0` to `_5`) to avoid naming collisions. All variants are called and their results merged by Lookin. ```objc // UIView+Custom.m — category on UIView; uses _0 to avoid name collision @implementation UIView (Custom) - (NSDictionary *)lookin_customDebugInfos_0 { return @{ @"properties": @[ @{ @"section": @"Appearance", @"title": @"Brightness", @"value": @8.8, @"valueType": @"number" } ] }; } @end ``` -------------------------------- ### Reading `LookinIvarTrace` (Objective-C) Source: https://context7.com/qmui/lookinserver/llms.txt This snippet demonstrates how to access and read `LookinIvarTrace` objects attached to a view, which record the association between a host object and its stored `UIView`/`CALayer` ivars. This is primarily for internal or advanced usage. ```objc // Reading traces attached to a view (internal / advanced usage) #import "LookinIvarTrace.h" UIView *myView = /* … */; NSArray *traces = myView.lks_ivarTraces; for (LookinIvarTrace *trace in traces) { NSLog(@"hostClass=%@ ivarName=%@ relation=%@", trace.hostClassName, trace.ivarName, trace.relation ?: @"(none)"); } // Example output: // hostClass=MyApp.HomeViewController : UIViewController // ivarName=headerView // relation=superview ``` -------------------------------- ### Integrate LookinServer with Swift Package Manager Source: https://context7.com/qmui/lookinserver/llms.txt Adds LookinServer as a remote Swift package dependency. This method is suitable for adding LookinServer via Xcode's package management interface or programmatically. ```swift dependencies: [ .package(url: "https://github.com/QMUI/LookinServer/", branch: "main") ], targets: [ .target( name: "MyApp", dependencies: [.product(name: "LookinServer", package: "LookinServer")] ) ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.