Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update to Swift 5 #59

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private extension UIView.ContentMode {
return "bottomLeft"
case .bottomRight:
return "bottomRight"
@unknown default:
fatalError("Unknown contentMode")
}
}
}
2 changes: 2 additions & 0 deletions ImageViewer/AnimatableImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private extension AnimatableImageView {
case .bottomRight:
imageView.bounds = Utilities.rect(forSize: image.size)
imageView.center = Utilities.bottomRight(forSize: image.size, insideSize: bounds.size)
@unknown default:
fatalError("Unkown content mode")
}
}
}
8 changes: 7 additions & 1 deletion ImageViewer/ImageViewerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public final class ImageViewerController: UIViewController {
@IBOutlet fileprivate var scrollView: UIScrollView!
@IBOutlet fileprivate var imageView: UIImageView!
@IBOutlet fileprivate var activityIndicator: UIActivityIndicatorView!
@IBOutlet fileprivate var closeButton: UIButton! {
didSet {
let closeImage = UIImage(named: "closeButton", in: Bundle.module, compatibleWith: nil)
closeButton.setImage(closeImage, for: .normal)
}
}

fileprivate var transitionHandler: ImageViewerTransitioningHandler?
fileprivate let configuration: ImageViewerConfiguration?
Expand All @@ -15,7 +21,7 @@ public final class ImageViewerController: UIViewController {

public init(configuration: ImageViewerConfiguration?) {
self.configuration = configuration
super.init(nibName: String(describing: type(of: self)), bundle: Bundle(for: type(of: self)))
super.init(nibName: "ImageViewerController", bundle: .module)

modalPresentationStyle = .overFullScreen
modalTransitionStyle = .crossDissolve
Expand Down
4 changes: 3 additions & 1 deletion ImageViewer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>SimpleImageViewer</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -17,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>1</string>
<key>NSPrincipalClass</key>
<string></string>
<key>UILaunchStoryboardName</key>
Expand Down
17 changes: 6 additions & 11 deletions ImageViewer/Resources/ImageViewerController.xib
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ImageViewerController" customModule="SimpleImageViewer" customModuleProvider="target">
<connections>
<outlet property="activityIndicator" destination="oPl-2f-Knx" id="GOD-eG-o96"/>
<outlet property="closeButton" destination="Wsy-fe-raz" id="a3H-nt-lws"/>
<outlet property="imageView" destination="rHA-5m-kkS" id="V86-k1-pPH"/>
<outlet property="scrollView" destination="cQD-2Q-pvo" id="M6k-QU-OVY"/>
<outlet property="view" destination="iN0-l3-epB" id="bEt-1B-b5l"/>
Expand Down Expand Up @@ -45,12 +43,12 @@
<rect key="frame" x="169" y="315" width="37" height="37"/>
</activityIndicatorView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wsy-fe-raz">
<rect key="frame" x="0.0" y="20" width="44" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="44" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="bXU-O2-lam"/>
<constraint firstAttribute="width" constant="44" id="xTg-TJ-eL3"/>
</constraints>
<state key="normal" image="closeButton">
<state key="normal">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
Expand All @@ -74,7 +72,4 @@
<point key="canvasLocation" x="33.5" y="54.5"/>
</view>
</objects>
<resources>
<image name="closeButton" width="13" height="13"/>
</resources>
</document>
16 changes: 15 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "SimpleImageViewer",
dependencies : []
products: [
.library(name: "SimpleImageViewer",
targets: ["SimpleImageViewer"]),
],
dependencies : [
],
targets: [
.target(name: "SimpleImageViewer",
dependencies: [],
path: "ImageViewer",
resources: [
.process("Resources")
])
]
)
63 changes: 39 additions & 24 deletions SimpleImageViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,30 +281,31 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = aFrogleap;
TargetAttributes = {
A02EE5D31EF1897D000EAB41 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = WQEYNHG5C2;
DevelopmentTeam = GP4DF7F833;
ProvisioningStyle = Automatic;
};
A07E76D21ECC94A400B77D46 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 44MAY72KU6;
DevelopmentTeam = GP4DF7F833;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
ProvisioningStyle = Automatic;
};
A0BF70A61EDC5B1400109F6E = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = GP4DF7F833;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = A07E76CE1ECC94A400B77D46 /* Build configuration list for PBXProject "SimpleImageViewer" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -412,24 +413,24 @@
A02EE5DD1EF1897D000EAB41 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = WQEYNHG5C2;
DEVELOPMENT_TEAM = GP4DF7F833;
INFOPLIST_FILE = SimpleImageViewerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.afrogleap.SimpleImageViewerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
A02EE5DE1EF1897D000EAB41 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = WQEYNHG5C2;
DEVELOPMENT_TEAM = GP4DF7F833;
INFOPLIST_FILE = SimpleImageViewerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.afrogleap.SimpleImageViewerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -447,13 +448,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -464,6 +467,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = GP4DF7F833;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -486,6 +490,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -504,13 +509,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -521,6 +528,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = GP4DF7F833;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -535,6 +543,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -545,17 +554,19 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 44MAY72KU6;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = GP4DF7F833;
INFOPLIST_FILE = "$(SRCROOT)/ImageViewer/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.afrogleapbv.inhouse.swift.imageviewer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "d5b8f7cb-0120-427a-9ff1-14d28ee0046f";
PROVISIONING_PROFILE_SPECIFIER = "aFrogleap Wildcard Development";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -564,25 +575,28 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = GP4DF7F833;
INFOPLIST_FILE = "$(SRCROOT)/ImageViewer/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.afrogleapbv.inhouse.swift.imageviewer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
A0BF70B11EDC5B1400109F6E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = GP4DF7F833;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -594,7 +608,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -603,10 +617,11 @@
A0BF70B21EDC5B1400109F6E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = GP4DF7F833;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -618,7 +633,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down