diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..53397f1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,537 @@ +# BEMCheckBox - Project Reference Guide + +## Project Overview + +BEMCheckBox is an open-source iOS checkbox library that provides beautiful, highly customizable, animated checkboxes. This is a fork of the original [Boris-Em/BEMCheckBox](https://github.com/Boris-Em/BEMCheckBox) repository. + +### Key Technologies +- **Main Library**: Written in Swift +- **Example Project**: Written in Objective-C +- **Minimum iOS Version**: iOS 18 +- **Swift Tools Version**: 6.0+ + +## Project Structure + +``` +BEMCheckBox/ +├── Classes/ # Swift source files for the main library +│ ├── BEMCheckBox.swift # Main checkbox implementation +│ ├── BEMCheckBoxGroup.swift # Radio button group functionality +│ ├── BEMAnimationManager.swift # Animation handling +│ └── BEMPathManager.swift # Path drawing utilities +├── Sample Project/ # Example iOS application (Objective-C) +│ ├── CheckBox.xcodeproj/ # Xcode project file +│ ├── BEMCheckBox/ # Framework header files +│ ├── CheckBox/ # Example app source code +│ ├── CheckBoxTests/ # Unit tests +│ │ ├── CheckBoxTests.m # Basic checkbox functionality tests +│ │ ├── GroupTests.m # Radio button group tests +│ │ └── AnimationManangerTests.m # Animation tests +│ └── CheckBoxUITests/ # UI tests +│ └── CheckBoxUITests.m # UI interaction tests +├── Scripts/ # Build automation scripts +│ └── build-xcframework.sh # Script to build XCFramework +├── Package.swift # Swift Package Manager configuration +├── GitVersion.yml # GitVersion configuration +├── GitReleaseManager.yml # Release manager configuration +├── .github/workflows/ # CI/CD GitHub Actions +│ ├── ci.yml # Main CI workflow +│ └── release-notes.yml # Release notes generation +└── README.md # Main documentation +``` + +## Build Instructions + +### Building the Framework + +#### Using Xcode Command Line Tools + +```bash +# Build for iOS Simulator (excluding arm64 to avoid conflicts) +xcodebuild -sdk iphonesimulator \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme BEMCheckBox \ + -configuration Release \ + EXCLUDED_ARCHS="arm64" + +# Build for iOS Device +xcodebuild -sdk iphoneos \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme BEMCheckBox \ + -configuration Release + +# Build the Sample App +xcodebuild -sdk iphonesimulator \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBox \ + -configuration Debug +``` + +#### Using Swift Package Manager + +**Note**: Building with Swift Package Manager for iOS requires explicit SDK paths and target specifications since this is an iOS-only library. + +##### iOS Simulator (x86_64) + +```bash +# Debug build for iOS Simulator +swift build \ + --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.0.sdk \ + -Xswiftc -target \ + -Xswiftc x86_64-apple-ios18.0-simulator + +# Release build for iOS Simulator +swift build -c release \ + --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.0.sdk \ + -Xswiftc -target \ + -Xswiftc x86_64-apple-ios18.0-simulator +``` + +##### iOS Device (arm64) + +```bash +# Debug build for iOS Device +swift build \ + --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk \ + -Xswiftc -target \ + -Xswiftc arm64-apple-ios18.0 + +# Release build for iOS Device +swift build -c release \ + --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk \ + -Xswiftc -target \ + -Xswiftc arm64-apple-ios18.0 +``` + +##### Build Artifacts + +Build artifacts are located in: +- **Debug builds**: `.build/debug/` +- **Release builds**: `.build/release/` +- **Swift modules**: `BEMCheckBox.swiftmodule` +- **Documentation**: `BEMCheckBox.swiftdoc` + +##### Important Notes for Swift Package Manager + +1. **Swift Version**: Package.swift is configured to use Swift 5 language mode to avoid Swift 6 strict concurrency issues +2. **SDK Versions**: Update SDK paths if using different Xcode versions (check with `xcodebuild -showsdks`) +3. **No Tests**: Swift Package Manager tests are not available as this is an iOS-only library requiring simulator/device +4. **Architecture**: Specify target architecture explicitly for each platform + +### Creating an XCFramework (Recommended) + +The project includes a build script that creates a universal XCFramework supporting both iOS devices and simulators (including Apple Silicon simulators): + +```bash +# Build XCFramework using the automated script +./Scripts/build-xcframework.sh + +# Output will be at: Temp/Release-fat/BEMCheckBox.xcframework +``` + +This script: +1. Builds archives for iOS Simulator (arm64 + x86_64) +2. Builds archives for iOS Device (arm64) +3. Creates an XCFramework from both archives +4. Supports BUILD_LIBRARY_FOR_DISTRIBUTION for better compatibility +5. Includes debug symbols (dSYMs) + +**Note**: XCFramework is the modern Apple-recommended approach and is preferred over fat binaries. + +### Creating a Fat Binary Framework (Legacy) + +**Note**: This approach is deprecated. Use XCFramework instead (see above). + +To create a legacy universal framework that works on both device and simulator: + +```bash +# 1. Build for simulator (excluding arm64) +xcodebuild -sdk iphonesimulator \ + -project "Sample Project/CheckBox.xcodeproj" \ + -derivedDataPath build \ + -scheme BEMCheckBox \ + -configuration Release \ + EXCLUDED_ARCHS="arm64" + +# 2. Build for device +xcodebuild -sdk iphoneos \ + -project "Sample Project/CheckBox.xcodeproj" \ + -derivedDataPath build \ + -scheme BEMCheckBox \ + -configuration Release + +# 3. Create fat binary +cp -R build/Build/Products/Release-iphoneos/ Release-fat +lipo -create -output Release-fat/BEMCheckBox.framework/BEMCheckBox \ + build/Build/Products/Release-iphoneos/BEMCheckBox.framework/BEMCheckBox \ + build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework/BEMCheckBox + +# 4. Verify the fat binary +lipo -info Release-fat/BEMCheckBox.framework/BEMCheckBox +``` + +## Running Tests + +The project includes two test suites: +- **CheckBoxTests**: Unit tests for the BEMCheckBox framework +- **CheckBoxUITests**: UI tests for the sample application (currently failing) + +### Prerequisites +- iOS Simulator with iOS 18.0+ (recommended: iPhone 16 or newer) +- Xcode 16+ with command line tools (tested with Xcode 26.0.1) +- iOS 26.0 SDK + +### Running Unit Tests + +```bash +# Run all unit tests +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxTests \ + -destination 'platform=iOS Simulator,name=iPhone 14' + +# Run unit tests on a specific iOS version +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxTests \ + -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' + +# Run a specific test class +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxTests \ + -destination 'platform=iOS Simulator,name=iPhone 14' \ + -only-testing:CheckBoxTests/CheckBoxTests + +# Run a specific test method +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxTests \ + -destination 'platform=iOS Simulator,name=iPhone 14' \ + -only-testing:CheckBoxTests/CheckBoxTests/test_frame +``` + +### Running UI Tests + +**⚠️ Note**: The UI tests are currently failing and will need to be fixed in a future update. + +```bash +# Run all UI tests (using CheckBox scheme which includes UI tests) +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBox \ + -destination 'platform=iOS Simulator,name=iPhone 14' \ + -only-testing:CheckBoxUITests + +# Alternative: Run UI tests directly (may not work due to current issues) +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxUITests \ + -destination 'platform=iOS Simulator,name=iPhone 14' +``` + +### Running All Tests + +```bash +# Run both unit and UI tests together +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBox \ + -destination 'platform=iOS Simulator,name=iPhone 14' +``` + +### Test Results and Debugging + +- Test results are output to the console in real-time +- For more detailed output, add `-verbose` flag to any xcodebuild command +- Test results bundles are saved to `/tmp/` for further analysis +- Failed tests will show assertion details and stack traces + +### Available Test Classes + +**Unit Tests (CheckBoxTests)**: +- `CheckBoxTests.m`: Basic checkbox functionality tests (initialization, setters, default values) +- `GroupTests.m`: Radio button group functionality tests (group selection, mustHaveSelection behavior) +- `AnimationManangerTests.m`: Animation behavior tests (typo in filename is intentional - actual file name) + +**UI Tests (CheckBoxUITests)**: +- `CheckBoxUITests.m`: End-to-end UI interaction tests + +### Troubleshooting + +- If tests fail to start, ensure the iOS Simulator is available and iOS 18.0+ is installed +- For "No such device" errors, check available simulators with: `xcrun simctl list devices` +- Test timeouts may occur on slower machines - increase timeout with `-test-timeout` flag + +## Installation Methods + +### Swift Package Manager +Add `https://github.com/saturdaymp/BEMCheckBox` as a dependency in Xcode or Package.swift + +### CocoaPods +```ruby +pod 'BEMCheckBox' +``` +Note: The latest CocoaPods version is v1.4.1 from the original repository + +### Carthage +Add to Cartfile and run `carthage update` + +### Manual +Copy the `Classes` folder directly into your Xcode project + +## Development Setup + +### Requirements +- Xcode 16+ (Xcode 26.0.1 tested and working) +- iOS 18.0+ deployment target +- Swift 6.0+ (Package.swift uses Swift 5 language mode for compatibility) +- macOS 15+ for development (CI uses macOS-15) + +### Schemes and Targets +The Xcode project contains the following targets: +- **BEMCheckBox**: Framework target for the library +- **CheckBox**: Sample application demonstrating usage +- **CheckBoxTests**: Unit tests for the library +- **CheckBoxUITests**: UI tests for the sample app + +## Key Features + +- **Animation Types**: Stroke, Fill, Bounce, Flat, One-Stroke, Fade +- **Box Types**: Circle, Square +- **Group Functionality**: Radio button behavior with BEMCheckBoxGroup +- **Customization Properties**: + - Line width + - Colors (on/off states) + - Animation duration + - Box visibility + +## CI/CD Pipeline + +The project uses GitHub Actions for continuous integration and release management. + +### Main CI Workflow (ci.yml) + +**Trigger**: +- Pushes to `main` and `release/*` branches +- Pull requests to `main` and `release/*` branches +- Tags matching `v*` pattern + +**Build Environment**: macOS-15 with Xcode 26.0.1 + +**Version Management**: GitVersion 6.3.0 for semantic versioning + +**Workflow Steps**: +1. Checkout code with full history (required for GitVersion) +2. Install and run GitVersion to determine version +3. Show available SDKs and simulators +4. Run unit tests on iPhone 16 with iOS 18.5 simulator +5. Build XCFramework using `./Scripts/build-xcframework.sh` +6. Upload XCFramework as workflow artifact +7. On tag push: Install GitReleaseManager 0.20.0 and upload XCFramework to GitHub Release + +**Test Configuration**: +- Destination: `platform=iOS Simulator,OS=18.5,name=iPhone 16` +- Timeout: 10 minutes +- Test results saved to TestResults bundle + +**Artifacts**: +- Workflow artifact: `BEMCheckBox-v{version}.xcframework` (directory) +- Release asset: `BEMCheckBox-v{version}.xcframework.zip` (on tagged releases) +- Output location: `Temp/Release-fat/BEMCheckBox.xcframework` + +### Release Notes Workflow (release-notes.yml) + +**Trigger**: +- Pushes to `release/*` branches +- Pull requests to `main` and `release/*` branches + +**Purpose**: Automatically generates and maintains CHANGELOG.md + +**Workflow Steps**: +1. Checkout code with full history +2. Install GitVersion and GitReleaseManager +3. Create GitHub Release draft for the milestone +4. Export changelog to CHANGELOG.md +5. Auto-commit updated CHANGELOG.md if changed + +**Configuration**: Uses GitReleaseManager.yml for: +- Issue label filtering (breaking, bug, devops, dependency, documentation, enhancement, refactoring, security) +- Changelog formatting +- Created date in title format + +### GitVersion Configuration (GitVersion.yml) + +- **Workflow**: GitHubFlow/v1 +- **Main branch**: Increments minor version +- **Release branches**: Prevent increment when current commit is tagged + +### Important Notes + +1. CI requires `contents: write` permission to upload artifacts and create releases +2. Release notes workflow uses PAT token for committing to protected branches +3. XCFramework build includes both simulator (arm64 + x86_64) and device (arm64) architectures +4. Test failures will fail the entire CI build +5. Only tag pushes trigger the release asset upload + +## Build Scripts + +### XCFramework Build Script (build-xcframework.sh) + +Located at [Scripts/build-xcframework.sh](Scripts/build-xcframework.sh), this script automates the complete XCFramework build process. + +**Features**: +- Color-coded console output for better readability +- Error handling with `set -e` and `set -o pipefail` +- Environment validation (checks for xcodebuild and project path) +- Automatic cleanup of previous builds +- Detailed logging of build artifacts and architectures +- Build time reporting + +**Usage**: +```bash +# Standard build +./Scripts/build-xcframework.sh + +# Show help +./Scripts/build-xcframework.sh --help +``` + +**Configuration** (editable at top of script): +- `PROJECT_PATH`: "Sample Project/CheckBox.xcodeproj" +- `SCHEME`: "BEMCheckBox" +- `CONFIGURATION`: "Release" +- `ARCHIVE_DIR`: "Temp/Archives" +- `OUTPUT_DIR`: "Temp/Release-fat" + +**Build Process**: +1. Validates environment (xcodebuild presence, project existence) +2. Cleans previous builds from Temp/ directory +3. Archives for iOS Simulator with destination `generic/platform=iOS Simulator` +4. Archives for iOS Device with destination `generic/platform=iOS` +5. Creates XCFramework with `xcodebuild -create-xcframework` +6. Reports final XCFramework size, supported architectures, and build time + +**Flags Used**: +- `SKIP_INSTALL=NO`: Required for archiving frameworks +- `BUILD_LIBRARY_FOR_DISTRIBUTION=YES`: Enables module stability for better compatibility + +**Output**: +- Archives: `Temp/Archives/BEMCheckBox-iOS_Simulator.xcarchive` and `Temp/Archives/BEMCheckBox-iOS.xcarchive` +- XCFramework: `Temp/Release-fat/BEMCheckBox.xcframework` +- Includes dSYMs for debugging + +## Common Development Tasks + +### Viewing Available Schemes +```bash +xcodebuild -list -project "Sample Project/CheckBox.xcodeproj" +``` + +### Clean Build +```bash +# Clean Xcode build +xcodebuild clean -project "Sample Project/CheckBox.xcodeproj" -scheme BEMCheckBox + +# Clean build script artifacts +rm -rf Temp/ build/ +``` + +### Check Available SDKs +```bash +xcodebuild -showsdks +``` + +### List Available Simulators +```bash +xcrun simctl list devices +``` + +### Generate Documentation +```bash +# If using jazzy for documentation +jazzy --module BEMCheckBox --source-directory Classes/ +``` + +### Check Swift Version +```bash +swift --version +``` + +### Verify XCFramework +```bash +# Check architectures in simulator slice +file Temp/Release-fat/BEMCheckBox.xcframework/ios-arm64_x86_64-simulator/BEMCheckBox.framework/BEMCheckBox + +# Check architectures in device slice +file Temp/Release-fat/BEMCheckBox.xcframework/ios-arm64/BEMCheckBox.framework/BEMCheckBox + +# Check XCFramework structure +ls -laR Temp/Release-fat/BEMCheckBox.xcframework +``` + +## Important Notes + +1. **Interface Builder Support**: The framework is `@IBDesignable` and `@IBInspectable` compatible for Interface Builder +2. **Language Interoperability**: The main checkbox implementation is in Swift while maintaining Objective-C compatibility through the generated Swift header +3. **XCFramework vs Fat Binary**: + - XCFramework is the modern, recommended approach (supports both arm64 and x86_64 simulators) + - Fat binaries are legacy and don't support multiple simulator architectures +4. **Initialization**: The project supports both programmatic and Interface Builder initialization +5. **Swift Language Mode**: Package.swift uses Swift 5 language mode (`.swiftLanguageMode(.v5)`) to avoid Swift 6 strict concurrency warnings +6. **Build Output**: All build scripts output to the `Temp/` directory, which is not tracked in git +7. **SDK Versions**: Update SDK paths in Swift Package Manager commands based on your Xcode version (use `xcodebuild -showsdks` to check) + +## Useful Links + +- [Original Repository](https://github.com/Boris-Em/BEMCheckBox) +- [Current Fork](https://github.com/saturdaymp/BEMCheckBox) +- [Xamarin Binding](https://github.com/saturdaymp/XPlugins.iOS.BEMCheckBox) +- [React Native Wrapper](https://github.com/torifat/react-native-bem-check-box) +- [NativeScript Plugin](https://github.com/nstudio/nativescript-checkbox) + +## Git Workflow and Branching + +The project follows **GitHubFlow/v1** workflow with the following branch structure: + +### Branch Strategy + +- **`main`**: Primary development branch + - All feature development and bug fixes merge here + - GitVersion increments minor version on commits to main + - Protected branch requiring pull request reviews + +- **`release/*`**: Release preparation branches (e.g., `release/2.2.0`) + - Created from main when ready to release + - GitVersion prevents increment when current commit is tagged + - Triggers release notes generation workflow + - CI runs on all pushes to release branches + +- **`v*` tags**: Version tags (e.g., `v2.2.0`) + - Applied to release branch commits + - Triggers full CI build with XCFramework upload to GitHub Releases + - Must match GitVersion output for consistency + +### Release Process + +1. Create release branch from main: `git checkout -b release/X.Y.Z` +2. Push release branch: triggers CHANGELOG.md generation +3. Review and merge any final changes +4. Tag the release: `git tag vX.Y.Z` +5. Push tag: `git push origin vX.Y.Z` +6. CI builds and uploads XCFramework to GitHub Release +7. GitReleaseManager creates release notes from milestone + +### Version Numbers + +- Managed by **GitVersion 6.3.0** +- Configuration in [GitVersion.yml](GitVersion.yml) +- Semantic versioning (MAJOR.MINOR.PATCH) +- Version embedded in build artifacts + +## Support + +For issues or questions: +- Open an [issue](https://github.com/saturdaymp/BEMCheckBox/issues) +- Submit a [pull request](https://github.com/saturdaymp/BEMCheckBox/pulls) +- Email: support@saturdaymp.com diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b3c3c4..856b0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## v2.2.0 (Nov, 13, 2025) + + +As part of this release we had [2 issues](https://github.com/saturdaymp/BEMCheckBox/milestone/3?closed=1) closed. + +Update from Fat32 binary to XCFramework + +__Documentation__ + +- [__!32__](https://github.com/saturdaymp/BEMCheckBox/pull/32) Update documentation and licensing for 2.2.0 release + +__enhancement__ + +- [__!30__](https://github.com/saturdaymp/BEMCheckBox/pull/30) Build XCFramework instead of Fat32 binary + ## v2.1.0 (Oct, 16, 2025) diff --git a/CLAUDE.md b/CLAUDE.md index dc2ba95..22de1ae 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,336 +1,7 @@ -# BEMCheckBox - Project Reference Guide +# BEMCheckBox - Claude Code Instructions -## Project Overview +This project uses a vendor-neutral agent instruction file for compatibility with multiple AI coding assistants. -BEMCheckBox is an open-source iOS checkbox library that provides beautiful, highly customizable, animated checkboxes. This is a fork of the original [Boris-Em/BEMCheckBox](https://github.com/Boris-Em/BEMCheckBox) repository. +For complete project documentation and instructions, please refer to: -### Key Technologies -- **Main Library**: Written in Swift -- **Example Project**: Written in Objective-C -- **Minimum iOS Version**: iOS 18 -- **Swift Tools Version**: 6.0+ - -## Project Structure - -``` -BEMCheckBox/ -├── Classes/ # Swift source files for the main library -│ ├── BEMCheckBox.swift # Main checkbox implementation -│ ├── BEMCheckBoxGroup.swift # Radio button group functionality -│ ├── BEMAnimationManager.swift # Animation handling -│ └── BEMPathManager.swift # Path drawing utilities -├── Sample Project/ # Example iOS application (Objective-C) -│ ├── CheckBox.xcodeproj/ # Xcode project file -│ ├── CheckBox/ # Example app source code -│ ├── CheckBoxTests/ # Unit tests -│ └── CheckBoxUITests/ # UI tests -├── Package.swift # Swift Package Manager configuration -├── .github/workflows/ # CI/CD GitHub Actions -│ ├── ci.yml # Main CI workflow -│ └── release-notes.yml # Release notes generation -└── README.md # Main documentation -``` - -## Build Instructions - -### Building the Framework - -#### Using Xcode Command Line Tools - -```bash -# Build for iOS Simulator (excluding arm64 to avoid conflicts) -xcodebuild -sdk iphonesimulator \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme BEMCheckBox \ - -configuration Release \ - EXCLUDED_ARCHS="arm64" - -# Build for iOS Device -xcodebuild -sdk iphoneos \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme BEMCheckBox \ - -configuration Release - -# Build the Sample App -xcodebuild -sdk iphonesimulator \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBox \ - -configuration Debug -``` - -#### Using Swift Package Manager - -**Note**: Building with Swift Package Manager for iOS requires explicit SDK paths and target specifications since this is an iOS-only library. - -##### iOS Simulator (x86_64) - -```bash -# Debug build for iOS Simulator -swift build \ - --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.0.sdk \ - -Xswiftc -target \ - -Xswiftc x86_64-apple-ios18.0-simulator - -# Release build for iOS Simulator -swift build -c release \ - --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.0.sdk \ - -Xswiftc -target \ - -Xswiftc x86_64-apple-ios18.0-simulator -``` - -##### iOS Device (arm64) - -```bash -# Debug build for iOS Device -swift build \ - --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk \ - -Xswiftc -target \ - -Xswiftc arm64-apple-ios18.0 - -# Release build for iOS Device -swift build -c release \ - --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk \ - -Xswiftc -target \ - -Xswiftc arm64-apple-ios18.0 -``` - -##### Build Artifacts - -Build artifacts are located in: -- **Debug builds**: `.build/debug/` -- **Release builds**: `.build/release/` -- **Swift modules**: `BEMCheckBox.swiftmodule` -- **Documentation**: `BEMCheckBox.swiftdoc` - -##### Important Notes for Swift Package Manager - -1. **Swift Version**: Package.swift is configured to use Swift 5 language mode to avoid Swift 6 strict concurrency issues -2. **SDK Versions**: Update SDK paths if using different Xcode versions (check with `xcodebuild -showsdks`) -3. **No Tests**: Swift Package Manager tests are not available as this is an iOS-only library requiring simulator/device -4. **Architecture**: Specify target architecture explicitly for each platform - -### Creating a Fat Binary Framework - -To create a universal framework that works on both device and simulator: - -```bash -# 1. Build for simulator (excluding arm64) -xcodebuild -sdk iphonesimulator \ - -project "Sample Project/CheckBox.xcodeproj" \ - -derivedDataPath build \ - -scheme BEMCheckBox \ - -configuration Release \ - EXCLUDED_ARCHS="arm64" - -# 2. Build for device -xcodebuild -sdk iphoneos \ - -project "Sample Project/CheckBox.xcodeproj" \ - -derivedDataPath build \ - -scheme BEMCheckBox \ - -configuration Release - -# 3. Create fat binary -cp -R build/Build/Products/Release-iphoneos/ Release-fat -lipo -create -output Release-fat/BEMCheckBox.framework/BEMCheckBox \ - build/Build/Products/Release-iphoneos/BEMCheckBox.framework/BEMCheckBox \ - build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework/BEMCheckBox - -# 4. Verify the fat binary -lipo -info Release-fat/BEMCheckBox.framework/BEMCheckBox -``` - -## Running Tests - -The project includes two test suites: -- **CheckBoxTests**: Unit tests for the BEMCheckBox framework -- **CheckBoxUITests**: UI tests for the sample application (currently failing) - -### Prerequisites -- iOS Simulator with iOS 18.0+ (recommended: iPhone 14 or newer) -- Xcode 14+ with command line tools - -### Running Unit Tests - -```bash -# Run all unit tests -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBoxTests \ - -destination 'platform=iOS Simulator,name=iPhone 14' - -# Run unit tests on a specific iOS version -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBoxTests \ - -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' - -# Run a specific test class -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBoxTests \ - -destination 'platform=iOS Simulator,name=iPhone 14' \ - -only-testing:CheckBoxTests/CheckBoxTests - -# Run a specific test method -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBoxTests \ - -destination 'platform=iOS Simulator,name=iPhone 14' \ - -only-testing:CheckBoxTests/CheckBoxTests/test_frame -``` - -### Running UI Tests - -**⚠️ Note**: The UI tests are currently failing and will need to be fixed in a future update. - -```bash -# Run all UI tests (using CheckBox scheme which includes UI tests) -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBox \ - -destination 'platform=iOS Simulator,name=iPhone 14' \ - -only-testing:CheckBoxUITests - -# Alternative: Run UI tests directly (may not work due to current issues) -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBoxUITests \ - -destination 'platform=iOS Simulator,name=iPhone 14' -``` - -### Running All Tests - -```bash -# Run both unit and UI tests together -xcodebuild test \ - -project "Sample Project/CheckBox.xcodeproj" \ - -scheme CheckBox \ - -destination 'platform=iOS Simulator,name=iPhone 14' -``` - -### Test Results and Debugging - -- Test results are output to the console in real-time -- For more detailed output, add `-verbose` flag to any xcodebuild command -- Test results bundles are saved to `/tmp/` for further analysis -- Failed tests will show assertion details and stack traces - -### Available Test Classes - -**Unit Tests (CheckBoxTests)**: -- `CheckBoxTests.m`: Basic checkbox functionality tests -- `GroupTests.m`: Radio button group functionality tests -- `AnimationManagerTests.m`: Animation behavior tests - -**UI Tests (CheckBoxUITests)**: -- `CheckBoxUITests.m`: End-to-end UI interaction tests - -### Troubleshooting - -- If tests fail to start, ensure the iOS Simulator is available and iOS 18.0+ is installed -- For "No such device" errors, check available simulators with: `xcrun simctl list devices` -- Test timeouts may occur on slower machines - increase timeout with `-test-timeout` flag - -## Installation Methods - -### Swift Package Manager -Add `https://github.com/saturdaymp/BEMCheckBox` as a dependency in Xcode or Package.swift - -### CocoaPods -```ruby -pod 'BEMCheckBox' -``` -Note: The latest CocoaPods version is v1.4.1 from the original repository - -### Carthage -Add to Cartfile and run `carthage update` - -### Manual -Copy the `Classes` folder directly into your Xcode project - -## Development Setup - -### Requirements -- Xcode 14+ (recommended) -- iOS 18.0+ deployment target -- Swift 6.0+ -- macOS for development - -### Schemes and Targets -The Xcode project contains the following targets: -- **BEMCheckBox**: Framework target for the library -- **CheckBox**: Sample application demonstrating usage -- **CheckBoxTests**: Unit tests for the library -- **CheckBoxUITests**: UI tests for the sample app - -## Key Features - -- **Animation Types**: Stroke, Fill, Bounce, Flat, One-Stroke, Fade -- **Box Types**: Circle, Square -- **Group Functionality**: Radio button behavior with BEMCheckBoxGroup -- **Customization Properties**: - - Line width - - Colors (on/off states) - - Animation duration - - Box visibility - -## CI/CD Pipeline - -The project uses GitHub Actions for continuous integration: - -- **Trigger**: Pushes to `main` and `release/*` branches, pull requests -- **Build Environment**: macOS-15 -- **Version Management**: GitVersion for semantic versioning -- **Artifacts**: Builds universal framework and uploads to GitHub releases on tags - -### CI Workflow Steps -1. Install GitVersion for version determination -2. Build for iOS Simulator (x86_64) -3. Build for iOS Device (arm64) -4. Create fat binary framework -5. Upload artifacts to GitHub - -## Common Development Tasks - -### Viewing Available Schemes -```bash -xcodebuild -list -project "Sample Project/CheckBox.xcodeproj" -``` - -### Clean Build -```bash -xcodebuild clean -project "Sample Project/CheckBox.xcodeproj" -scheme BEMCheckBox -``` - -### Generate Documentation -```bash -# If using jazzy for documentation -jazzy --module BEMCheckBox --source-directory Classes/ -``` - -### Check Swift Version -```bash -swift --version -``` - -## Important Notes - -1. The framework is `@IBDesignable` and `@IBInspectable` compatible for Interface Builder -2. The main checkbox implementation is in Swift while maintaining Objective-C compatibility -3. When building for simulator on Apple Silicon Macs, exclude arm64 architecture to avoid conflicts with device builds -4. The project supports both programmatic and Interface Builder initialization - -## Useful Links - -- [Original Repository](https://github.com/Boris-Em/BEMCheckBox) -- [Current Fork](https://github.com/saturdaymp/BEMCheckBox) -- [Xamarin Binding](https://github.com/saturdaymp/XPlugins.iOS.BEMCheckBox) -- [React Native Wrapper](https://github.com/torifat/react-native-bem-check-box) -- [NativeScript Plugin](https://github.com/nstudio/nativescript-checkbox) - -## Support - -For issues or questions: -- Open an [issue](https://github.com/saturdaymp/BEMCheckBox/issues) -- Submit a [pull request](https://github.com/saturdaymp/BEMCheckBox/pulls) -- Email: support@saturdaymp.com \ No newline at end of file +@AGENTS.md diff --git a/LICENSE b/LICENSE index 2a0a606..c856d00 100755 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2015 Boris Emorine. +Copyright (c) 2023 Saturday Morning Productions Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2fbae7a..fd6daf2 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,17 @@ # BEMCheckBox [![CI](https://github.com/saturdaymp/BEMCheckBox/actions/workflows/ci.yml/badge.svg)](https://github.com/saturdaymp/BEMCheckBox/actions/workflows/ci.yml) -[![Release Notes](https://github.com/saturdaymp/BEMCheckBox/actions/workflows/release-notes.yml/badge.svg)](https://github.com/saturdaymp/BEMCheckBox/actions/workflows/release-notes.yml) [![GitHub Sponsors](https://img.shields.io/github/sponsors/saturdaymp?label=Sponsors&logo=githubsponsors&labelColor=3C444C)](https://github.com/sponsors/saturdaymp)

