Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing import declarations #49

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.1
osx_image: xcode9.4
env:
global:
- LC_CTYPE=en_US.UTF-8
Expand All @@ -10,7 +10,7 @@ env:
#- WATCHOS_FRAMEWORK_SCHEME="QRCode-watchOS"
matrix:
#- DESTINATION="OS=9.3,name=iPhone 6S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="iphonesimulator9.3"
- DESTINATION="OS=10.1,name=iPhone 6S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="iphonesimulator10.1"
- DESTINATION="OS=11.4,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="iphonesimulator11.4"
#- DESTINATION="OS=9.2,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="appletvsimulator9.2"
#- DESTINATION="OS=2.2,name=Apple Watch - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="watchsimulator2.2"
#- DESTINATION="OS=10.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="appletvsimulator10.0"
Expand Down
36 changes: 27 additions & 9 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Alexander Schuch";
TargetAttributes = {
4D248F061A751C3700E44E6B = {
Expand Down Expand Up @@ -407,14 +407,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -442,7 +450,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -454,14 +462,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -481,7 +497,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -490,25 +506,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.QRCode-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
4D248F281A751C3700E44E6B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.QRCode-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -534,7 +552,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -558,7 +576,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0.1;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 3 additions & 3 deletions Example.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,8 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions QRCode.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = "QRCode"
s.version = "2.0"
s.version = "2.0.1"
s.summary = "A QRCode generator written in Swift."
s.description = "Generate QRCodes and customize their appearance."
s.homepage = "https://github.com/aschuch/QRCode"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Alexander Schuch" => "[email protected]" }
s.social_media_url = "http://twitter.com/schuchalexander"
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/aschuch/QRCode.git", :tag => s.version }
s.source = { :git => "https://github.com/lgw51/QRCode.git", :tag => s.version }
s.requires_arc = true
s.source_files = "QRCode/QRCode.swift", "QRCode/UIImageViewExtension.swift", "QRCode/CIColorExtension.swift", "QRCode/CIImageExtension.swift"
end
2 changes: 1 addition & 1 deletion QRCode/CIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension CIColor {
var hexValue: CUnsignedLongLong = 0

if scanner.scanHexInt64(&hexValue) {
let length = rgba.characters.count
let length = rgba.count

switch (length) {
case 3:
Expand Down
4 changes: 3 additions & 1 deletion QRCode/CIImageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

import Foundation
import UIKit
import CoreImage

internal typealias Scale = (dx: CGFloat, dy: CGFloat)

Expand All @@ -18,7 +20,7 @@ internal extension CIImage {
///
/// - returns: an non-interpolated UIImage
internal func nonInterpolatedImage(withScale scale: Scale = Scale(dx: 1, dy: 1)) -> UIImage? {
guard let cgImage = CIContext(options: nil).createCGImage(self, from: self.extent) else { return nil }
guard let cgImage = CIContext().createCGImage(self, from: self.extent) else { return nil }
let size = CGSize(width: self.extent.size.width * scale.dx, height: self.extent.size.height * scale.dy)

UIGraphicsBeginImageContextWithOptions(size, true, 0)
Expand Down
2 changes: 1 addition & 1 deletion QRCode/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
48 changes: 41 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# QRCode 🔳

[![Build Status](https://travis-ci.org/aschuch/QRCode.svg)](https://travis-ci.org/aschuch/QRCode)
[![Build Status](https://travis-ci.org/ekscrypto/QRCode.svg)](https://travis-ci.org/ekscrypto/QRCode)
![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)
![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg)
![Swift 4.0](https://img.shields.io/badge/Swift-4.0-orange.svg)

A QRCode generator written in Swift.

Expand Down Expand Up @@ -54,6 +54,33 @@ qrCode.image // UIImage (green QRCode color and black background)

> **Note**: The above examples make use of the `CIColor` extension that ships with this project to create colors based on HEX strings.

**Error Correction**

QR codes support a configurable error correction setting. This controls how much of the generated image can be damaged or occluded, while still allowing for the code to be recognized correctly.

To set error correction:

```swift
qrCode.errorCorrection = .High
```

If you do not declare this property, the default will be `.Low`.

Valid values and the corresponding error correction ability are:

| Parameter Val | Correction Ability |
| ------------- | ------------------ |
| Low | Approx 7% |
| Medium | Approx 15% |
| Quartile | Approx 25% |
| High | Approx 30% |

> For more information on Error Correction, see [QRcode.com](http://www.qrcode.com/en/about/error_correction.html).

*Why would you want higher error correction?*

Setting error correction above the default of Low allows you to create a QR code that can be damaged or covered but still scanned correctly. This allows for wear (if on a printed code) but also allows the use of graphics on top of the code. Therefore, QR codes can include a logo or other branding right over the qr code image (covering a part of it) and still will work. Note, however, that a higher amount of error correction also means that the QR code will be more "dense" (and therefore limits how small it might be printed/displayed.)

### UIImageView extension

For convenience, a `UIImageView` extension is provided to directly initialize an image view with an instance of `QRCode`.
Expand All @@ -76,11 +103,12 @@ Current Swift compatibility breakdown:

| Swift Version | Framework Version |
| ------------- | ----------------- |
| 3.0 | 2.x |
| 4.0 | 2.0.1 |
| 3.0 | 2.0 |
| 2.3 | 1.x |
| 2.2 | 0.x |

[all releases]: https://github.com/aschuch/QRCode/releases
[all releases]: https://github.com/ekscrypto/QRCode/releases

## Installation

Expand All @@ -89,7 +117,7 @@ Current Swift compatibility breakdown:
Add the following line to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).

```
github "aschuch/QRCode"
github "ekscrypto/QRCode"
```

Then run `carthage update`.
Expand All @@ -99,10 +127,10 @@ Then run `carthage update`.
Add the following line to your Podfile.

```
pod "QRCode"
pod "QRCode", :git => "https://github.com/ekscrypto/QRCode.git"
```

Then run `pod install` with Cocoapods 0.36 or newer.
Then run `pod install` with Cocoapods 1.5.3 or newer.

#### Manually

Expand Down Expand Up @@ -137,5 +165,11 @@ xctool -scheme QRCodeTests -sdk iphonesimulator test

Feel free to get in touch.

Original author:
* Website: <http://schuch.me>
* Twitter: [@schuchalexander](http://twitter.com/schuchalexander)

Latest updates:
* Website: <http://soft.io>
* Twitter: [@ekscrypto](https://twitter.com/ekscrypto)