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

SPM and swift 5 support #75

Open
wants to merge 3 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 33 additions & 8 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
4DE62AD319B658610021630A = {
isa = PBXGroup;
children = (
C70A7279255BEE580046EDE9 /* Sources */,
C70A727A255BEE6E0046EDE9 /* Tests */,
4DE62ADE19B658610021630A /* Example */,
4D6451471A64079200108EA3 /* StatefulViewController */,
4D6451561A64079300108EA3 /* StatefulViewControllerTests */,
4DE62ADD19B658610021630A /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -227,6 +227,22 @@
path = PlaceholderViews;
sourceTree = "<group>";
};
C70A7279255BEE580046EDE9 /* Sources */ = {
isa = PBXGroup;
children = (
4D6451471A64079200108EA3 /* StatefulViewController */,
);
path = Sources;
sourceTree = "<group>";
};
C70A727A255BEE6E0046EDE9 /* Tests */ = {
isa = PBXGroup;
children = (
4D6451561A64079300108EA3 /* StatefulViewControllerTests */,
);
path = Tests;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -357,6 +373,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -507,14 +524,15 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = StatefulViewController/Info.plist;
INFOPLIST_FILE = Sources/StatefulViewController/Info.plist;
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.StatefulViewController;
PRODUCT_NAME = StatefulViewController;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -532,13 +550,14 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = StatefulViewController/Info.plist;
INFOPLIST_FILE = Sources/StatefulViewController/Info.plist;
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.StatefulViewController;
PRODUCT_NAME = StatefulViewController;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -553,11 +572,12 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = StatefulViewControllerTests/Info.plist;
INFOPLIST_FILE = Tests/StatefulViewControllerTests/Info.plist;
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)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
Expand All @@ -567,11 +587,12 @@
buildSettings = {
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = StatefulViewControllerTests/Info.plist;
INFOPLIST_FILE = Tests/StatefulViewControllerTests/Info.plist;
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)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
Expand Down Expand Up @@ -671,6 +692,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -682,6 +704,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aschuch.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -696,13 +719,14 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "$(SRCROOT)/StatefulViewController/Info.plist";
INFOPLIST_FILE = "$(SRCROOT)/Sources//StatefulViewController/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.StatefulViewController;
PRODUCT_NAME = StatefulViewController;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -722,13 +746,14 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "$(SRCROOT)/StatefulViewController/Info.plist";
INFOPLIST_FILE = "$(SRCROOT)/Sources//StatefulViewController/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.aschuch.StatefulViewController;
PRODUCT_NAME = StatefulViewController;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
2 changes: 1 addition & 1 deletion Example/CollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CollectionViewController: UICollectionViewController, StatefulViewControll
refresh()
}

func refresh() {
@objc func refresh() {
if (lastState == .loading) { return }

startLoading {
Expand Down
2 changes: 1 addition & 1 deletion Example/PlaceholderViews/BasicPlaceholderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BasicPlaceholderView: UIView {
let vConstraints = NSLayoutConstraint.constraints(withVisualFormat: "|-(>=20)-[centerView]-(>=20)-|", options: .alignAllCenterX, metrics: nil, views: ["centerView": centerView])
let hConstraint = NSLayoutConstraint(item: centerView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0.0)
let centerConstraint = NSLayoutConstraint(item: centerView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0.0)
centerConstraint.priority = 750
centerConstraint.priority = UILayoutPriority(rawValue: 750)

addConstraints(vConstraints)
addConstraint(hConstraint)
Expand Down
2 changes: 1 addition & 1 deletion Example/PlaceholderViews/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ErrorView: BasicPlaceholderView {
detailTextLabel.text = "Tap to reload"
detailTextLabel.numberOfLines = 0
detailTextLabel.textAlignment = .center
let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFontTextStyle.footnote)
let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .footnote)
detailTextLabel.font = UIFont(descriptor: fontDescriptor, size: 0)
detailTextLabel.textAlignment = .center
detailTextLabel.textColor = UIColor.gray
Expand Down
2 changes: 1 addition & 1 deletion Example/PlaceholderViews/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LoadingView: BasicPlaceholderView, StatefulPlaceholderView {
label.translatesAutoresizingMaskIntoConstraints = false
centerView.addSubview(label)

let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
let activityIndicator = UIActivityIndicatorView(style: .gray)
activityIndicator.startAnimating()
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
centerView.addSubview(activityIndicator)
Expand Down
2 changes: 1 addition & 1 deletion Example/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TableViewController: UITableViewController, StatefulViewController {
refresh()
}

func refresh() {
@objc func refresh() {
if (lastState == .loading) { return }

startLoading {
Expand Down
2 changes: 1 addition & 1 deletion Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ViewController: UIViewController, StatefulViewController {
refresh()
}

func refresh() {
@objc func refresh() {
if (lastState == .loading) { return }

startLoading {
Expand Down
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "StatefulViewController",
platforms: [.iOS(.v9), .tvOS(.v9)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "StatefulViewController",
targets: ["StatefulViewController"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "StatefulViewController",
dependencies: [],
exclude: ["Info.plist"]),
.testTarget(
name: "StatefulViewControllerTests",
dependencies: ["StatefulViewController"],
exclude: ["Info.plist"]),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2016 Alexander Schuch. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public protocol StatefulPlaceholderView {
Expand All @@ -22,3 +23,4 @@ extension StatefulPlaceholderView {
}

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// Copyright (c) 2015 Alexander Schuch. All rights reserved.
//

#import <UIKit/UIKit.h>
#if canImport(UIKit)
#import <UIKit/UIKit.h>
#endif

//! Project version number for StatefulViewController.
FOUNDATION_EXPORT double StatefulViewControllerVersionNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import UIKit

/// Represents all possible states of a stateful view controller
Expand Down Expand Up @@ -87,3 +88,4 @@ public protocol StatefulViewController: class, BackingViewProvider {
/// - parameter error: The error that occurred
func handleErrorWhenContentAvailable(_ error: Error)
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if canImport(UIKit)
import UIKit


// MARK: Default Implementation BackingViewProvider

extension BackingViewProvider where Self: UIViewController {
Expand Down Expand Up @@ -133,3 +133,4 @@ private func associatedObject<T: AnyObject>(_ host: AnyObject, key: UnsafeRawPoi
}
return value!
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright (c) 2014 Alexander Schuch. All rights reserved.
//

#if canImport(UIKit)
import UIKit


/// Represents the state of the view state machine
public enum ViewStateMachineState : Equatable {
case none // No view shown
Expand Down Expand Up @@ -244,3 +244,4 @@ private class PassthroughView: UIView {
return false
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2015 Alexander Schuch. All rights reserved.
//

#if canImport(UIKit)
import UIKit
import XCTest
import StatefulViewController
Expand Down Expand Up @@ -66,3 +67,4 @@ class StatefulViewControllerTests: XCTestCase {
}

}
#endif