From afc83ade5bbec6ee581e1f592db6b63bb00f8bce Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:04:58 +0200 Subject: [PATCH 01/11] Replace stray tabs with spaces --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bb0285..21b33f3 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,9 @@ Current Swift compatibility breakdown: | Swift Version | Framework Version | | ------------- | ----------------- | -| 3.0 | 2.x | -| 2.3 | 1.x | -| 2.2 | 0.x | +| 3.0 | 2.x | +| 2.3 | 1.x | +| 2.2 | 0.x | [all releases]: https://github.com/aschuch/QRCode/releases From ab667362e9ca3cd04629f3f252ff3f7284a51ee5 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:08:13 +0200 Subject: [PATCH 02/11] Remove trailing whitespace and superfluous empty lines --- Example/ViewController.swift | 12 ++++----- QRCode/CIColorExtension.swift | 14 +++++------ QRCode/CIImageExtension.swift | 6 ++--- QRCode/QRCode.swift | 40 ++++++++++++++--------------- QRCode/UIImageViewExtension.swift | 4 +-- QRCodeTests/QRCodeTests.swift | 42 +++++++++++++++---------------- README.md | 2 +- 7 files changed, 59 insertions(+), 61 deletions(-) diff --git a/Example/ViewController.swift b/Example/ViewController.swift index e3e3072..605f111 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -18,10 +18,9 @@ class ViewController: UIViewController { @IBOutlet weak var imageViewMedium: UIImageView! @IBOutlet weak var imageViewLarge: UIImageView! - override func viewDidLoad() { super.viewDidLoad() - + // large // default imageViewLarge.image = { @@ -30,7 +29,7 @@ class ViewController: UIViewController { qrCode.errorCorrection = .High return qrCode.image }() - + // medium // purple imageViewMedium.image = { @@ -39,7 +38,7 @@ class ViewController: UIViewController { qrCode.color = CIColor(rgba: "8e44ad") return qrCode.image }() - + // small // red (inverted) imageViewSmall1.image = { @@ -49,7 +48,7 @@ class ViewController: UIViewController { qrCode.backgroundColor = CIColor(rgba: "e74c3c") return qrCode.image }() - + // small // green imageViewSmall2.image = { @@ -59,7 +58,7 @@ class ViewController: UIViewController { qrCode.backgroundColor = CIColor(rgba: "000") return qrCode.image }() - + // small // orange imageViewSmall3.image = { @@ -70,7 +69,6 @@ class ViewController: UIViewController { return qrCode.image }() - // small // blue imageViewSmall4.image = { diff --git a/QRCode/CIColorExtension.swift b/QRCode/CIColorExtension.swift index 40b4435..070552e 100644 --- a/QRCode/CIColorExtension.swift +++ b/QRCode/CIColorExtension.swift @@ -9,7 +9,7 @@ import UIKit public extension CIColor { - + /// Creates a CIColor from an rgba string /// /// E.g. @@ -24,13 +24,13 @@ public extension CIColor { var g: CGFloat = 0.0 var b: CGFloat = 0.0 var a: CGFloat = 1.0 - + let scanner = Scanner(string: rgba) var hexValue: CUnsignedLongLong = 0 - + if scanner.scanHexInt64(&hexValue) { let length = rgba.characters.count - + switch (length) { case 3: r = CGFloat((hexValue & 0xF00) >> 8) / 15.0 @@ -53,12 +53,12 @@ public extension CIColor { default: print("Invalid number of values (\(length)) in HEX string. Make sure to enter 3, 4, 6 or 8 values. E.g. `aabbccff`") } - + } else { print("Invalid HEX value: \(rgba)") } - + self.init(red: r, green: g, blue: b, alpha: a) } - + } diff --git a/QRCode/CIImageExtension.swift b/QRCode/CIImageExtension.swift index f096069..fdb2433 100644 --- a/QRCode/CIImageExtension.swift +++ b/QRCode/CIImageExtension.swift @@ -11,7 +11,7 @@ import Foundation internal typealias Scale = (dx: CGFloat, dy: CGFloat) internal extension CIImage { - + /// Creates an `UIImage` with interpolation disabled and scaled given a scale property /// /// - parameter withScale: a given scale using to resize the result image @@ -20,7 +20,7 @@ internal extension CIImage { 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 } let size = CGSize(width: self.extent.size.width * scale.dx, height: self.extent.size.height * scale.dy) - + UIGraphicsBeginImageContextWithOptions(size, true, 0) guard let context = UIGraphicsGetCurrentContext() else { return nil } context.interpolationQuality = .none @@ -29,7 +29,7 @@ internal extension CIImage { context.draw(cgImage, in: context.boundingBoxOfClipPath) let result = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() - + return result } } diff --git a/QRCode/QRCode.swift b/QRCode/QRCode.swift index 826ee94..67e4ea4 100644 --- a/QRCode/QRCode.swift +++ b/QRCode/QRCode.swift @@ -12,10 +12,10 @@ public typealias 🔳 = QRCode /// QRCode generator public struct QRCode { - + /** The level of error correction. - + - Low: 7% - Medium: 15% - Quartile: 25% @@ -27,30 +27,30 @@ public struct QRCode { case Quartile = "Q" case High = "H" } - + /// Data contained in the generated QRCode public let data: Data - + /// Foreground color of the output /// Defaults to black public var color = CIColor(red: 0, green: 0, blue: 0) - + /// Background color of the output /// Defaults to white public var backgroundColor = CIColor(red: 1, green: 1, blue: 1) - + /// Size of the output public var size = CGSize(width: 200, height: 200) - + /// The error correction. The default value is `.Low`. public var errorCorrection = ErrorCorrection.Low - + // MARK: Init - + public init(_ data: Data) { self.data = data } - + public init?(_ string: String) { if let data = string.data(using: .isoLatin1) { self.data = data @@ -58,7 +58,7 @@ public struct QRCode { return nil } } - + public init?(_ url: URL) { if let data = url.absoluteString.data(using: .isoLatin1) { self.data = data @@ -66,38 +66,38 @@ public struct QRCode { return nil } } - + // MARK: Generate QRCode - + /// The QRCode's UIImage representation public var image: UIImage? { guard let ciImage = ciImage else { return nil } - + // Size let ciImageSize = ciImage.extent.size let widthRatio = size.width / ciImageSize.width let heightRatio = size.height / ciImageSize.height - + return ciImage.nonInterpolatedImage(withScale: Scale(dx: widthRatio, dy: heightRatio)) } - + /// The QRCode's CIImage representation public var ciImage: CIImage? { // Generate QRCode guard let qrFilter = CIFilter(name: "CIQRCodeGenerator") else { return nil } - + qrFilter.setDefaults() qrFilter.setValue(data, forKey: "inputMessage") qrFilter.setValue(self.errorCorrection.rawValue, forKey: "inputCorrectionLevel") - + // Color code and background guard let colorFilter = CIFilter(name: "CIFalseColor") else { return nil } - + colorFilter.setDefaults() colorFilter.setValue(qrFilter.outputImage, forKey: "inputImage") colorFilter.setValue(color, forKey: "inputColor0") colorFilter.setValue(backgroundColor, forKey: "inputColor1") - + return colorFilter.outputImage } } diff --git a/QRCode/UIImageViewExtension.swift b/QRCode/UIImageViewExtension.swift index 789175d..2c4035b 100644 --- a/QRCode/UIImageViewExtension.swift +++ b/QRCode/UIImageViewExtension.swift @@ -9,12 +9,12 @@ import UIKit public extension UIImageView { - + /// Creates a new image view with the given QRCode /// /// - parameter qrCode: The QRCode to display in the image view public convenience init(qrCode: QRCode) { self.init(image: qrCode.image) } - + } diff --git a/QRCodeTests/QRCodeTests.swift b/QRCodeTests/QRCodeTests.swift index d1cf844..7a5a7ca 100644 --- a/QRCodeTests/QRCodeTests.swift +++ b/QRCodeTests/QRCodeTests.swift @@ -11,28 +11,28 @@ import XCTest @testable import QRCode class QRCodeTests: XCTestCase { - + func testDefaultValues() { let qrCode = QRCode("hello") - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssertEqual(CIColor(red: 0, green: 0, blue: 0), qrCode!.color, "Initial color is not black") XCTAssertEqual(CIColor(red: 1, green: 1, blue: 1), qrCode!.backgroundColor, "Initial backgroundColor is not white") XCTAssertEqual(CGSize(width: 200, height: 200), qrCode!.size, "Initial size is not 200x200") } - + func testInitWithData() { let data = "hello".data(using: .isoLatin1)! let qrCode = QRCode(data) - + XCTAssertEqual(data, qrCode.data, "data is not equal") } - + func testInitWithString() { let string = "hello" let data = string.data(using: .isoLatin1)! let qrCode = QRCode(string) - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssertEqual(data, qrCode!.data, "data is not equal") } @@ -41,53 +41,53 @@ class QRCodeTests: XCTestCase { let url = URL(string: "http://example.com")! let data = url.absoluteString.data(using: .isoLatin1)! let qrCode = QRCode(url) - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssertEqual(data, qrCode!.data, "data is not equal") } - + func testColor() { let red = CIColor(red: 1, green: 0, blue: 0) let blue = CIColor(red: 0, green: 0, blue: 1) - + var qrCode = QRCode("hello") qrCode?.color = red qrCode?.backgroundColor = blue - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssertEqual(red, qrCode!.color, "color is not red") XCTAssertEqual(blue, qrCode!.backgroundColor, "backgroundColor is not blue") - + qrCode?.color = blue qrCode?.backgroundColor = red - + XCTAssertEqual(blue, qrCode!.color, "color is not blue") XCTAssertEqual(red, qrCode!.backgroundColor, "backgroundColor is not red") } - + func testSize() { var size = CGSize(width: 400, height: 400) - + var qrCode = QRCode("hello") qrCode?.size = size - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssertEqual(size, qrCode!.size, "size is not equal") - + size = CGSize(width: 10.457, height: 12.454) qrCode?.size = size - + XCTAssertEqual(size, qrCode!.size, "size is not equal") } - + func testImageSize() { let size = CGSize(width: 100, height: 100) - + var qrCode = QRCode("hello") qrCode?.size = size - + let image = qrCode?.image - + XCTAssert(qrCode != nil, "QRCode is nil") XCTAssert(image != nil, "image is nil") XCTAssertEqual(image!.size, size) diff --git a/README.md b/README.md index 21b33f3..72de3f4 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ qrCode.backgroundColor = CIColor(rgba: "000") 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. +> **Note**: The above examples make use of the `CIColor` extension that ships with this project to create colors based on HEX strings. ### UIImageView extension From 66e0b42e9d9af9418257deae8c84f84600ff1b5e Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:10:28 +0200 Subject: [PATCH 03/11] Use more specific import --- QRCode/CIColorExtension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QRCode/CIColorExtension.swift b/QRCode/CIColorExtension.swift index 070552e..03565bb 100644 --- a/QRCode/CIColorExtension.swift +++ b/QRCode/CIColorExtension.swift @@ -6,7 +6,7 @@ // Copyright (c) 2015 Alexander Schuch. All rights reserved. // -import UIKit +import CoreImage public extension CIColor { From 2d5d84b106a2f3c02369aeee736da0c645b90095 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 18:50:51 +0200 Subject: [PATCH 04/11] Rename Xcode project It's confusing if the project is simply called "Example", especially if you add the project as dependency to another project. Lets call it "QRCode" instead. --- .travis.yml | 2 +- .../project.pbxproj | 4 ++-- .../project.xcworkspace/contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/QRCode.xcscheme | 10 +++++----- .../xcshareddata/xcschemes/QRCodeTests.xcscheme | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) rename {Example.xcodeproj => QRCode.xcodeproj}/project.pbxproj (99%) rename {Example.xcodeproj => QRCode.xcodeproj}/project.xcworkspace/contents.xcworkspacedata (71%) rename {Example.xcodeproj => QRCode.xcodeproj}/xcshareddata/xcschemes/QRCode.xcscheme (90%) rename {Example.xcodeproj => QRCode.xcodeproj}/xcshareddata/xcschemes/QRCodeTests.xcscheme (90%) diff --git a/.travis.yml b/.travis.yml index 99858c0..a140a34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ env: global: - LC_CTYPE=en_US.UTF-8 - LANG=en_US.UTF-8 - - PROJECT=Example.xcodeproj + - PROJECT=QRCode.xcodeproj - IOS_FRAMEWORK_SCHEME="QRCode" # -iOS #- TVOS_FRAMEWORK_SCHEME="QRCode-tvOS" #- WATCHOS_FRAMEWORK_SCHEME="QRCode-watchOS" diff --git a/Example.xcodeproj/project.pbxproj b/QRCode.xcodeproj/project.pbxproj similarity index 99% rename from Example.xcodeproj/project.pbxproj rename to QRCode.xcodeproj/project.pbxproj index 042dddb..5aaf6a8 100644 --- a/Example.xcodeproj/project.pbxproj +++ b/QRCode.xcodeproj/project.pbxproj @@ -283,7 +283,7 @@ }; }; }; - buildConfigurationList = 4D248F021A751C3700E44E6B /* Build configuration list for PBXProject "Example" */; + buildConfigurationList = 4D248F021A751C3700E44E6B /* Build configuration list for PBXProject "QRCode" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -598,7 +598,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 4D248F021A751C3700E44E6B /* Build configuration list for PBXProject "Example" */ = { + 4D248F021A751C3700E44E6B /* Build configuration list for PBXProject "QRCode" */ = { isa = XCConfigurationList; buildConfigurations = ( 4D248F241A751C3700E44E6B /* Debug */, diff --git a/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/QRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 71% rename from Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to QRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 6d2a51b..034c9dc 100644 --- a/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/QRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:QRCode.xcodeproj"> diff --git a/Example.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme similarity index 90% rename from Example.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme rename to QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme index 820d857..91153ba 100644 --- a/Example.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme @@ -17,7 +17,7 @@ BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" BlueprintName = "QRCode" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -36,7 +36,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -46,7 +46,7 @@ BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" BlueprintName = "QRCode" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -68,7 +68,7 @@ BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" BlueprintName = "QRCode" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -86,7 +86,7 @@ BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" BlueprintName = "QRCode" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> diff --git a/Example.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme similarity index 90% rename from Example.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme rename to QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme index 44264cb..115ceef 100644 --- a/Example.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme @@ -17,7 +17,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -35,7 +35,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -45,7 +45,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -67,7 +67,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> @@ -85,7 +85,7 @@ BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" BlueprintName = "QRCodeTests" - ReferencedContainer = "container:Example.xcodeproj"> + ReferencedContainer = "container:QRCode.xcodeproj"> From 4f4884e0adff548be2d631884b6f4e3bb4338bb5 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:39:47 +0200 Subject: [PATCH 05/11] Remove superfluous preprocessor macro `DEBUG=1` is already set by default. --- QRCode.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/QRCode.xcodeproj/project.pbxproj b/QRCode.xcodeproj/project.pbxproj index 5aaf6a8..85ddf37 100644 --- a/QRCode.xcodeproj/project.pbxproj +++ b/QRCode.xcodeproj/project.pbxproj @@ -522,10 +522,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); INFOPLIST_FILE = QRCode/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -569,10 +565,6 @@ isa = XCBuildConfiguration; buildSettings = { FRAMEWORK_SEARCH_PATHS = ""; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); INFOPLIST_FILE = QRCodeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; From a705d63fc681e3d97d723fa1ccb560ee12e60cb8 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:40:46 +0200 Subject: [PATCH 06/11] Remove test dependency on example app --- QRCode.xcodeproj/project.pbxproj | 15 --------------- .../xcschemes/QRCodeTests.xcscheme | 19 ------------------- 2 files changed, 34 deletions(-) diff --git a/QRCode.xcodeproj/project.pbxproj b/QRCode.xcodeproj/project.pbxproj index 85ddf37..e74b4bb 100644 --- a/QRCode.xcodeproj/project.pbxproj +++ b/QRCode.xcodeproj/project.pbxproj @@ -31,13 +31,6 @@ remoteGlobalIDString = 4D248F301A751C7800E44E6B; remoteInfo = QRCode; }; - 4D248F3F1A751C7800E44E6B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4D248F061A751C3700E44E6B; - remoteInfo = Example; - }; 4D248F461A751C7800E44E6B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; @@ -250,7 +243,6 @@ ); dependencies = ( 4D248F3E1A751C7800E44E6B /* PBXTargetDependency */, - 4D248F401A751C7800E44E6B /* PBXTargetDependency */, ); name = QRCodeTests; productName = QRCodeTests; @@ -367,11 +359,6 @@ target = 4D248F301A751C7800E44E6B /* QRCode */; targetProxy = 4D248F3D1A751C7800E44E6B /* PBXContainerItemProxy */; }; - 4D248F401A751C7800E44E6B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4D248F061A751C3700E44E6B /* Example */; - targetProxy = 4D248F3F1A751C7800E44E6B /* PBXContainerItemProxy */; - }; 4D248F471A751C7800E44E6B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4D248F301A751C7800E44E6B /* QRCode */; @@ -570,7 +557,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0.1; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; name = Debug; }; @@ -583,7 +569,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0.1; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; name = Release; }; diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme index 115ceef..74c8488 100644 --- a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme @@ -28,16 +28,6 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - - - - - From 20990794ce08fd41b50e3c6f2d798a4ef2089f84 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:43:21 +0200 Subject: [PATCH 07/11] Add scheme for the example app --- .../xcshareddata/xcschemes/Example.xcscheme | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme new file mode 100644 index 0000000..6190689 --- /dev/null +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3e9e06cff6e8023e2fc1f090f25719adda38a72e Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Thu, 10 Aug 2017 00:34:41 +0200 Subject: [PATCH 08/11] Select a default device for preview in Interface Builder --- Example/Base.lproj/LaunchScreen.xib | 13 +++++++++---- Example/Base.lproj/Main.storyboard | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Example/Base.lproj/LaunchScreen.xib b/Example/Base.lproj/LaunchScreen.xib index dde6076..34c6f70 100644 --- a/Example/Base.lproj/LaunchScreen.xib +++ b/Example/Base.lproj/LaunchScreen.xib @@ -1,7 +1,12 @@ - - + + + + + - + + + @@ -9,7 +14,7 @@ - + diff --git a/Example/Base.lproj/Main.storyboard b/Example/Base.lproj/Main.storyboard index 80e98c3..4e7008c 100644 --- a/Example/Base.lproj/Main.storyboard +++ b/Example/Base.lproj/Main.storyboard @@ -1,7 +1,12 @@ - - + + + + + - + + + @@ -13,11 +18,11 @@ - + - + @@ -70,7 +75,7 @@ - + @@ -92,7 +97,7 @@ - + From 06c0ef45630ba17c12e6e3d779cc8a4814ba311b Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:57:56 +0200 Subject: [PATCH 09/11] Update the asset catalogue Actually, Xcode automatically did it. --- .../Images.xcassets/AppIcon.appiconset/Contents.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Example/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Images.xcassets/AppIcon.appiconset/Contents.json index 118c98f..b8236c6 100644 --- a/Example/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", From 1e6d573e47dc83e7889bb78c02565384ec96de58 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 23:57:07 +0200 Subject: [PATCH 10/11] Add iOS suffix to targets in preparation of macOS support --- {Example => Example_iOS}/AppDelegate.swift | 0 .../Base.lproj/LaunchScreen.xib | 0 .../Base.lproj/Main.storyboard | 0 .../AppIcon.appiconset/Contents.json | 0 {Example => Example_iOS}/Info.plist | 0 {Example => Example_iOS}/ViewController.swift | 0 QRCode.xcodeproj/project.pbxproj | 68 +++++++++---------- ...{Example.xcscheme => Example_iOS.xcscheme} | 10 +-- ...ests.xcscheme => QRCodeTests_iOS.xcscheme} | 6 +- .../{QRCode.xcscheme => QRCode_iOS.xcscheme} | 10 +-- README.md | 2 +- 11 files changed, 48 insertions(+), 48 deletions(-) rename {Example => Example_iOS}/AppDelegate.swift (100%) rename {Example => Example_iOS}/Base.lproj/LaunchScreen.xib (100%) rename {Example => Example_iOS}/Base.lproj/Main.storyboard (100%) rename {Example => Example_iOS}/Images.xcassets/AppIcon.appiconset/Contents.json (100%) rename {Example => Example_iOS}/Info.plist (100%) rename {Example => Example_iOS}/ViewController.swift (100%) rename QRCode.xcodeproj/xcshareddata/xcschemes/{Example.xcscheme => Example_iOS.xcscheme} (94%) rename QRCode.xcodeproj/xcshareddata/xcschemes/{QRCodeTests.xcscheme => QRCodeTests_iOS.xcscheme} (95%) rename QRCode.xcodeproj/xcshareddata/xcschemes/{QRCode.xcscheme => QRCode_iOS.xcscheme} (94%) diff --git a/Example/AppDelegate.swift b/Example_iOS/AppDelegate.swift similarity index 100% rename from Example/AppDelegate.swift rename to Example_iOS/AppDelegate.swift diff --git a/Example/Base.lproj/LaunchScreen.xib b/Example_iOS/Base.lproj/LaunchScreen.xib similarity index 100% rename from Example/Base.lproj/LaunchScreen.xib rename to Example_iOS/Base.lproj/LaunchScreen.xib diff --git a/Example/Base.lproj/Main.storyboard b/Example_iOS/Base.lproj/Main.storyboard similarity index 100% rename from Example/Base.lproj/Main.storyboard rename to Example_iOS/Base.lproj/Main.storyboard diff --git a/Example/Images.xcassets/AppIcon.appiconset/Contents.json b/Example_iOS/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Example/Images.xcassets/AppIcon.appiconset/Contents.json rename to Example_iOS/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/Example/Info.plist b/Example_iOS/Info.plist similarity index 100% rename from Example/Info.plist rename to Example_iOS/Info.plist diff --git a/Example/ViewController.swift b/Example_iOS/ViewController.swift similarity index 100% rename from Example/ViewController.swift rename to Example_iOS/ViewController.swift diff --git a/QRCode.xcodeproj/project.pbxproj b/QRCode.xcodeproj/project.pbxproj index e74b4bb..33ccc1b 100644 --- a/QRCode.xcodeproj/project.pbxproj +++ b/QRCode.xcodeproj/project.pbxproj @@ -104,7 +104,7 @@ 4D248EFE1A751C3700E44E6B = { isa = PBXGroup; children = ( - 4D248F091A751C3700E44E6B /* Example */, + 4D248F091A751C3700E44E6B /* Example_iOS */, 4D248F321A751C7800E44E6B /* QRCode */, 4D248F411A751C7800E44E6B /* QRCodeTests */, 4D248F081A751C3700E44E6B /* Products */, @@ -121,7 +121,7 @@ name = Products; sourceTree = ""; }; - 4D248F091A751C3700E44E6B /* Example */ = { + 4D248F091A751C3700E44E6B /* Example_iOS */ = { isa = PBXGroup; children = ( 4D248F0C1A751C3700E44E6B /* AppDelegate.swift */, @@ -131,7 +131,7 @@ 4D248F151A751C3700E44E6B /* LaunchScreen.xib */, 4D248F0A1A751C3700E44E6B /* Supporting Files */, ); - path = Example; + path = Example_iOS; sourceTree = ""; }; 4D248F0A1A751C3700E44E6B /* Supporting Files */ = { @@ -194,9 +194,9 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 4D248F061A751C3700E44E6B /* Example */ = { + 4D248F061A751C3700E44E6B /* Example_iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = 4D248F261A751C3700E44E6B /* Build configuration list for PBXNativeTarget "Example" */; + buildConfigurationList = 4D248F261A751C3700E44E6B /* Build configuration list for PBXNativeTarget "Example_iOS" */; buildPhases = ( 4D248F031A751C3700E44E6B /* Sources */, 4D248F041A751C3700E44E6B /* Frameworks */, @@ -208,14 +208,14 @@ dependencies = ( 4D248F471A751C7800E44E6B /* PBXTargetDependency */, ); - name = Example; + name = Example_iOS; productName = Example; productReference = 4D248F071A751C3700E44E6B /* Example.app */; productType = "com.apple.product-type.application"; }; - 4D248F301A751C7800E44E6B /* QRCode */ = { + 4D248F301A751C7800E44E6B /* QRCode_iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = 4D248F4A1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCode" */; + buildConfigurationList = 4D248F4A1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCode_iOS" */; buildPhases = ( 4D248F2C1A751C7800E44E6B /* Sources */, 4D248F2D1A751C7800E44E6B /* Frameworks */, @@ -226,14 +226,14 @@ ); dependencies = ( ); - name = QRCode; + name = QRCode_iOS; productName = QRCode; productReference = 4D248F311A751C7800E44E6B /* QRCode.framework */; productType = "com.apple.product-type.framework"; }; - 4D248F3A1A751C7800E44E6B /* QRCodeTests */ = { + 4D248F3A1A751C7800E44E6B /* QRCodeTests_iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = 4D248F4E1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCodeTests" */; + buildConfigurationList = 4D248F4E1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCodeTests_iOS" */; buildPhases = ( 4D248F371A751C7800E44E6B /* Sources */, 4D248F381A751C7800E44E6B /* Frameworks */, @@ -244,7 +244,7 @@ dependencies = ( 4D248F3E1A751C7800E44E6B /* PBXTargetDependency */, ); - name = QRCodeTests; + name = QRCodeTests_iOS; productName = QRCodeTests; productReference = 4D248F3B1A751C7800E44E6B /* QRCodeTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; @@ -288,9 +288,9 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 4D248F061A751C3700E44E6B /* Example */, - 4D248F301A751C7800E44E6B /* QRCode */, - 4D248F3A1A751C7800E44E6B /* QRCodeTests */, + 4D248F061A751C3700E44E6B /* Example_iOS */, + 4D248F301A751C7800E44E6B /* QRCode_iOS */, + 4D248F3A1A751C7800E44E6B /* QRCodeTests_iOS */, ); }; /* End PBXProject section */ @@ -356,12 +356,12 @@ /* Begin PBXTargetDependency section */ 4D248F3E1A751C7800E44E6B /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 4D248F301A751C7800E44E6B /* QRCode */; + target = 4D248F301A751C7800E44E6B /* QRCode_iOS */; targetProxy = 4D248F3D1A751C7800E44E6B /* PBXContainerItemProxy */; }; 4D248F471A751C7800E44E6B /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 4D248F301A751C7800E44E6B /* QRCode */; + target = 4D248F301A751C7800E44E6B /* QRCode_iOS */; targetProxy = 4D248F461A751C7800E44E6B /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -477,11 +477,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = Example/Info.plist; + INFOPLIST_FILE = Example_iOS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.Example.iOS; + PRODUCT_NAME = Example; SWIFT_VERSION = 3.0.1; }; name = Debug; @@ -490,11 +490,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = Example/Info.plist; + INFOPLIST_FILE = Example_iOS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.Example.iOS; + PRODUCT_NAME = Example; SWIFT_VERSION = 3.0.1; }; name = Release; @@ -513,8 +513,8 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; + PRODUCT_NAME = QRCode; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0.1; @@ -538,8 +538,8 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; + PRODUCT_NAME = QRCode; SKIP_INSTALL = YES; SWIFT_VERSION = 3.0.1; TARGETED_DEVICE_FAMILY = "1,2"; @@ -554,8 +554,8 @@ FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = QRCodeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; + PRODUCT_NAME = QRCodeTests; SWIFT_VERSION = 3.0.1; }; name = Debug; @@ -566,8 +566,8 @@ FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = QRCodeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; + PRODUCT_NAME = QRCodeTests; SWIFT_VERSION = 3.0.1; }; name = Release; @@ -584,7 +584,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 4D248F261A751C3700E44E6B /* Build configuration list for PBXNativeTarget "Example" */ = { + 4D248F261A751C3700E44E6B /* Build configuration list for PBXNativeTarget "Example_iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 4D248F271A751C3700E44E6B /* Debug */, @@ -593,7 +593,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 4D248F4A1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCode" */ = { + 4D248F4A1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCode_iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 4D248F4B1A751C7800E44E6B /* Debug */, @@ -602,7 +602,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 4D248F4E1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCodeTests" */ = { + 4D248F4E1A751C7800E44E6B /* Build configuration list for PBXNativeTarget "QRCodeTests_iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 4D248F4F1A751C7800E44E6B /* Debug */, diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/Example_iOS.xcscheme similarity index 94% rename from QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme rename to QRCode.xcodeproj/xcshareddata/xcschemes/Example_iOS.xcscheme index 6190689..130614b 100644 --- a/QRCode.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/Example_iOS.xcscheme @@ -16,7 +16,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F061A751C3700E44E6B" BuildableName = "Example.app" - BlueprintName = "Example" + BlueprintName = "Example_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -35,7 +35,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" - BlueprintName = "QRCodeTests" + BlueprintName = "QRCodeTests_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -45,7 +45,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F061A751C3700E44E6B" BuildableName = "Example.app" - BlueprintName = "Example" + BlueprintName = "Example_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -68,7 +68,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F061A751C3700E44E6B" BuildableName = "Example.app" - BlueprintName = "Example" + BlueprintName = "Example_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -87,7 +87,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F061A751C3700E44E6B" BuildableName = "Example.app" - BlueprintName = "Example" + BlueprintName = "Example_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_iOS.xcscheme similarity index 95% rename from QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme rename to QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_iOS.xcscheme index 74c8488..4353553 100644 --- a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_iOS.xcscheme @@ -16,7 +16,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" - BlueprintName = "QRCodeTests" + BlueprintName = "QRCodeTests_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -34,7 +34,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" - BlueprintName = "QRCodeTests" + BlueprintName = "QRCodeTests_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -56,7 +56,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" - BlueprintName = "QRCodeTests" + BlueprintName = "QRCodeTests_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme similarity index 94% rename from QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme rename to QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme index 91153ba..e94e15c 100644 --- a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme @@ -16,7 +16,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" - BlueprintName = "QRCode" + BlueprintName = "QRCode_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -35,7 +35,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F3A1A751C7800E44E6B" BuildableName = "QRCodeTests.xctest" - BlueprintName = "QRCodeTests" + BlueprintName = "QRCodeTests_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -45,7 +45,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" - BlueprintName = "QRCode" + BlueprintName = "QRCode_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -67,7 +67,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" - BlueprintName = "QRCode" + BlueprintName = "QRCode_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> @@ -85,7 +85,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "4D248F301A751C7800E44E6B" BuildableName = "QRCode.framework" - BlueprintName = "QRCode" + BlueprintName = "QRCode_iOS" ReferencedContainer = "container:QRCode.xcodeproj"> diff --git a/README.md b/README.md index 72de3f4..96dd4f3 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Open the Xcode project and press `⌘-U` to run the tests. Alternatively, all tests can be run from the terminal using [xctool](https://github.com/facebook/xctool). ```bash -xctool -scheme QRCodeTests -sdk iphonesimulator test +xctool -scheme QRCodeTests_iOS -sdk iphonesimulator test ``` ## Todo From 147d3a818dc3963e8fbac7ac4ff7dba3b47e08b2 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 9 Aug 2017 22:56:11 +0200 Subject: [PATCH 11/11] Add macOS support Most of the code can be shared, except for the `UIKit` imports, which I conditionally replaced by `Cocoa` imports on macOS. Image handling is slightly different, as the `UI*` classes are not available on macOS. Due to the initializer of `NSImageView` not accepting an optional `NSImage` I refrained from adding a convenient initializer accepting a `QRCode`, where it is unclear if an image could be constructed. --- .travis.yml | 2 +- Example_macOS/AppDelegate.swift | 23 + .../AppIcon.appiconset/Contents.json | 58 ++ Example_macOS/Base.lproj/Main.storyboard | 737 ++++++++++++++++++ Example_macOS/Info.plist | 32 + Example_macOS/ViewController.swift | 83 ++ QRCode.xcodeproj/project.pbxproj | 443 ++++++++++- .../xcschemes/Example_macOS.xcscheme | 102 +++ .../xcschemes/QRCodeTests_macOS.xcscheme | 56 ++ .../xcschemes/QRCode_iOS.xcscheme | 2 +- .../xcschemes/QRCode_macOS.xcscheme | 100 +++ QRCode/CIImageExtension.swift | 46 +- QRCode/QRCode.h | 2 +- QRCode/QRCode.swift | 10 +- QRCodeTests/QRCodeTests.swift | 9 +- README.md | 6 +- 16 files changed, 1676 insertions(+), 35 deletions(-) create mode 100644 Example_macOS/AppDelegate.swift create mode 100644 Example_macOS/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example_macOS/Base.lproj/Main.storyboard create mode 100644 Example_macOS/Info.plist create mode 100644 Example_macOS/ViewController.swift create mode 100644 QRCode.xcodeproj/xcshareddata/xcschemes/Example_macOS.xcscheme create mode 100644 QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_macOS.xcscheme create mode 100644 QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_macOS.xcscheme diff --git a/.travis.yml b/.travis.yml index a140a34..5cf7ea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ env: - LC_CTYPE=en_US.UTF-8 - LANG=en_US.UTF-8 - PROJECT=QRCode.xcodeproj - - IOS_FRAMEWORK_SCHEME="QRCode" # -iOS + - IOS_FRAMEWORK_SCHEME="QRCode_iOS" # -iOS #- TVOS_FRAMEWORK_SCHEME="QRCode-tvOS" #- WATCHOS_FRAMEWORK_SCHEME="QRCode-watchOS" matrix: diff --git a/Example_macOS/AppDelegate.swift b/Example_macOS/AppDelegate.swift new file mode 100644 index 0000000..3a2e335 --- /dev/null +++ b/Example_macOS/AppDelegate.swift @@ -0,0 +1,23 @@ +// +// AppDelegate.swift +// Example_macOS +// +// Created by Maximilian Blochberger on 2017-08-09. +// Copyright © 2017 Alexander Schuch. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } + +} + diff --git a/Example_macOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example_macOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/Example_macOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example_macOS/Base.lproj/Main.storyboard b/Example_macOS/Base.lproj/Main.storyboard new file mode 100644 index 0000000..1622f55 --- /dev/null +++ b/Example_macOS/Base.lproj/Main.storyboard @@ -0,0 +1,737 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example_macOS/Info.plist b/Example_macOS/Info.plist new file mode 100644 index 0000000..1336bb2 --- /dev/null +++ b/Example_macOS/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2017 Alexander Schuch. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/Example_macOS/ViewController.swift b/Example_macOS/ViewController.swift new file mode 100644 index 0000000..64bb174 --- /dev/null +++ b/Example_macOS/ViewController.swift @@ -0,0 +1,83 @@ +// +// ViewController.swift +// Example_macOS +// +// Created by Maximilian Blochberger on 2017-08-09. +// Copyright © 2017 Alexander Schuch. All rights reserved. +// + +import Cocoa +import QRCode + +class ViewController: NSViewController { + + @IBOutlet weak var imageViewSmall1: NSImageView! + @IBOutlet weak var imageViewSmall2: NSImageView! + @IBOutlet weak var imageViewSmall3: NSImageView! + @IBOutlet weak var imageViewSmall4: NSImageView! + @IBOutlet weak var imageViewMedium: NSImageView! + @IBOutlet weak var imageViewLarge: NSImageView! + + override func viewDidLoad() { + super.viewDidLoad() + + // large + // default + imageViewLarge.image = { + var qrCode = QRCode("http://github.com/aschuch/QRCode")! + qrCode.size = self.imageViewLarge.bounds.size + qrCode.errorCorrection = .High + return qrCode.image + }() + + // medium + // purple + imageViewMedium.image = { + var qrCode = QRCode("http://schuch.me")! + qrCode.size = self.imageViewMedium.bounds.size + qrCode.color = CIColor(rgba: "8e44ad") + return qrCode.image + }() + + // small + // red (inverted) + imageViewSmall1.image = { + var qrCode = QRCode("http://objc.at")! + qrCode.size = self.imageViewSmall1.bounds.size + qrCode.color = CIColor(rgba: "fff") + qrCode.backgroundColor = CIColor(rgba: "e74c3c") + return qrCode.image + }() + + // small + // green + imageViewSmall2.image = { + var qrCode = QRCode("http://apple.com")! + qrCode.size = self.imageViewSmall1.bounds.size + qrCode.color = CIColor(rgba: "16a085") + qrCode.backgroundColor = CIColor(rgba: "000") + return qrCode.image + }() + + // small + // orange + imageViewSmall3.image = { + var qrCode = QRCode("http://example.com")! + qrCode.size = self.imageViewSmall1.bounds.size + qrCode.color = CIColor(rgba: "c0392b") + qrCode.backgroundColor = CIColor(rgba: "f1c40f") + return qrCode.image + }() + + // small + // blue + imageViewSmall4.image = { + var qrCode = QRCode("http://example.com")! + qrCode.size = self.imageViewSmall1.bounds.size + qrCode.color = CIColor(rgba: "2980b9") + return qrCode.image + }() + } + +} + diff --git a/QRCode.xcodeproj/project.pbxproj b/QRCode.xcodeproj/project.pbxproj index 33ccc1b..d664c66 100644 --- a/QRCode.xcodeproj/project.pbxproj +++ b/QRCode.xcodeproj/project.pbxproj @@ -15,11 +15,23 @@ 4D248F361A751C7800E44E6B /* QRCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D248F351A751C7800E44E6B /* QRCode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4D248F3C1A751C7800E44E6B /* QRCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D248F311A751C7800E44E6B /* QRCode.framework */; }; 4D248F451A751C7800E44E6B /* QRCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F441A751C7800E44E6B /* QRCodeTests.swift */; }; - 4D248F481A751C7800E44E6B /* QRCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D248F311A751C7800E44E6B /* QRCode.framework */; }; - 4D248F491A751C7800E44E6B /* QRCode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4D248F311A751C7800E44E6B /* QRCode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4D248F521A751CE300E44E6B /* QRCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F511A751CE300E44E6B /* QRCode.swift */; }; 4D9240641A78050C0069D66D /* UIImageViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9240631A78050C0069D66D /* UIImageViewExtension.swift */; }; 4D9240661A7805310069D66D /* CIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9240651A7805310069D66D /* CIColorExtension.swift */; }; + 60940CEA1F3B75AB00725D98 /* QRCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60940CE11F3B75AB00725D98 /* QRCode.framework */; }; + 60940CF81F3B75DA00725D98 /* QRCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F511A751CE300E44E6B /* QRCode.swift */; }; + 60940CFA1F3B75E100725D98 /* CIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9240651A7805310069D66D /* CIColorExtension.swift */; }; + 60940CFB1F3B75E400725D98 /* CIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA24AF3D1C247A7C00D1BEC7 /* CIImageExtension.swift */; }; + 60940CFC1F3B75E700725D98 /* QRCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D248F351A751C7800E44E6B /* QRCode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 60940CFD1F3B75F800725D98 /* QRCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F441A751C7800E44E6B /* QRCodeTests.swift */; }; + 60940D051F3B814300725D98 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60940D041F3B814300725D98 /* AppDelegate.swift */; }; + 60940D071F3B814300725D98 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60940D061F3B814300725D98 /* ViewController.swift */; }; + 60940D091F3B814300725D98 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 60940D081F3B814300725D98 /* Assets.xcassets */; }; + 60940D0C1F3B814300725D98 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 60940D0A1F3B814300725D98 /* Main.storyboard */; }; + 60940D111F3B836600725D98 /* QRCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60940CE11F3B75AB00725D98 /* QRCode.framework */; }; + 60940D121F3B836600725D98 /* QRCode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 60940CE11F3B75AB00725D98 /* QRCode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 60CA86781F3BC32900E844B2 /* QRCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D248F311A751C7800E44E6B /* QRCode.framework */; }; + 60CA86791F3BC32900E844B2 /* QRCode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4D248F311A751C7800E44E6B /* QRCode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; AA24AF3E1C247A7C00D1BEC7 /* CIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA24AF3D1C247A7C00D1BEC7 /* CIImageExtension.swift */; }; /* End PBXBuildFile section */ @@ -32,22 +44,54 @@ remoteInfo = QRCode; }; 4D248F461A751C7800E44E6B /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60940CE01F3B75AB00725D98; + remoteInfo = QRCode_macOS; + }; + 60940D131F3B836600725D98 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60940CE01F3B75AB00725D98; + remoteInfo = QRCode_macOS; + }; + 60CA86771F3BC0FF00E844B2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60940CE01F3B75AB00725D98; + remoteInfo = QRCode_macOS; + }; + 60CA867A1F3BC32900E844B2 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4D248EFF1A751C3700E44E6B /* Project object */; proxyType = 1; remoteGlobalIDString = 4D248F301A751C7800E44E6B; - remoteInfo = QRCode; + remoteInfo = QRCode_iOS; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 4D248F4D1A751C7800E44E6B /* Embed Frameworks */ = { + 60940D151F3B836600725D98 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( - 4D248F491A751C7800E44E6B /* QRCode.framework in Embed Frameworks */, + 60940D121F3B836600725D98 /* QRCode.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 60CA867C1F3BC32900E844B2 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 60CA86791F3BC32900E844B2 /* QRCode.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -65,12 +109,20 @@ 4D248F311A751C7800E44E6B /* QRCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = QRCode.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4D248F341A751C7800E44E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4D248F351A751C7800E44E6B /* QRCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QRCode.h; sourceTree = ""; }; - 4D248F3B1A751C7800E44E6B /* QRCodeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QRCodeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 4D248F3B1A751C7800E44E6B /* QRCodeTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = QRCodeTests_iOS.xctest; path = QRCodeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 4D248F431A751C7800E44E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4D248F441A751C7800E44E6B /* QRCodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeTests.swift; sourceTree = ""; }; 4D248F511A751CE300E44E6B /* QRCode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRCode.swift; sourceTree = ""; }; 4D9240631A78050C0069D66D /* UIImageViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageViewExtension.swift; sourceTree = ""; }; 4D9240651A7805310069D66D /* CIColorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CIColorExtension.swift; sourceTree = ""; }; + 60940CE11F3B75AB00725D98 /* QRCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = QRCode.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 60940CE91F3B75AB00725D98 /* QRCodeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QRCodeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 60940D021F3B814300725D98 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 60940D041F3B814300725D98 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 60940D061F3B814300725D98 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 60940D081F3B814300725D98 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 60940D0B1F3B814300725D98 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 60940D0D1F3B814300725D98 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AA24AF3D1C247A7C00D1BEC7 /* CIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CIImageExtension.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -79,7 +131,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4D248F481A751C7800E44E6B /* QRCode.framework in Frameworks */, + 60CA86781F3BC32900E844B2 /* QRCode.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -98,6 +150,29 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 60940CDD1F3B75AB00725D98 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940CE61F3B75AB00725D98 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940CEA1F3B75AB00725D98 /* QRCode.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940CFF1F3B814300725D98 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940D111F3B836600725D98 /* QRCode.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -105,6 +180,7 @@ isa = PBXGroup; children = ( 4D248F091A751C3700E44E6B /* Example_iOS */, + 60940D031F3B814300725D98 /* Example_macOS */, 4D248F321A751C7800E44E6B /* QRCode */, 4D248F411A751C7800E44E6B /* QRCodeTests */, 4D248F081A751C3700E44E6B /* Products */, @@ -116,7 +192,10 @@ children = ( 4D248F071A751C3700E44E6B /* Example.app */, 4D248F311A751C7800E44E6B /* QRCode.framework */, - 4D248F3B1A751C7800E44E6B /* QRCodeTests.xctest */, + 4D248F3B1A751C7800E44E6B /* QRCodeTests_iOS.xctest */, + 60940CE11F3B75AB00725D98 /* QRCode.framework */, + 60940CE91F3B75AB00725D98 /* QRCodeTests.xctest */, + 60940D021F3B814300725D98 /* Example.app */, ); name = Products; sourceTree = ""; @@ -180,6 +259,18 @@ name = "Supporting Files"; sourceTree = ""; }; + 60940D031F3B814300725D98 /* Example_macOS */ = { + isa = PBXGroup; + children = ( + 60940D041F3B814300725D98 /* AppDelegate.swift */, + 60940D061F3B814300725D98 /* ViewController.swift */, + 60940D081F3B814300725D98 /* Assets.xcassets */, + 60940D0A1F3B814300725D98 /* Main.storyboard */, + 60940D0D1F3B814300725D98 /* Info.plist */, + ); + path = Example_macOS; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -191,6 +282,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 60940CDE1F3B75AB00725D98 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940CFC1F3B75E700725D98 /* QRCode.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -201,12 +300,13 @@ 4D248F031A751C3700E44E6B /* Sources */, 4D248F041A751C3700E44E6B /* Frameworks */, 4D248F051A751C3700E44E6B /* Resources */, - 4D248F4D1A751C7800E44E6B /* Embed Frameworks */, + 60CA867C1F3BC32900E844B2 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( 4D248F471A751C7800E44E6B /* PBXTargetDependency */, + 60CA867B1F3BC32900E844B2 /* PBXTargetDependency */, ); name = Example_iOS; productName = Example; @@ -246,9 +346,64 @@ ); name = QRCodeTests_iOS; productName = QRCodeTests; - productReference = 4D248F3B1A751C7800E44E6B /* QRCodeTests.xctest */; + productReference = 4D248F3B1A751C7800E44E6B /* QRCodeTests_iOS.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 60940CE01F3B75AB00725D98 /* QRCode_macOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 60940CF21F3B75AB00725D98 /* Build configuration list for PBXNativeTarget "QRCode_macOS" */; + buildPhases = ( + 60940CDC1F3B75AB00725D98 /* Sources */, + 60940CDD1F3B75AB00725D98 /* Frameworks */, + 60940CDE1F3B75AB00725D98 /* Headers */, + 60940CDF1F3B75AB00725D98 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = QRCode_macOS; + productName = QRCode_macOS; + productReference = 60940CE11F3B75AB00725D98 /* QRCode.framework */; + productType = "com.apple.product-type.framework"; + }; + 60940CE81F3B75AB00725D98 /* QRCodeTests_macOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 60940CF51F3B75AB00725D98 /* Build configuration list for PBXNativeTarget "QRCodeTests_macOS" */; + buildPhases = ( + 60940CE51F3B75AB00725D98 /* Sources */, + 60940CE61F3B75AB00725D98 /* Frameworks */, + 60940CE71F3B75AB00725D98 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 60940CEC1F3B75AB00725D98 /* PBXTargetDependency */, + ); + name = QRCodeTests_macOS; + productName = QRCode_macOSTests; + productReference = 60940CE91F3B75AB00725D98 /* QRCodeTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 60940D011F3B814300725D98 /* Example_macOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 60940D0E1F3B814300725D98 /* Build configuration list for PBXNativeTarget "Example_macOS" */; + buildPhases = ( + 60940CFE1F3B814300725D98 /* Sources */, + 60940CFF1F3B814300725D98 /* Frameworks */, + 60940D001F3B814300725D98 /* Resources */, + 60940D151F3B836600725D98 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 60940D141F3B836600725D98 /* PBXTargetDependency */, + ); + name = Example_macOS; + productName = Example_macOS; + productReference = 60940D021F3B814300725D98 /* Example.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -256,7 +411,7 @@ isa = PBXProject; attributes = { LastSwiftMigration = 0700; - LastSwiftUpdateCheck = 0700; + LastSwiftUpdateCheck = 0830; LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Alexander Schuch"; TargetAttributes = { @@ -273,6 +428,18 @@ LastSwiftMigration = 0800; TestTargetID = 4D248F061A751C3700E44E6B; }; + 60940CE01F3B75AB00725D98 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + }; + 60940CE81F3B75AB00725D98 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + }; + 60940D011F3B814300725D98 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 4D248F021A751C3700E44E6B /* Build configuration list for PBXProject "QRCode" */; @@ -291,6 +458,9 @@ 4D248F061A751C3700E44E6B /* Example_iOS */, 4D248F301A751C7800E44E6B /* QRCode_iOS */, 4D248F3A1A751C7800E44E6B /* QRCodeTests_iOS */, + 60940D011F3B814300725D98 /* Example_macOS */, + 60940CE01F3B75AB00725D98 /* QRCode_macOS */, + 60940CE81F3B75AB00725D98 /* QRCodeTests_macOS */, ); }; /* End PBXProject section */ @@ -320,6 +490,29 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 60940CDF1F3B75AB00725D98 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940CE71F3B75AB00725D98 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940D001F3B814300725D98 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940D091F3B814300725D98 /* Assets.xcassets in Resources */, + 60940D0C1F3B814300725D98 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -351,6 +544,33 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 60940CDC1F3B75AB00725D98 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940CFB1F3B75E400725D98 /* CIImageExtension.swift in Sources */, + 60940CF81F3B75DA00725D98 /* QRCode.swift in Sources */, + 60940CFA1F3B75E100725D98 /* CIColorExtension.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940CE51F3B75AB00725D98 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940CFD1F3B75F800725D98 /* QRCodeTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60940CFE1F3B814300725D98 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 60940D071F3B814300725D98 /* ViewController.swift in Sources */, + 60940D051F3B814300725D98 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -361,9 +581,24 @@ }; 4D248F471A751C7800E44E6B /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 4D248F301A751C7800E44E6B /* QRCode_iOS */; + target = 60940CE01F3B75AB00725D98 /* QRCode_macOS */; targetProxy = 4D248F461A751C7800E44E6B /* PBXContainerItemProxy */; }; + 60940CEC1F3B75AB00725D98 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 60940CE01F3B75AB00725D98 /* QRCode_macOS */; + targetProxy = 60CA86771F3BC0FF00E844B2 /* PBXContainerItemProxy */; + }; + 60940D141F3B836600725D98 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 60940CE01F3B75AB00725D98 /* QRCode_macOS */; + targetProxy = 60940D131F3B836600725D98 /* PBXContainerItemProxy */; + }; + 60CA867B1F3BC32900E844B2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4D248F301A751C7800E44E6B /* QRCode_iOS */; + targetProxy = 60CA867A1F3BC32900E844B2 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -383,6 +618,14 @@ name = LaunchScreen.xib; sourceTree = ""; }; + 60940D0A1F3B814300725D98 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 60940D0B1F3B814300725D98 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -476,11 +719,12 @@ 4D248F271A751C3700E44E6B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Example_iOS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.Example.iOS; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; PRODUCT_NAME = Example; SWIFT_VERSION = 3.0.1; }; @@ -489,11 +733,12 @@ 4D248F281A751C3700E44E6B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Example_iOS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.Example.iOS; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).iOS"; PRODUCT_NAME = Example; SWIFT_VERSION = 3.0.1; }; @@ -572,6 +817,149 @@ }; name = Release; }; + 60940CF31F3B75AB00725D98 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = QRCode/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = QRCode; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 3.0; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 60940CF41F3B75AB00725D98 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = QRCode/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = QRCode; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 60940CF61F3B75AB00725D98 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + INFOPLIST_FILE = QRCodeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = QRCodeTests; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 60940CF71F3B75AB00725D98 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + INFOPLIST_FILE = QRCodeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = QRCodeTests; + SDKROOT = macosx; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 60940D0F1F3B814300725D98 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + INFOPLIST_FILE = Example_macOS/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = Example; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 60940D101F3B814300725D98 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + INFOPLIST_FILE = Example_macOS/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier).macOS"; + PRODUCT_NAME = Example; + SDKROOT = macosx; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -611,6 +999,33 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 60940CF21F3B75AB00725D98 /* Build configuration list for PBXNativeTarget "QRCode_macOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60940CF31F3B75AB00725D98 /* Debug */, + 60940CF41F3B75AB00725D98 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 60940CF51F3B75AB00725D98 /* Build configuration list for PBXNativeTarget "QRCodeTests_macOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60940CF61F3B75AB00725D98 /* Debug */, + 60940CF71F3B75AB00725D98 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 60940D0E1F3B814300725D98 /* Build configuration list for PBXNativeTarget "Example_macOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60940D0F1F3B814300725D98 /* Debug */, + 60940D101F3B814300725D98 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 4D248EFF1A751C3700E44E6B /* Project object */; diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/Example_macOS.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/Example_macOS.xcscheme new file mode 100644 index 0000000..0fa2255 --- /dev/null +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/Example_macOS.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_macOS.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_macOS.xcscheme new file mode 100644 index 0000000..1875c16 --- /dev/null +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCodeTests_macOS.xcscheme @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme index e94e15c..0ca615f 100644 --- a/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme +++ b/QRCode.xcodeproj/xcshareddata/xcschemes/QRCode_iOS.xcscheme @@ -1,6 +1,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QRCode/CIImageExtension.swift b/QRCode/CIImageExtension.swift index fdb2433..a091038 100644 --- a/QRCode/CIImageExtension.swift +++ b/QRCode/CIImageExtension.swift @@ -6,29 +6,51 @@ // Copyright © 2015 Alexander Schuch. All rights reserved. // -import Foundation +#if os(iOS) + import UIKit + + public typealias Image = UIImage +#endif // iOS + +#if os(OSX) + import Cocoa + + public typealias Image = NSImage +#endif // macOS internal typealias Scale = (dx: CGFloat, dy: CGFloat) internal extension CIImage { - /// Creates an `UIImage` with interpolation disabled and scaled given a scale property + /// Creates an `UIImage` (iOS) / `NSImage` (macOS) with interpolation disabled and scaled given a scale property /// /// - 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? { + /// - returns: an non-interpolated `UIImage`/`NSImage` + internal func nonInterpolatedImage(withScale scale: Scale = Scale(dx: 1, dy: 1)) -> Image? { guard let cgImage = CIContext(options: nil).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) - guard let context = UIGraphicsGetCurrentContext() else { return nil } - context.interpolationQuality = .none - context.translateBy(x: 0, y: size.height) - context.scaleBy(x: 1.0, y: -1.0) - context.draw(cgImage, in: context.boundingBoxOfClipPath) - let result = UIGraphicsGetImageFromCurrentImageContext() - UIGraphicsEndImageContext() + #if os(iOS) + UIGraphicsBeginImageContextWithOptions(size, true, 0) + guard let context = UIGraphicsGetCurrentContext() else { return nil } + context.interpolationQuality = .none + context.translateBy(x: 0, y: size.height) + context.scaleBy(x: 1.0, y: -1.0) + context.draw(cgImage, in: context.boundingBoxOfClipPath) + let result = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + #endif // iOS + + #if os(OSX) + let source = NSImage(cgImage: cgImage, size: self.extent.size) + let result = NSImage(size: size) + result.lockFocus() + guard let context = NSGraphicsContext.current() else { return nil } + context.imageInterpolation = .none + source.draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: size), from: extent, operation: .copy, fraction: 1.0) + result.unlockFocus() + #endif // macOS return result } diff --git a/QRCode/QRCode.h b/QRCode/QRCode.h index 054e49b..216bd4e 100644 --- a/QRCode/QRCode.h +++ b/QRCode/QRCode.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Alexander Schuch. All rights reserved. // -#import +#import //! Project version number for QRCode. FOUNDATION_EXPORT double QRCodeVersionNumber; diff --git a/QRCode/QRCode.swift b/QRCode/QRCode.swift index 67e4ea4..be67eae 100644 --- a/QRCode/QRCode.swift +++ b/QRCode/QRCode.swift @@ -6,7 +6,13 @@ // Copyright (c) 2015 Alexander Schuch. All rights reserved. // -import UIKit +#if os(iOS) + import UIKit +#endif // iOS + +#if os(OSX) + import Cocoa +#endif // macOS public typealias 🔳 = QRCode @@ -70,7 +76,7 @@ public struct QRCode { // MARK: Generate QRCode /// The QRCode's UIImage representation - public var image: UIImage? { + public var image: Image? { guard let ciImage = ciImage else { return nil } // Size diff --git a/QRCodeTests/QRCodeTests.swift b/QRCodeTests/QRCodeTests.swift index 7a5a7ca..5882466 100644 --- a/QRCodeTests/QRCodeTests.swift +++ b/QRCodeTests/QRCodeTests.swift @@ -6,7 +6,14 @@ // Copyright (c) 2015 Alexander Schuch. All rights reserved. // -import UIKit +#if os(iOS) + import UIKit +#endif // iOS + +#if os(OSX) + import Cocoa +#endif // macOS + import XCTest @testable import QRCode diff --git a/README.md b/README.md index 96dd4f3..2ed3ebd 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Change the output size of the QRCode output image via the `size` property. ```swift qrCode.size = CGSize(width: 300, height: 300) -qrCode.image // UIImage (300x300) +qrCode.image // UIImage/NSImage (300x300) ``` **Color** @@ -49,12 +49,12 @@ Modify the colors of the QRCode output image via `color` and `backgroundColor` p ```swift qrCode.color = CIColor(rgba: "16a085") qrCode.backgroundColor = CIColor(rgba: "000") -qrCode.image // UIImage (green QRCode color and black background) +qrCode.image // UIImage/NSImage (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. -### UIImageView extension +### UIImageView extension (iOS only) For convenience, a `UIImageView` extension is provided to directly initialize an image view with an instance of `QRCode`.