-**BEMCheckBox** is an open source library making it easy to create beautiful, highly customizable, animated checkboxes for iOS. +**BEMCheckBox** is an open source library making it easy to create beautiful, highly customizable, animated checkboxes for iOS. -Forked from [Boris-EM/BEMCheckBox](https://github.com/Boris-Em/BEMCheckBox) because the not been updated in a while and I wanted to use an updated version in the [XPlugins.iOS.BEMCheckBox](https://github.com/saturdaymp/XPlugins.iOS.BEMCheckBox). I'm not very knowledge about Xcode and Swift so please feel free to help by creating an [issue](https://github.com/saturdaymp/BEMCheckBox/issues) and/or a [pull request](https://github.com/saturdaymp/BEMCheckBox/pulls). +This is a fork of the original [Boris-EM/BEMCheckBox](https://github.com/Boris-Em/BEMCheckBox) repository. Thanks to [Boris-Em](https://github.com/Boris-Em) for creating this excellent library! Please feel free to contribute by creating an [issue](https://github.com/saturdaymp/BEMCheckBox/issues) or a [pull request](https://github.com/saturdaymp/BEMCheckBox/pulls). ## Table of Contents -* [**Project Details**](#project-details) +* [**Project Details**](#project-details) * [Requirements](#requirements) - * [License](#license) * [Support](#support) * [Sample App](#sample-app) * [React Native](#react-native) @@ -22,8 +20,11 @@ Forked from [Boris-EM/BEMCheckBox](https://github.com/Boris-Em/BEMCheckBox) beca * [**Getting Started**](#getting-started) * [Installation](#installation) * [Setup](#setup) +* [**Building**](#building) + * [XCFramework (Recommended)](#xcframework-recommended) + * [Running Tests](#running-tests) * [**Documentation**](#documentation) - * [Enabling / Disabling the Checkbox](#enabling--disabling-the-checkbox) + * [Enabling / Disabling the Checkbox](#enabling--disabling-the-checkbox) * [Reloading](#reloading) * [Group / Radio Button Functionality](#group--radio-button-functionality) * [Delegate](#delegate) @@ -35,18 +36,17 @@ A quick example of the checkbox in action.

### Requirements - - Requires iOS 18 or later. - - Requires Automatic Reference Counting (ARC). - - Optimized for ARM64 Architecture. - -### License -See the [License](LICENSE). You are free to make changes and use this in either personal or commercial projects. Attribution is not required, but highly appreciated. A little "Thanks!" (or something to that affect) is always welcome for either [Saturday MP](https://github.com/saturdaymp) and/or [Boris-EM](https://github.com/Boris-Em) If you use **BEMCheckBox** in your app, please let us know! +- **iOS 18.0+** - Minimum deployment target +- **Swift 6.0+** - Swift Tools Version (Package.swift uses Swift 5 language mode for compatibility) +- **Xcode 16+** - Development environment (tested with Xcode 26.0.1) +- **Automatic Reference Counting (ARC)** +- **Architectures**: ARM64 (device), ARM64 + x86_64 (simulator) ### Support Open an [issue](https://github.com/saturdaymp/BEMCheckBox/issues) if you have a question, spot a bug, or have a feature request. [Pull requests](https://github.com/saturdaymp/BEMCheckBox/pulls) are welcome and much appreciated. Finally you can send an email to [support@saturdaymp.com](support@saturdaymp.com). ### Sample App -The iOS Sample App included with this project demonstrates one way to correctly setup and use **BEMCheckBox**. It also offers the possibility to customize the checkbox within the app. +The iOS Sample App included with this project demonstrates how to setup and use **BEMCheckBox** in Objective-C. There is currently no example project for Swift but hopefully one will be added in the future. The sample app is located in the `Sample Project/` directory. ### React Native **BEMCheckBox** can be used with React Native: [React-Native-BEMCheckBox](https://github.com/torifat/react-native-bem-check-box) @@ -58,160 +58,325 @@ The iOS Sample App included with this project demonstrates one way to correctly **BEMCheckBox** can also be used with Xamarin: [XPlugins.iOS.BEMCheckBox](https://github.com/saturdaymp/XPlugins.iOS.BEMCheckBox) ## Getting Started -It only takes a few simple steps to install and setup **BEMCheckBox** to your project. +There are several ways to install and use **BEMCheckBox** into your project. ### Installation -#### Swift Package Manager -Add `https://github.com/saturdaymp/BEMCheckBox` as a dependency to your Package.swift file or select `File -> Swift Packages -> Add Package Dependency...` in Xcode. +#### Swift Package Manager (Recommended) +Add `https://github.com/saturdaymp/BEMCheckBox` as a dependency in Xcode: +1. Select `File -> Add Package Dependencies...` in Xcode +2. Enter the repository URL: `https://github.com/saturdaymp/BEMCheckBox` +3. Select the version or branch you want to use + +Or add it to your `Package.swift` file: +```swift +dependencies: [ + .package(url: "https://github.com/saturdaymp/BEMCheckBox", from: "2.2.0") +] +``` + +#### XCFramework +Download the latest pre-built XCFramework from the [Releases](https://github.com/saturdaymp/BEMCheckBox/releases) page. The XCFramework supports both iOS devices (arm64) and iOS simulators (arm64 + x86_64). -#### CocoaPods -Note: The latest version on CocoaPods is [v1.4.1](https://cocoapods.org/pods/BEMCheckBox) by [Boris-Em](https://github.com/Boris-Em). CocoaPods is being [deprecated](https://blog.cocoapods.org/CocoaPods-Specs-Repo/) so there are no plans to add new versions of BEMCheckBox to it. +To integrate: +1. Download `BEMCheckBox.xcframework.zip` from the latest release +2. Unzip and drag `BEMCheckBox.xcframework` into your Xcode project +3. In your target's settings, add the framework to "Frameworks, Libraries, and Embedded Content" -To install BEMCheckBox using CocoaPods add the following line to your `Podfile`: +#### CocoaPods +**Note:** The latest version on CocoaPods is [v1.4.1](https://cocoapods.org/pods/BEMCheckBox) from the original [Boris-Em](https://github.com/Boris-Em) repository. As CocoaPods is being [deprecated](https://blog.cocoapods.org/CocoaPods-Specs-Repo/), there are no plans to publish new versions of this fork to CocoaPods. Please use Swift Package Manager or XCFramework instead. -
pod 'BEMCheckBox'
+To install the original version using CocoaPods, add to your `Podfile`: +```ruby +pod 'BEMCheckBox' +``` #### Carthage -[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. +[Carthage](https://github.com/Carthage/Carthage) is supported. Add **BEMCheckBox** to your Cartfile, run `carthage update`, and drag the built `BEMCheckBox.framework` into your Xcode project. -Run `carthage update` after adding **BEMCheckBox** to your Cartfile to build the framework. Drag the built `BEMCheckBox.framework` into your Xcode project. - -#### Manually -Finally, you can install **BEMCheckBox** manually. Simply drag and drop the *Classes* folder into your Xcode project. When you do so, make sure to check the "*Copy items into destination group's folder*" box. +#### Manual Installation +You can install **BEMCheckBox** manually by dragging and dropping the `Classes/` folder into your Xcode project. Make sure to check the "*Copy items into destination group's folder*" box when adding the files. ### Setup -Setting up **BEMCheckBox** to your project couldn't be more simple. It is modeled after `UISwitch`. In fact, you could just replace instances of `UISwitch` by **BEMCheckBox** in your project! -Here are the steps to follow to get everything up and running: - - 1. Import `"BEMCheckBox.h"` to the header of your view controller: - - ```objective-c - #import "BEMCheckBox.h" - ``` - - 2. **BEMCheckBox** can either be initialized programatically (through code) or with Interface Builder (Storyboard file). Use the method that makes the most sense for your project. - - **Programmatical Initialization** - Just add the following code to your implementation (usually in the `viewDidLoad` method of your View Controller). - - ```objective-c - BEMCheckBox *myCheckBox = [[BEMCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; - [self.view addSubview:myCheckBox]; - ``` - - **Interface Builder Initialization** - 1 - Drag a `UIView` to your `UIViewController`. - 2 - Change the class of the new `UIView` to `BEMCheckBox`. - 3 - Select the `BEMCheckBox` and open the Attributes Inspector. Most of the customizable properties can easily be set from the Attributes Inspector. The Sample App demonstrates this capability. +Setting up **BEMCheckBox** to your project couldn't be simpler. It is modeled after `UISwitch`. In fact, you could just replace instances of `UISwitch` with **BEMCheckBox** in your project! + +The library is written in Swift but maintains full Objective-C compatibility. Here are the steps to get started: + +#### Swift Usage + +1. Import the module in your Swift file: + +```swift +import BEMCheckBox +``` + +2. **BEMCheckBox** can be initialized programmatically or with Interface Builder (Storyboard file). + +**Programmatic Initialization** +Add the following code to your implementation (usually in the `viewDidLoad` method of your View Controller): + +```swift +let myCheckBox = BEMCheckBox(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) +self.view.addSubview(myCheckBox) +``` + +**Interface Builder Initialization** +1. Drag a `UIView` to your `UIViewController` +2. Change the class of the new `UIView` to `BEMCheckBox` +3. Select the `BEMCheckBox` and open the Attributes Inspector. Most customizable properties can be set from the Attributes Inspector. The Sample App demonstrates this capability. + +#### Objective-C Usage + +1. Import the framework header in your Objective-C file: + +```objective-c +#import +// Or if manually installed: +#import "BEMCheckBox-Swift.h" +``` + +2. **BEMCheckBox** can be initialized programmatically or with Interface Builder. + +**Programmatic Initialization** +Add the following code to your implementation: + +```objective-c +BEMCheckBox *myCheckBox = [[BEMCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; +[self.view addSubview:myCheckBox]; +``` + +**Interface Builder Initialization** +Same as Swift - drag a `UIView`, change its class to `BEMCheckBox`, and customize in the Attributes Inspector. + +## Building + +### XCFramework (Recommended) +The project includes a build script that creates a universal XCFramework supporting both iOS devices and simulators (including Apple Silicon): + +```bash +# Build XCFramework using the automated script +./Scripts/build-xcframework.sh + +# Output will be at: Temp/Release-fat/BEMCheckBox.xcframework +``` + +This script: +- Builds archives for iOS Simulator (arm64 + x86_64) +- Builds archives for iOS Device (arm64) +- Creates an XCFramework from both archives +- Supports BUILD_LIBRARY_FOR_DISTRIBUTION for better compatibility +- Includes debug symbols (dSYMs) + +**Note:** XCFramework is the modern Apple-recommended approach and is preferred over fat binaries. + +### Building with Xcode Command Line + +```bash +# Build for iOS Simulator (excluding arm64 to avoid conflicts) +xcodebuild -sdk iphonesimulator \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme BEMCheckBox \ + -configuration Release \ + EXCLUDED_ARCHS="arm64" + +# Build for iOS Device +xcodebuild -sdk iphoneos \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme BEMCheckBox \ + -configuration Release +``` + +### Running Tests + +The project includes comprehensive unit tests for the BEMCheckBox framework: + +```bash +# Run all unit tests +xcodebuild test \ + -project "Sample Project/CheckBox.xcodeproj" \ + -scheme CheckBoxTests \ + -destination 'platform=iOS Simulator,name=iPhone 14' +``` + +**Test Suites:** +- **CheckBoxTests**: Basic checkbox functionality (initialization, setters, default values) +- **GroupTests**: Radio button group functionality (group selection, mustHaveSelection behavior) +- **AnimationManagerTests**: Animation behavior tests ## Documentation All of the methods and properties available for **BEMCheckBox** are documented below. ### Enabling / Disabling the Checkbox ##### The `on` Property -Just like `UISwitch`, **BEMCheckBox** provides the boolean property `on` that allows you to retrieve and set (without animation) a value determining wether the BEMCheckBox object is `on` or `off`. Defaults to `NO`. +Just like `UISwitch`, **BEMCheckBox** provides the boolean property `on` that allows you to retrieve and set (without animation) a value determining whether the BEMCheckBox object is `on` or `off`. Defaults to `false`. + Example usage: +```swift +// Swift +myCheckBox.on = true +``` ```objective-c +// Objective-C self.myCheckBox.on = YES; ``` + ##### `setOn:animated:` -Just like `UISwitch`, **BEMCheckBox** provides an instance method `setOn:animated:` that sets the state of the checkbox to On or Off, optionally animating the transition. +Just like `UISwitch`, **BEMCheckBox** provides an instance method `setOn(_:animated:)` that sets the state of the checkbox to On or Off, optionally animating the transition. + Example usage: +```swift +// Swift +myCheckBox.setOn(true, animated: true) +``` ```objective-c +// Objective-C [self.myCheckBox setOn:YES animated:YES]; ``` ### Reloading -The instance method `reload` lets you redraw the entire checkbox, keeping the current `on` value. -Example usage: +The instance method `reload()` lets you redraw the entire checkbox, keeping the current `on` value. + +Example usage: +```swift +// Swift +myCheckBox.reload() +``` ```objective-c -[self.myCheckBox reload] +// Objective-C +[self.myCheckBox reload]; ``` ### Group / Radio Button Functionality **BEMCheckBox**es can easily be grouped together to form radio button functionality. This will automatically manage the state of each checkbox in the group, so that only one is selected at a time, and can optionally require that the group has a selection at all times. +```swift +// Swift +group = BEMCheckBoxGroup(checkBoxes: [checkBox1, checkBox2, checkBox3]) +group.selectedCheckBox = checkBox2 // Optionally set which checkbox is pre-selected +group.mustHaveSelection = true // Define if the group must always have a selection +``` ```objective-c +// Objective-C self.group = [BEMCheckBoxGroup groupWithCheckBoxes:@[self.checkBox1, self.checkBox2, self.checkBox3]]; -self.group.selectedCheckBox = self.checkBox2; // Optionally set which checkbox is pre-selected -self.group.mustHaveSelection = YES; // Define if the group must always have a selection +self.group.selectedCheckBox = self.checkBox2; +self.group.mustHaveSelection = YES; ``` -To see which checkbox is selected in that group, just ask for it: +To see which checkbox is selected in that group: +```swift +// Swift +let selection = group.selectedCheckBox +``` ```objective-c +// Objective-C BEMCheckBox *selection = self.group.selectedCheckBox; ``` -To manually update the selection for a group, just set it: +To manually update the selection for a group: +```swift +// Swift +group.selectedCheckBox = checkBox1 +``` ```objective-c +// Objective-C self.group.selectedCheckBox = self.checkBox1; ``` ### Delegate **BEMCheckBox** uses a delegate to receive check box events. The delegate object must conform to the `BEMCheckBoxDelegate` protocol, which is composed of two optional methods: -- `didTap:` +- `didTap(_:)` Sent to the delegate every time the check box gets tapped, after its properties are updated (`on`), but before the animations are completed. -- `animationDidStop:` +- `animationDidStop(for:)` Sent to the delegate every time the check box finishes being animated. +Example: +```swift +// Swift +class MyViewController: UIViewController, BEMCheckBoxDelegate { + func didTap(_ checkBox: BEMCheckBox) { + print("Checkbox tapped: \(checkBox.on)") + } + + func animationDidStop(for checkBox: BEMCheckBox) { + print("Animation completed") + } +} +``` +```objective-c +// Objective-C +@interface MyViewController () +@end + +@implementation MyViewController + +- (void)didTap:(BEMCheckBox *)checkBox { + NSLog(@"Checkbox tapped: %d", checkBox.on); +} + +- (void)animationDidStopForCheckBox:(BEMCheckBox *)checkBox { + NSLog(@"Animation completed"); +} + +@end +``` + ### Customization -**BEMCheckBox** is exclusively customizable though properties. -The following diagram provides a good overview: +**BEMCheckBox** is exclusively customizable through properties. +The following diagram provides a good overview:

+##### Appearance Properties +`lineWidth` - `CGFloat` +The width of the lines of the check mark and box. Defaults to `2.0`. -##### Apparence Properties -`lineWidth` - CGFloat -The width of the lines of the check mark and box. Defaults to 2.0. - -`hideBox` - BOOL -BOOL to control if the box should be hidden or not. Setting this property to `YES` will essentially turn the checkbox into a check mark. Defaults to `NO`. +`hideBox` - `Bool` +Controls if the box should be hidden or not. Setting this property to `true` will essentially turn the checkbox into a check mark. Defaults to `false`. -`boxType` - BEMBoxType -The type of box to use. See `BEMBoxType` for possible values. Defaults to `BEMBoxTypeCircle`. +`boxType` - `BEMBoxType` +The type of box to use. See `BEMBoxType` for possible values. Defaults to `.circle`.

-`tintColor` - UIColor +`tintColor` - `UIColor` The color of the box when the checkbox is Off. -`onCheckColor` - UIColor +`onCheckColor` - `UIColor` The color of the check mark when it is On. -`onFillColor` - UIColor +`onFillColor` - `UIColor` The color of the inside of the box when it is On. -`onTintColor` - UIColor +`onTintColor` - `UIColor` The color of the line around the box when it is On. ##### Animations -`animationDuration` - CGFloat +`animationDuration` - `CGFloat` The duration in seconds of the animations. Defaults to `0.5`. -`onAnimationType` - BEMAnimationType -The type of animation to use when the checkbox gets checked. Defaults to `BEMAnimationTypeStroke`. See `BEMAnimationType` bellow for possible values. +`onAnimationType` - `BEMAnimationType` +The type of animation to use when the checkbox gets checked. Defaults to `.stroke`. See `BEMAnimationType` below for possible values. + +`offAnimationType` - `BEMAnimationType` +The type of animation to use when the checkbox gets unchecked. Defaults to `.stroke`. See `BEMAnimationType` below for possible values. -`offAnimationType` - BEMAnimationType -The type of animation to use when the checkbox gets unchecked. Defaults to `BEMAnimationTypeStroke`. See `BEMAnimationType` bellow for possible values. +`BEMAnimationType` +The possible values for `onAnimationType` and `offAnimationType`. -`BEMAnimationType` -The possible values for `onAnimationType` and `offAnimationType`. -- `BEMAnimationTypeStroke` +- `.stroke` (Swift) / `BEMAnimationTypeStroke` (Objective-C)

-- `BEMAnimationTypeFill` +- `.fill` (Swift) / `BEMAnimationTypeFill` (Objective-C)

-- `BEMAnimationTypeBounce` +- `.bounce` (Swift) / `BEMAnimationTypeBounce` (Objective-C)

-- `BEMAnimationTypeFlat` +- `.flat` (Swift) / `BEMAnimationTypeFlat` (Objective-C)

-- `BEMAnimationTypeOneStroke` +- `.oneStroke` (Swift) / `BEMAnimationTypeOneStroke` (Objective-C)

-- `BEMAnimationTypeFade` +- `.fade` (Swift) / `BEMAnimationTypeFade` (Objective-C)