Copilot instructions
.github/copilot-instructions.mdCopilot instructions
Quality
85/100
Scores the file, not the repository.Length
1,576 words
44 headings · 16 code blocksRepository
17k
— · pushed 69 days agoLast changed
3 days ago
First indexed 3 days ago.1# IQKeyboardManager23IQKeyboardManager is an iOS library available in both Objective-C and Swift versions that provides automatic keyboard management functionality. The library includes comprehensive demo applications and supports CocoaPods, Carthage, and Swift Package Manager.45Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.67## Working Effectively89### Environment Requirements10- **CRITICAL**: This is an iOS-specific library that requires macOS with Xcode for full development11- Minimum Xcode 15 for Demo projects12- Minimum Xcode 13 for library development13- iOS 13.0+ target for both Objective-C and Swift versions14- Swift 5.7+ supported1516### Dependency Management and Setup17**ALWAYS** perform these steps in order for fresh repository setup:18191. **Install CocoaPods** (on macOS only):20```bash21 gem install cocoapods --user-install22 export PATH=$HOME/.local/share/gem/ruby/3.2.0/bin:$PATH23```24252. **Install dependencies** (macOS only - NEVER CANCEL - takes 5-10 minutes):26```bash27 cd /path/to/IQKeyboardManager28 pod install --repo-update29```30 Set timeout to 15+ minutes. This downloads all dependencies including SwiftLint.31 **NOTE**: `pod install` fails in sandboxed environments due to network restrictions.32333. **Verify Swift Package Manager dependencies** (works on both macOS and Linux - takes ~2 seconds):34```bash35 swift package resolve36```37 This resolves all SPM dependencies successfully even on Linux.38394. **Show dependency tree**:40```bash41 swift package show-dependencies42```4344### Build and Test45**IMPORTANT**: Full builds require macOS with Xcode installed. Linux environments can only validate Swift Package Manager dependency resolution.4647#### On macOS with Xcode:481. **Build Demo Applications** (NEVER CANCEL - takes 10-15 minutes):49```bash50 cd /path/to/IQKeyboardManager51 xcodebuild -workspace Demo.xcworkspace -scheme DemoSwift -sdk iphonesimulator clean build52 xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator clean build53```54 Set timeout to 30+ minutes for each command.55562. **Run UI Tests** (NEVER CANCEL - takes 15-20 minutes):57```bash58 xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.0' test59```60 Set timeout to 45+ minutes.6162#### On Linux (Limited Validation):63- **Dependency resolution works**: `swift package resolve` (takes ~2 seconds)64- **Dependency analysis works**: `swift package show-dependencies`65- **Building FAILS**: `swift build` fails with "no such module 'UIKit'" error (expected)66- **Cannot run simulators or UI tests**67- **CocoaPods may fail** due to network restrictions in sandboxed environments6869### Linting and Code Quality701. **SwiftLint** (macOS only - installed via CocoaPods):71```bash72 Pods/SwiftLint/swiftlint73```74 **NOTE**: Not available on Linux or when CocoaPods installation fails.75762. **Check formatting** before commits (macOS only):77```bash78 Pods/SwiftLint/swiftlint --fix79```80813. **Manual code review** (any platform):82 - Review Swift files in `IQKeyboardManagerSwift/`83 - Check Objective-C files in `IQKeyboardManager/`84 - Verify integration examples in demo apps8586## Validation8788### Required Manual Testing Scenarios89**ALWAYS** test these scenarios after making changes to keyboard management:90911. **Basic Keyboard Management**:92 - Run DemoSwift app in iOS Simulator93 - Navigate to "UITextField/UITextView example"94 - Tap text fields - verify keyboard shows/hides smoothly95 - Verify toolbar appears above keyboard with Previous/Next/Done buttons96 - Test scrolling behavior when keyboard appears97 - **Validate**: No text fields are obscured by keyboard98992. **Multi-Field Navigation**:100 - Use Previous/Next buttons in toolbar to navigate between text fields101 - Verify focus moves correctly between fields102 - Test with different keyboard types (number pad, email, etc.)103 - **Validate**: All fields are accessible via keyboard navigation1041053. **Configuration Testing**:106 - Open Settings in demo app107 - Toggle "Enable IQKeyboardManager" - verify keyboard behavior changes108 - Test different toolbar management options109 - Verify appearance customization works110 - **Validate**: Settings changes take effect immediately1111124. **Both Platform Testing**:113 - Test identical scenarios in both DemoSwift and DemoObjC apps114 - Ensure Objective-C and Swift versions behave identically115 - **Validate**: Feature parity between both implementations1161175. **Edge Cases**:118 - Test with collection views and table views containing text fields119 - Test with modal presentations and popovers120 - Test device rotation during text input121 - **Validate**: Keyboard management works in complex UI scenarios122123### CI Validation124The project uses Travis CI (`.travis.yml`) with these validation steps:125```bash126xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator127xcodebuild -workspace Demo.xcworkspace -scheme DemoSwift -sdk iphonesimulator128```129130**Always** run these commands locally before committing changes.131132## Key Project Structure133134### Library Files135- `IQKeyboardManager/` - Objective-C version (legacy)136- `IQKeyboardManagerSwift/` - Swift version (current)137 - `IQKeyboardManager/` - Core keyboard management138 - `Appearance/` - UI appearance customization139 - `Resign/` - Keyboard dismissal handling140 - `IQKeyboardToolbarManager/` - Toolbar management141142### Demo Applications143- `Demo/Swift_Demo/` - Swift demonstration app (45 Swift files)144- `Demo/Objective_C_Demo/` - Objective-C demonstration app (28 Objective-C files)145- `DemoObjCUITests/` - UI test suite146147### Dependencies (Swift Package Manager)148The Swift version depends on separate modular libraries:149- IQKeyboardNotification (1.0.5+)150- IQTextInputViewNotification (1.0.8+)151- IQKeyboardToolbarManager (1.1.3+)152- IQKeyboardReturnManager (1.0.5+)153- IQTextView (1.0.5+)154155## Platform-Specific Instructions156157### macOS Development158- Use Xcode 15+ for demo projects159- Open `Demo.xcworkspace` (NOT `Demo.xcodeproj`)160- Build times: 10-15 minutes for clean builds161- UI test runs: 15-20 minutes162163### Linux Development (Limited)164- Can validate Swift Package Manager dependencies only165- Cannot build iOS targets or run simulators166- Use for dependency analysis and non-iOS-specific code review only167168## Validated Commands and Timing169170### Commands That Work on Any Platform171```bash172# Fast dependency resolution (~2 seconds)173swift package resolve174175# Show dependency tree (~1 second)176swift package show-dependencies177178# Basic file exploration and structure analysis179find . -name "*.swift" | wc -l # Count Swift files180find . -name "*.m" | wc -l # Count Objective-C files181```182183### Commands That Work Only on macOS184```bash185# CocoaPods installation (5-10 minutes)186pod install --repo-update187188# Xcode builds (10-15 minutes each)189xcodebuild -workspace Demo.xcworkspace -scheme DemoSwift -sdk iphonesimulator clean build190xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator clean build191192# UI Tests (15-20 minutes)193xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator test194```195196### Commands That Fail on Linux (Expected)197```bash198# Fails with "no such module 'UIKit'" error199swift build200201# May fail due to network restrictions202pod install --repo-update203```204205## Common Tasks206207### Repository Structure Overview208```209IQKeyboardManager/210├── README.md (236 lines) - Main documentation211├── CONTRIBUTING.md (52 lines) - Contribution guidelines212├── Package.swift - Swift Package Manager configuration213├── Podfile - CocoaPods configuration for demo apps214├── Demo.xcworkspace - Xcode workspace (use this, not .xcodeproj)215├── IQKeyboardManager/ - Objective-C version (legacy)216├── IQKeyboardManagerSwift/ - Swift version (current)217│ ├── IQKeyboardManager/ - Core keyboard management (~40KB main file)218│ │ ├── Configuration/ - Runtime configuration classes219│ │ ├── Debug/ - Debug utilities220│ │ ├── Deprecated/ - Backward compatibility221│ │ ├── IQKeyboardManagerExtension/ - UIKit extensions222│ │ └── UIKitExtensions/ - Additional UIKit helpers223│ ├── Appearance/ - UI appearance customization224│ ├── Resign/ - Keyboard dismissal handling225│ └── IQKeyboardToolbarManager/ - Toolbar management226├── Demo/227│ ├── Swift_Demo/ - Swift demonstration app (45 Swift files)228│ │ ├── AppDelegate.swift - Shows basic integration229│ │ └── ViewController/ - Various usage examples230│ └── Objective_C_Demo/ - Objective-C demonstration app (28 .m files)231├── DemoObjCUITests/ - UI test suite232└── Documentation/ - Migration guides for major versions233```234235### Key Files to Check After Changes236- `IQKeyboardManagerSwift/IQKeyboardManager/IQKeyboardManager.swift` - Main library class237- `Demo/Swift_Demo/AppDelegate.swift` - Basic integration example238- `Demo/Objective_C_Demo/AppDelegate.m` - Objective-C integration example239- Any files in `IQKeyboardManagerSwift/IQKeyboardManagerExtension/` when modifying UIKit behavior240241### Basic Usage Integration242**Swift**:243```swift244import IQKeyboardManagerSwift245246// In AppDelegate.swift247IQKeyboardManager.shared.isEnabled = true248IQKeyboardManager.shared.enableAutoToolbar = true249```250251**Objective-C**:252```objc253#import <IQKeyboardManager/IQKeyboardManager.h>254255// In AppDelegate.m256[[IQKeyboardManager sharedManager] setEnable:YES];257```258259### Installation Methods2601. **CocoaPods**: `pod 'IQKeyboardManagerSwift'` or `pod 'IQKeyboardManager'`2612. **Swift Package Manager**: `https://github.com/hackiftekhar/IQKeyboardManager.git`2623. **Carthage**: `github "hackiftekhar/IQKeyboardManager"`263264### Documentation Locations265- `Documentation/` - Migration guides for major versions266- `README.md` - Installation and basic usage267- `CONTRIBUTING.md` - Development guidelines268- Demo apps serve as comprehensive usage examples269270## Troubleshooting271272### Common Issues and Solutions273274**"No such module 'UIKit'" error:**275- Expected on Linux - this is an iOS-only library276- Build and test only on macOS with Xcode277278**CocoaPods installation fails:**279- Check internet connectivity and firewall restrictions280- Try `pod install --verbose` for detailed error messages281- In sandboxed environments, network access may be limited282283**Xcode build fails:**284- Ensure you're opening `Demo.xcworkspace`, not `Demo.xcodeproj`285- Clean build folder: `cmd+shift+k` in Xcode286- Reset simulators if needed287288**UI tests fail:**289- Ensure iOS Simulator is available and running290- Check that test devices match requirements (iOS 13.0+)291- Verify simulator has sufficient disk space292293## CRITICAL: Timeout and Cancellation Guidelines294295### NEVER CANCEL These Commands296Set appropriate timeouts and wait for completion:297298**Swift Package Manager (works on any platform):**299- `swift package resolve` - Takes ~2 seconds, set 60 second timeout300- `swift package show-dependencies` - Takes ~1 second, set 30 second timeout301302**CocoaPods (macOS only):**303- `pod install --repo-update` - Takes 5-10 minutes, set 15+ minute timeout304- NEVER CANCEL during "Installing" or "Generating Pods project" phases305306**Xcode Builds (macOS only):**307- Clean builds: 10-15 minutes, set 30+ minute timeout308- Incremental builds: 2-5 minutes, set 15+ minute timeout309- UI test runs: 15-20 minutes, set 45+ minute timeout310311**Expected Command Failures:**312- `swift build` on Linux - WILL FAIL with UIKit error (this is correct)313- `pod install` in restricted networks - MAY FAIL due to network access314315### Build Command Examples with Timeouts316```bash317# Swift Package Manager (any platform)318timeout 60 swift package resolve319320# CocoaPods (macOS only)321timeout 900 pod install --repo-update # 15 minutes322323# Xcode builds (macOS only)324timeout 1800 xcodebuild -workspace Demo.xcworkspace -scheme DemoSwift -sdk iphonesimulator clean build # 30 minutes325timeout 2700 xcodebuild -workspace Demo.xcworkspace -scheme DemoObjC -sdk iphonesimulator test # 45 minutes326```
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dotnet/maui.github/instructions/integration-tests.instructions.md · 23k | Copilot instructions | setupteststyledo-not | 92/100 | 3 days ago | |
| dotnet/maui.github/instructions/templates.instructions.md · 23k | Copilot instructions | buildteststylearch+1 | 92/100 | 3 days ago | |
| we-promise/sure.github/copilot-instructions.md · 9.3k | Copilot instructions | setuptestlint-formatstyle+10 | 88/100 | 2 days ago | |
| dotnet/maui.github/instructions/sandbox.instructions.md · 23k | Copilot instructions | buildteststyletesting-strategy+4 | 81/100 | 3 days ago | |
| dotnet/maui.github/instructions/uitests.instructions.md · 23k | Copilot instructions | setupbuildteststyle+5 | 79/100 | 3 days ago | |
| envoyproxy/envoy.github/copilot-instructions.md · 29k | Copilot instructions | setupbuildtestlint-format+7 | 77/100 | 2 days ago | |
| dotnet/maui.github/copilot-instructions.md · 23k | Copilot instructions | setuptestlint-formatstyle+6 | 76/100 | 3 days ago | |
| dotnet/maui.github/instructions/ci-copilot-pipeline-security.instructions.md · 23k | Copilot instructions | gitsecuritydeploymentdo-not+1 | 76/100 | 3 days ago |
