How to Install the EFQRCode Swift Library: CocoaPods, Carthage, and SPM Guide
Add EFQRCode to your Xcode project using CocoaPods (pod 'EFQRCode', '~> 7.0.3'), Carthage (github "EFPrefix/EFQRCode" ~> 7.0.3), or Swift Package Manager (URL: https://github.com/EFPrefix/EFQRCode.git), then import with import EFQRCode to access the Generator and Recognizer APIs.
The EFQRCode library from the EFPrefix/EFQRCode repository provides a pure-Swift solution for generating and recognizing QR codes across Apple platforms. Installing the EFQRCode Swift library via your preferred dependency manager exposes the complete API for creating static and animated QR codes with custom styles. This guide details the exact installation steps for CocoaPods, Carthage, and Swift Package Manager, including verification code and key source file references.
Installation Methods for the EFQRCode Swift Library
EFQRCode supports three major dependency managers. Choose the method that aligns with your project's existing workflow.
CocoaPods Installation
CocoaPods manages library dependencies through a centralized specification repository. To install EFQRCode via CocoaPods:
-
Add the pod to your
Podfile:pod 'EFQRCode', '~> 7.0.3' -
Execute the installation:
pod install -
Open the generated
.xcworkspacefile. -
Import the module in your Swift source files:
import EFQRCode
The EFQRCode.podspec file defines the library's source file patterns and module map, ensuring that Source/EFQRCode.swift and its dependencies compile correctly into your project.
Carthage Installation
Carthage builds dependencies as binary frameworks, giving you explicit control over integration. To install EFQRCode via Carthage:
-
Add the dependency to your
Cartfile:github "EFPrefix/EFQRCode" ~> 7.0.3 -
Build the framework for your target platforms:
carthage update --platform iOS,macOS,tvOS,watchOS -
In Xcode, drag the built
EFQRCode.frameworkfromCarthage/Buildinto the "Frameworks, Libraries, and Embedded Content" section of your target. -
Import the library:
import EFQRCode
The Carthage build process compiles the core generation logic from Source/EFQRCode+Generator.swift and recognition capabilities from Source/EFQRCode+Recognizer.swift into a reusable framework.
Swift Package Manager Installation
Swift Package Manager provides native dependency management integrated directly into Xcode. To install EFQRCode via SPM:
-
In Xcode, choose File ▸ Add Packages….
-
Enter the repository URL:
https://github.com/EFPrefix/EFQRCode.git -
Select the version rule (e.g., "Up to Next Minor from 7.0.3").
-
Xcode automatically adds the package and links the
EFQRCodeproduct to your target. -
Import the module:
import EFQRCode
The Package.swift manifest lists the library targets, including the core source files and the Source/Styles/ and Source/Extension/ directories required for full functionality.
Verifying Your EFQRCode Installation
Confirm successful installation by generating and recognizing a test QR code. The following examples utilize the public API exposed through Source/EFQRCode.swift.
Generate a simple QR code:
import EFQRCode
import UIKit
let generator = try? EFQRCode.Generator(
"https://github.com/EFPrefix/EFQRCode",
style: .basic()
)
if let cgImage = try? generator?.toImage(width: 300).cgImage {
let qrImage = UIImage(cgImage: cgImage)
// Successfully generated QR code image
}
Test recognition capabilities:
import EFQRCode
if let testImage = UIImage(named: "test.png")?.cgImage {
let recognizer = EFQRCode.Recognizer(image: testImage)
let codes = recognizer.recognize()
print("Detected \(codes.count) QR codes")
}
Successful execution confirms that Source/EFQRCode+Generator.swift and Source/EFQRCode+Recognizer.swift compiled correctly and that the style structs in Source/Styles/ are accessible.
Key Source Files in EFQRCode
Understanding the library structure helps troubleshoot installation issues:
| Path | Purpose |
|---|---|
Source/EFQRCode.swift |
Public namespace; exports Generator and Recognizer classes. |
Source/EFQRCode+Generator.swift |
Core QR-code generation engine supporting static and animated output. |
Source/EFQRCode+Recognizer.swift |
QR-code detection using CoreImage and ImageIO. |
Source/Styles/*.swift |
Visual style definitions (basic, bubble, 25D, image fill, etc.). |
Source/Extension/*.swift |
Platform extensions for UIImage, NSImage, CGImage, and numeric types. |
Package.swift |
SPM manifest defining targets and platform requirements. |
EFQRCode.podspec |
CocoaPods specification listing source files and module map. |
When you install EFQRCode using any package manager, these files compile into your project, exposing the full API for QR code creation and scanning.
Summary
- CocoaPods: Add
pod 'EFQRCode', '~> 7.0.3'to your Podfile, runpod install, and import withimport EFQRCode. - Carthage: Add
github "EFPrefix/EFQRCode" ~> 7.0.3to your Cartfile, runcarthage update, and embed the resulting framework. - Swift Package Manager: Add
https://github.com/EFPrefix/EFQRCode.gitvia File ▸ Add Packages… and select version 7.0.3 or later.
All methods expose the Generator and Recognizer classes defined in Source/EFQRCode.swift, enabling immediate QR code generation via Source/EFQRCode+Generator.swift and recognition via Source/EFQRCode+Recognizer.swift.
Frequently Asked Questions
What is the minimum iOS version required for EFQRCode?
EFQRCode requires iOS 12.0 or later, macOS 10.11 or later, tvOS 12.0 or later, and watchOS 5.0 or later. These minimum versions are defined in the Package.swift manifest and ensure compatibility with the CoreImage and ImageIO frameworks used by Source/EFQRCode+Generator.swift and Source/EFQRCode+Recognizer.swift.
Can I use EFQRCode in a macOS or watchOS app?
Yes, EFQRCode supports macOS, iOS, tvOS, and watchOS. When installing via Carthage, specify your target platforms using --platform iOS,macOS,tvOS,watchOS. The library's platform-specific extensions in Source/Extension/ provide convenience methods for NSImage on macOS and UIImage on iOS, ensuring consistent API behavior across all supported operating systems.
How do I troubleshoot import errors after installing EFQRCode?
If import EFQRCode fails, verify your installation method-specific steps. For CocoaPods, ensure you opened the .xcworkspace file rather than the .xcodeproj file. For Carthage, confirm that EFQRCode.framework appears in your target's "Frameworks, Libraries, and Embedded Content" section. For Swift Package Manager, check that the package appears in "Package Dependencies" and that the EFQRCode product is linked to your target.
What are the main classes available after installing EFQRCode?
After installation, you gain access to the Generator and Recognizer classes defined in Source/EFQRCode.swift. The Generator class (implemented in Source/EFQRCode+Generator.swift) creates static and animated QR codes with styles defined in Source/Styles/. The Recognizer class (found in Source/EFQRCode+Recognizer.swift) detects QR codes in images using CoreImage. Both classes become available immediately after importing with import EFQRCode.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →