A comprehensive command-line tool that analyzes your iOS projects for image optimization opportunities following Apple's official Human Interface Guidelines. Identify unused images, validate Apple compliance, and get actionable recommendations to improve your app's performance and App Store approval chances.
This tool provides comprehensive image analysis for iOS projects:
- Unused Image Detection - Find images that exist but are never referenced in code, including dynamic loading and compile-time pattern recognition
- Apple Compliance Validation - Validate images against Apple's official guidelines
- PNG Interlacing Analysis - Detect performance-impacting interlaced PNGs
- Color Profile Validation - Ensure consistent colors across devices
- Asset Catalog Organization - Validate proper scale variants (@1x, @2x, @3x)
- Design Quality Assessment - Check touch targets and memory optimization
- Compliance Scoring - Get a 0-100 Apple compliance score
- Prioritized Recommendations - Actionable items ranked by importance
- 154 Comprehensive Unit Tests - Ensuring reliability and accuracy
- CI/CD Pipeline - Automated testing on every Pull Request
- 73.8% Code Coverage - Extensive test coverage across all components
- Cross-Platform Support - Works on both Intel and Apple Silicon Macs
π Analyzing iOS project at: /Users/yourname/Documents/MyApp
π Analysis Complete
==================================================
π― Apple Compliance Score: 73/100
π Summary:
Total images: 45
Total image size: 2.3 MB
Unused images: 8
Potential savings: 890 KB
π Apple Guidelines Compliance:
PNG interlacing issues: 2
Color profile issues: 5
Asset catalog issues: 12
Design quality issues: 3
π‘ Prioritized Action Items:
1. Remove 8 unused images to save 890 KB
2. Fix 2 critical PNG interlacing issues
3. Add color profiles to 5 images
4. Add missing scale variants for 7 images
5. Address 2 design quality issues
This tool implements validation based on Apple's official Human Interface Guidelines:
- Primary Reference: Apple Human Interface Guidelines - Images
- Key Requirements:
- De-interlaced PNG files for better performance
- Color profiles for consistent appearance across devices
- Proper scale factors (@1x, @2x, @3x) for different device densities
- Appropriate formats (PNG for UI, JPEG for photos, PDF/SVG for icons)
- Design at lowest resolution and scale up for clean alignment
Open Terminal and verify Swift is installed:
swift --versionYou need Swift 5.9+ or Xcode 14+. If not installed:
xcode-select --install# Navigate to your Documents folder
cd ~/Documents
# Download the tool
git clone https://github.com/sahilsatralkar/iOSImageOptimizerTool.git
# Go into the tool directory
cd iOSImageOptimizerTool/iOSImageOptimizer
# Build the tool (takes 2-5 minutes first time)
swift build# Basic analysis
swift run iOSImageOptimizer /path/to/your/ios/project
# Detailed analysis with verbose output
swift run iOSImageOptimizer /path/to/your/ios/project --verbose
# JSON output for integration
swift run iOSImageOptimizer /path/to/your/ios/project --jsonReal example:
swift run iOSImageOptimizer /Users/yourname/Documents/MyiOSApp- 80-100: Excellent compliance, ready for App Store
- 60-79: Good, minor issues to address
- 40-59: Fair, several compliance issues
- 0-39: Poor, significant issues requiring attention
- What: Detects interlaced PNGs that impact performance
- Why: Apple recommends de-interlaced PNGs for better iOS performance
- Action: Convert to de-interlaced format using image editing tools
- What: Images missing or with incompatible color profiles
- Why: Ensures consistent colors across different iOS devices
- Action: Add sRGB color profile (recommended for most iOS images)
- What: Missing scale variants, orphaned scales, organization problems
- Why: iOS requires proper @1x, @2x, @3x variants for optimal display
- Action: Add missing scale variants or organize in Asset Catalogs
- What: Images too small for touch targets or memory-intensive
- Why: Affects usability and performance on iOS devices
- Action: Resize touch targets to 44Γ44pt minimum, optimize large images
- What: Images present in project but never referenced in code (detects static references, dynamic loading patterns, and string interpolation)
- Why: Reduces app bundle size and improves download/install times
- Action: Review and remove confirmed unused images
# Before deleting, verify the image is truly unused
grep -r "image_name" /path/to/your/project
# The tool already checks for dynamic patterns like Image("Icons/\(variable)")
# If flagged as unused, it's safe to delete- Use tools like ImageOptim, Photoshop, or online converters
- Ensure "interlaced" option is disabled when saving PNGs
- In Photoshop: Edit β Convert to Profile β sRGB
- In Preview: Tools β Assign Profile β sRGB IEC61966-2.1
- Create missing @1x, @2x, @3x variants
- Move standalone images to Asset Catalogs
- Ensure proper naming conventions
- Resize touch targets to minimum 44Γ44 points
- Optimize large images or implement progressive loading
- Use appropriate formats for content type
# Clean and rebuild
swift package clean
swift build
# Update dependencies
swift package update# Find your project path
open /path/to/your/project # Should open in Finder
pwd # Shows current directory- Ensure you have read access to the project directory
- Don't point to system directories
- Run before each App Store submission
- Include in CI/CD pipeline for continuous monitoring
- Check after adding new images or design updates
# Run all 154 unit tests
swift test
# Run tests with code coverage
swift test --enable-code-coverage
# Generate coverage report
swift test --enable-code-coverage
xcrun llvm-cov export ./.build/debug/iOSImageOptimizerPackageTests.xctest/Contents/MacOS/iOSImageOptimizerPackageTests -instr-profile=./.build/debug/codecov/default.profdata -format="lcov" > coverage.lcovThe project includes GitHub Actions automation that:
- Builds the project on every PR
- Runs all 154 unit tests
- Generates code coverage reports
- Supports both x86_64 and Apple Silicon runners
- Provides detailed test summaries
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
swift test - Submit a Pull Request (CI will automatically run tests)
- Design images at @1x resolution with whole-number dimensions
- Scale up to create @2x and @3x variants
- Optimize file sizes without losing quality
- Validate with this tool before submission
- Test on actual devices to verify appearance
- Use PNG for UI elements and icons
- Use JPEG for photographs
- Use PDF/SVG for scalable icons
- Always include color profiles
- Organize images in Asset Catalogs
- Follow Apple's dimension guidelines
- iOS: @2x and @3x required
- iPadOS: @2x required
- macOS: @1x and @2x required
- watchOS: @2x required
- UI Elements: De-interlaced PNG with sRGB color profile
- Photographs: JPEG with embedded color profile
- Icons: PDF or SVG for scalability
- Low-color graphics: 8-bit PNG palette
"No images found"
- Verify project path is correct
- Ensure project contains .png, .jpg, .pdf, or .svg files
"Low compliance score"
- Review each category in the detailed output
- Focus on Priority 1 and 2 items first
- Use Apple's official guidelines as reference
"Build failed"
- Update Xcode and command line tools
- Check Swift version compatibility
- Clean and rebuild the project
- Analysis Only: This tool only analyzes - it never automatically modifies your project
- Backup First: Always backup your project before making changes
- Enhanced Detection: Tool now detects dynamic loading patterns and string interpolation to reduce false positives
- Test Thoroughly: Verify your app works correctly after making changes
- Apple Guidelines: This tool follows Apple's official recommendations, not arbitrary limits
The tool works with standard iOS project structures:
MyiOSApp/
βββ MyiOSApp.xcodeproj
βββ MyiOSApp/
β βββ ViewController.swift
β βββ Assets.xcassets/
β β βββ AppIcon.appiconset/
β β βββ LaunchImage.imageset/
β βββ Images/
β β βββ logo.png
β β βββ logo@2x.png
β β βββ logo@3x.png
β βββ Storyboards/
β βββ Main.storyboard
βββ Pods/ (if using CocoaPods)
βββ README.md
Point the tool to the root project folder containing the .xcodeproj file.
- β Critical Performance Fix: Tool no longer hangs on real-world iOS projects
- β Smart Directory Exclusion: Automatically skips DerivedData, Pods, .build, Carthage, and other build directories
- β Massive Speed Improvement: Completes in seconds instead of hanging indefinitely
- β Production Ready: Successfully tested on complex projects with large dependency folders
- β Build Fix: Resolved critical build issues when cloning repository (Fixes #3)
- β Clean Repository: Removed machine-specific build artifacts from version control
- β Improved Developer Experience: Project now builds successfully on all machines without errors
- β Better .gitignore: Ensures build artifacts stay local and don't get committed
- β Complete Test Suite: 154 comprehensive unit tests with 73.8% code coverage
- β CI/CD Pipeline: Automated testing on GitHub Actions
- β Enhanced Detection: Improved dynamic image loading detection with Method 2
- β Cross-Platform: Full support for Intel and Apple Silicon Macs
- β Robust Error Handling: Better handling of edge cases and malformed files
- β Initial release with core image analysis features
- β Apple compliance validation
- β Unused image detection
- β Basic project parsing
Transform your iOS app's image optimization with Apple-compliant analysis! ππ±
Following Apple's Human Interface Guidelines ensures better performance, smaller bundle sizes, and improved App Store approval chances.