Skip to content

Commit

Permalink
Merge branch 'swift2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuch committed Sep 8, 2016
2 parents 8c800e7 + 6ed386f commit 44abb5e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
20 changes: 19 additions & 1 deletion Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,20 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Alexander Schuch";
TargetAttributes = {
4D248F061A751C3700E44E6B = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0800;
};
4D248F301A751C7800E44E6B = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0800;
};
4D248F3A1A751C7800E44E6B = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0800;
TestTargetID = 4D248F061A751C3700E44E6B;
};
};
Expand Down Expand Up @@ -409,8 +412,10 @@
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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -419,6 +424,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -452,15 +458,18 @@
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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -470,6 +479,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -483,6 +493,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -495,13 +506,15 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Release;
};
4D248F4B1A751C7800E44E6B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -519,6 +532,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -529,6 +543,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -541,6 +556,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -559,6 +575,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
Expand All @@ -571,6 +588,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
Expand Down
24 changes: 22 additions & 2 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 = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,9 +26,29 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D248F3A1A751C7800E44E6B"
BuildableName = "QRCodeTests.xctest"
BlueprintName = "QRCodeTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D248F301A751C7800E44E6B"
BuildableName = "QRCode.framework"
BlueprintName = "QRCode"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand Down
11 changes: 10 additions & 1 deletion Example.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -79,6 +79,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D248F3A1A751C7800E44E6B"
BuildableName = "QRCodeTests.xctest"
BlueprintName = "QRCodeTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
2 changes: 1 addition & 1 deletion QRCode.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QRCode"
s.version = "0.5"
s.version = "1.0"
s.summary = "A QRCode generator written in Swift."
s.description = "Generate QRCodes and customize their appearance."
s.homepage = "https://github.com/aschuch/QRCode"
Expand Down
8 changes: 4 additions & 4 deletions QRCode/CIImageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ internal extension CIImage {
/// - parameter withScale: a given scale using to resize the result image
///
/// - returns: an non-interpolated UIImage
internal func nonInterpolatedImage(withScale scale: Scale = Scale(dx: 1, dy: 1)) -> UIImage {
let cgImage = CIContext(options: nil).createCGImage(self, fromRect: self.extent)
internal func nonInterpolatedImage(withScale scale: Scale = Scale(dx: 1, dy: 1)) -> UIImage? {
guard let cgImage = CIContext(options: nil).createCGImage(self, fromRect: 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)
let context = UIGraphicsGetCurrentContext()
guard let context = UIGraphicsGetCurrentContext() else { return nil }

CGContextSetInterpolationQuality(context, .None)

Expand All @@ -36,4 +36,4 @@ internal extension CIImage {

return result
}
}
}
2 changes: 1 addition & 1 deletion QRCode/QRCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct QRCode {
}

public init?(_ url: NSURL) {
if let data = url.absoluteString.dataUsingEncoding(NSISOLatin1StringEncoding) {
if let data = url.absoluteString?.dataUsingEncoding(NSISOLatin1StringEncoding) {
self.data = data
} else {
return nil
Expand Down
2 changes: 1 addition & 1 deletion QRCodeTests/QRCodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class QRCodeTests: XCTestCase {

func testInitWithURL() {
let url = NSURL(string: "http://example.com")!
let data = url.absoluteString.dataUsingEncoding(NSISOLatin1StringEncoding)!
let data = url.absoluteString!.dataUsingEncoding(NSISOLatin1StringEncoding)!
let qrCode = QRCode(url)

XCTAssert(qrCode != nil, "QRCode is nil")
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

> This project is [Migrating to Swift 3](http://www.jessesquires.com/migrating-to-swift-3/).
> * Swift 2.3 is currently available from the [`swift2.3` branch](https://github.com/aschuch/QRCode/tree/swift2.3)
Expand All @@ -12,7 +12,7 @@ A QRCode generator written in Swift.

![QRCode Example](Resources/example.png)

## Usage
## Overview

Create a new QRCode representing a `NSURL`, a string or arbitrary data.
The following examples all result in the same QRCode image.
Expand Down Expand Up @@ -74,6 +74,17 @@ In case you love emoji as much as I do, make sure to create your `QRCode` instan
let qrCode = 🔳("http://example.com")
```

## Version Compatibility

Current Swift compatibility breakdown:

| Swift Version | Framework Version |
| ------------- | ----------------- |
| 2.3 | 1.x |
| 2.2 | 0.x |

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

## Installation

#### Carthage
Expand Down

0 comments on commit 44abb5e

Please sign in to comment.