Skip to content

Commit

Permalink
Support for Swift 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Sep 30, 2016
1 parent c100887 commit b63ae2e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion APNGKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Pod::Spec.new do |s|
s.source_files = "APNGKit/*.{h,swift}", "APNGKit/libpng-apng/*.{h,c,S}"
s.public_header_files = ["APNGKit/APNGKit.h", "APNGKit/libpng-apng/png.h", "APNGKit/libpng-apng/pnglibconf.h", "APNGKit/libpng-apng/pngconf.h"]
s.library = "z"

s.pod_target_xcconfig = { 'SWIFT_VERSION' => '2.3' }
end
19 changes: 16 additions & 3 deletions APNGKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "OneV's Den";
TargetAttributes = {
4B0D67381B8E9DBF00876BDF = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
4B0D67421B8E9DC000876BDF = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
D199B1F71B91445100BF8358 = {
CreatedOnToolsVersion = 7.0;
Expand Down Expand Up @@ -812,8 +814,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 Down Expand Up @@ -860,8 +864,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 @@ -881,6 +887,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -892,6 +899,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 135;
Expand All @@ -904,13 +912,15 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
4B0D674F1B8E9DC000876BDF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 135;
Expand All @@ -922,6 +932,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.onevcat.APNGKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand All @@ -932,6 +943,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.onevcat.APNGKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -942,14 +954,15 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.onevcat.APNGKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Release;
};
D199B21D1B91445100BF8358 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = APNGKitDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -961,8 +974,8 @@
D199B21E1B91445100BF8358 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = APNGKitDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
2 changes: 1 addition & 1 deletion APNGKit.xcodeproj/xcshareddata/xcschemes/APNGKit.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
5 changes: 4 additions & 1 deletion APNGKit/Frame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ struct Frame {

mutating func updateCGImageRef(width: Int, height: Int, bits: Int, scale: CGFloat, blend: Bool) {

let provider = CGDataProviderCreateWithData(nil, bytes, length, nil)
let unusedCallback: CGDataProviderReleaseDataCallback = { optionalPointer, pointer, valueInt in }
guard let provider = CGDataProviderCreateWithData(nil, bytes, length, unusedCallback) else {
return
}

if let imageRef = CGImageCreate(width, height, bits, bits * 4, bytesInRow, CGColorSpaceCreateDeviceRGB(),
[CGBitmapInfo.ByteOrder32Big, CGBitmapInfo(rawValue: blend ? CGImageAlphaInfo.Last.rawValue : CGImageAlphaInfo.PremultipliedLast.rawValue)],
Expand Down
14 changes: 7 additions & 7 deletions APNGKitTests/APNGImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ extension UIImage {
func isEmpty() -> Bool {
let cgImage = self.CGImage

let w = CGImageGetWidth(cgImage)
let h = CGImageGetHeight(cgImage)
let w = CGImageGetWidth(cgImage!)
let h = CGImageGetHeight(cgImage!)

let data = UnsafeMutablePointer<UInt8>.alloc(w * h * 4)
let aaa = CGImageGetBitsPerComponent(cgImage)
let color = CGImageGetColorSpace(cgImage)
let aaa = CGImageGetBitsPerComponent(cgImage!)
let color = CGImageGetColorSpace(cgImage!)

let context = CGBitmapContextCreate(data, w, h, aaa, w * 4, color, CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue).rawValue)
CGContextSetBlendMode(context, CGBlendMode.Copy);
CGContextDrawImage(context, CGRectMake(0, 0, CGFloat(w), CGFloat(h)), cgImage);
let context = CGBitmapContextCreate(data, w, h, aaa, w * 4, color!, CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue).rawValue)
CGContextSetBlendMode(context!, CGBlendMode.Copy);
CGContextDrawImage(context!, CGRectMake(0, 0, CGFloat(w), CGFloat(h)), cgImage!);

for i in 0 ..< w * h {
if data.advancedBy(i).memory != 0 {
Expand Down

0 comments on commit b63ae2e

Please sign in to comment.