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

Swift 3 migration #33

Merged
merged 15 commits into from
Oct 20, 2016
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ included: # paths to include during linting. `--path` is ignored if present.
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
disabled_rules:
- type_name

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "hyperoslo/Cache" "master"
github "hyperoslo/Cache" "swift-3"
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "krzyzanowskim/CryptoSwift" "0.5.2"
github "hyperoslo/Cache" "4d7029d95a0b0a77ead2f0144b99bf6543452e3d"
github "krzyzanowskim/CryptoSwift" "0.6.0"
github "hyperoslo/Cache" "0246e9e9e8faae93f2c83d15824789577f4720bf"
34 changes: 23 additions & 11 deletions Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 295D77471C07122700C43B07 /* Build configuration list for PBXNativeTarget "ImaginaryDemo" */;
buildPhases = (
B7D6496BFC7771A48F877CB3 /* 📦 Check Pods Manifest.lock */,
B7D6496BFC7771A48F877CB3 /* [CP] Check Pods Manifest.lock */,
295D77311C07122700C43B07 /* Sources */,
295D77321C07122700C43B07 /* Frameworks */,
295D77331C07122700C43B07 /* Resources */,
C0A8DDB8B9507E1DC5EAAF4F /* 📦 Embed Pods Frameworks */,
F2303666E66C11250DCBF23E /* 📦 Copy Pods Resources */,
C0A8DDB8B9507E1DC5EAAF4F /* [CP] Embed Pods Frameworks */,
F2303666E66C11250DCBF23E /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -119,11 +119,12 @@
295D772D1C07122700C43B07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Ramon Gilabert Llop";
TargetAttributes = {
295D77341C07122700C43B07 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -158,44 +159,44 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
B7D6496BFC7771A48F877CB3 /* 📦 Check Pods Manifest.lock */ = {
B7D6496BFC7771A48F877CB3 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
C0A8DDB8B9507E1DC5EAAF4F /* 📦 Embed Pods Frameworks */ = {
C0A8DDB8B9507E1DC5EAAF4F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ImaginaryDemo/Pods-ImaginaryDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
F2303666E66C11250DCBF23E /* 📦 Copy Pods Resources */ = {
F2303666E66C11250DCBF23E /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -243,8 +244,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 @@ -271,6 +274,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -288,8 +292,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 @@ -308,6 +314,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -317,25 +325,29 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 756C922FC82FDBF74BBB883A /* Pods-ImaginaryDemo.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = ImaginaryDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = RamonGilabert.ImaginaryDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
295D77491C07122700C43B07 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 2ECB55839D2BC9B48EBF6500 /* Pods-ImaginaryDemo.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = ImaginaryDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = RamonGilabert.ImaginaryDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let navigationController = UINavigationController(rootViewController: viewController)
viewController.title = "Imaginary".uppercaseString
viewController.title = "Imaginary".uppercased()

window = UIWindow()
window?.rootViewController = navigationController
Expand Down
28 changes: 14 additions & 14 deletions Example/ImaginaryDemo/ImaginaryDemo/FeedTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class FeedTableViewCell: UITableViewCell {

lazy var generalImageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .ScaleAspectFill
imageView.backgroundColor = UIColor.whiteColor()
imageView.contentMode = .scaleAspectFill
imageView.backgroundColor = UIColor.white
imageView.clipsToBounds = true

return imageView
}()

lazy var separator: UIView = {
let view = UIView()
view.backgroundColor = UIColor.whiteColor()
view.backgroundColor = UIColor.white

return view
}()
Expand All @@ -27,13 +27,13 @@ class FeedTableViewCell: UITableViewCell {

[generalImageView, separator].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.opaque = true
$0.isOpaque = true
$0.layer.drawsAsynchronously = true

addSubview($0)
}

selectionStyle = .None
selectionStyle = .none

setupConstraints()
}
Expand All @@ -45,14 +45,14 @@ class FeedTableViewCell: UITableViewCell {
// MARK: - Setup

func setupConstraints() {
generalImageView.topAnchor.constraintEqualToAnchor(topAnchor).active = true
generalImageView.bottomAnchor.constraintEqualToAnchor(bottomAnchor).active = true
generalImageView.leftAnchor.constraintEqualToAnchor(leftAnchor).active = true
generalImageView.rightAnchor.constraintEqualToAnchor(rightAnchor).active = true

separator.widthAnchor.constraintEqualToAnchor(widthAnchor).active = true
separator.heightAnchor.constraintEqualToConstant(5).active = true
separator.leftAnchor.constraintEqualToAnchor(leftAnchor).active = true
separator.bottomAnchor.constraintEqualToAnchor(bottomAnchor).active = true
generalImageView.topAnchor.constraint(equalTo: topAnchor).isActive = true
generalImageView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
generalImageView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
generalImageView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true

separator.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
separator.heightAnchor.constraint(equalToConstant: 5).isActive = true
separator.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
separator.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
}
}
28 changes: 15 additions & 13 deletions Example/ImaginaryDemo/ImaginaryDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class ViewController: UITableViewController {
static let imageNumber = 400
}

lazy var imaginaryArray: [NSURL] = { [unowned self] in
var array = [NSURL]()
lazy var imaginaryArray: [URL] = { [unowned self] in
var array = [URL]()

for i in 0..<Constants.imageNumber {
if let imageURL = NSURL(
string: "https://unsplash.it/600/300/?image=\(i)") {
if let imageURL = URL(
string: "https://placeimg.com/640/480/\(i)") {
array.append(imageURL)
}
}
Expand All @@ -27,25 +27,25 @@ class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = UIColor.whiteColor()
view.backgroundColor = UIColor.white

setupTableView()
}

// MARK: - Setup tableView

func setupTableView() {
tableView.registerClass(FeedTableViewCell.self,
tableView.register(FeedTableViewCell.self,
forCellReuseIdentifier: FeedTableViewCell.reusableIdentifier)
tableView.separatorStyle = .None
tableView.separatorStyle = .none
}
}

// MARK: - TableView Delegate

extension ViewController {

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 250
}
}
Expand All @@ -54,15 +54,17 @@ extension ViewController {

extension ViewController {

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return imaginaryArray.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCellWithIdentifier(
FeedTableViewCell.reusableIdentifier) as? FeedTableViewCell else { return UITableViewCell() }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(
withIdentifier: FeedTableViewCell.reusableIdentifier) as? FeedTableViewCell else { return UITableViewCell() }

cell.generalImageView.setImage(imaginaryArray[indexPath.row], placeholder: UIImage(named: "placeholder"))
cell.generalImageView.setImage(
url: imaginaryArray[indexPath.row],
placeholder: UIImage(named: "placeholder"))

return cell
}
Expand Down
4 changes: 2 additions & 2 deletions Example/ImaginaryDemo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ platform :ios, '8.0'
use_frameworks!
inhibit_all_warnings!


pod 'Imaginary', path: '../../'
pod 'Cache', git: 'https://github.com/hyperoslo/Cache'
pod 'Cache'
pod 'CryptoSwift'

target 'ImaginaryDemo'
22 changes: 8 additions & 14 deletions Example/ImaginaryDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
PODS:
- Cache (1.4.0):
- Cache (2.0.0):
- CryptoSwift
- CryptoSwift (0.5.1)
- CryptoSwift (0.6.1)
- Imaginary (0.1.0):
- Cache

DEPENDENCIES:
- Cache (from `https://github.com/hyperoslo/Cache`)
- Cache
- CryptoSwift
- Imaginary (from `../../`)

EXTERNAL SOURCES:
Cache:
:git: https://github.com/hyperoslo/Cache
Imaginary:
:path: "../../"

CHECKOUT OPTIONS:
Cache:
:commit: d6f0b013cbe9ede4b5fe5a8b615220abce0327d6
:git: https://github.com/hyperoslo/Cache

SPEC CHECKSUMS:
Cache: 059cf0e10e6c3aec2c402eea19bd6b3aacb3fe9d
CryptoSwift: df42dda18baf6c76347a94e227dbcc0a341304bd
Cache: 86c7a082ce5a734df15a103581d81d29002a171e
CryptoSwift: abdbc1bf32c89117c6b403810a7b30f742d86e68
Imaginary: 62a9ce1e6d7831ede429c8221a183f03ec2a90bc

PODFILE CHECKSUM: eeff3e5a8f20502e24b1eaa68f2a4c9eeece699d
PODFILE CHECKSUM: 6c3e9cf6a12cbdd6952efb6b00ddfb2139144199

COCOAPODS: 1.0.0
COCOAPODS: 1.1.0.rc.3
Loading