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

support for Swift3 with Xcode8GM #42

Merged
merged 6 commits into from
Sep 19, 2016
Merged
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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
osx_image: xcode7.3
osx_image: xcode8
language: objective-c
script:
- set -o pipefail && xcodebuild build -project NibDesignableDemo/NibDesignableDemo.xcodeproj -scheme NibDesignableDemo -sdk iphonesimulator | xcpretty -f `xcpretty-travis-formatter`
- set -o pipefail && xcodebuild test -project NibDesignableDemo/NibDesignableDemo.xcodeproj -scheme NibDesignableDemo -sdk iphonesimulator | xcpretty -f `xcpretty-travis-formatter`
- set -o pipefail && xcodebuild build -workspace NibDesignableDemo/NibDesignableDemo.xcworkspace -scheme NibDesignableDemo -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.0'| xcpretty -f `xcpretty-travis-formatter`
- set -o pipefail && xcodebuild test -workspace NibDesignableDemo/NibDesignableDemo.xcworkspace -scheme NibDesignableDemo -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.0'| xcpretty -f `xcpretty-travis-formatter`
- swiftlint lint --strict
before_install:
- brew update
- brew install swiftlint
- brew outdated swiftlint || brew upgrade swiftlint
- gem install xcpretty xcpretty-travis-formatter
26 changes: 13 additions & 13 deletions NibDesignable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ extension NibDesignableProtocol {
- returns: UIView instance loaded from a nib file.
*/
public func loadNib() -> UIView {
let bundle = NSBundle(forClass: self.dynamicType)
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: self.nibName(), bundle: bundle)
return nib.instantiateWithOwner(self, options: nil)[0] as! UIView // swiftlint:disable:this force_cast
return nib.instantiate(withOwner: self, options: nil)[0] as! UIView // swiftlint:disable:this force_cast
}

// MARK: - Nib loading

/**
Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview.
*/
private func setupNib() {
fileprivate func setupNib() {
let view = self.loadNib()
self.nibContainerView.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
let bindings = ["view": view]
self.nibContainerView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:[], metrics:nil, views: bindings))
self.nibContainerView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:[], metrics:nil, views: bindings))
self.nibContainerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options:[], metrics:nil, views: bindings))
self.nibContainerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options:[], metrics:nil, views: bindings))
}
}

Expand All @@ -85,13 +85,13 @@ extension UIView {

- returns: Name of a single view nib file.
*/
public func nibName() -> String {
return self.dynamicType.description().componentsSeparatedByString(".").last!
open func nibName() -> String {
return type(of: self).description().components(separatedBy: ".").last!
}
}

@IBDesignable
public class NibDesignable: UIView, NibDesignableProtocol {
open class NibDesignable: UIView, NibDesignableProtocol {

// MARK: - Initializer
override public init(frame: CGRect) {
Expand All @@ -107,7 +107,7 @@ public class NibDesignable: UIView, NibDesignableProtocol {
}

@IBDesignable
public class NibDesignableTableViewCell: UITableViewCell, NibDesignableProtocol {
open class NibDesignableTableViewCell: UITableViewCell, NibDesignableProtocol {
public override var nibContainerView: UIView {
return self.contentView
}
Expand All @@ -126,7 +126,7 @@ public class NibDesignableTableViewCell: UITableViewCell, NibDesignableProtocol
}

@IBDesignable
public class NibDesignableTableViewHeaderFooterView: UITableViewHeaderFooterView, NibDesignableProtocol {
open class NibDesignableTableViewHeaderFooterView: UITableViewHeaderFooterView, NibDesignableProtocol {

public override var nibContainerView: UIView {
return self.contentView
Expand All @@ -146,7 +146,7 @@ public class NibDesignableTableViewHeaderFooterView: UITableViewHeaderFooterView
}

@IBDesignable
public class NibDesignableControl: UIControl, NibDesignableProtocol {
open class NibDesignableControl: UIControl, NibDesignableProtocol {

// MARK: - Initializer
override public init(frame: CGRect) {
Expand All @@ -162,7 +162,7 @@ public class NibDesignableControl: UIControl, NibDesignableProtocol {
}

@IBDesignable
public class NibDesignableCollectionReusableView: UICollectionReusableView, NibDesignableProtocol {
open class NibDesignableCollectionReusableView: UICollectionReusableView, NibDesignableProtocol {

// MARK: - Initializer
override public init(frame: CGRect) {
Expand All @@ -178,7 +178,7 @@ public class NibDesignableCollectionReusableView: UICollectionReusableView, NibD
}

@IBDesignable
public class NibDesignableCollectionViewCell: UICollectionViewCell, NibDesignableProtocol {
open class NibDesignableCollectionViewCell: UICollectionViewCell, NibDesignableProtocol {
public override var nibContainerView: UIView {
return self.contentView
}
Expand Down
13 changes: 10 additions & 3 deletions NibDesignable/NibDesignable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0800;
TargetAttributes = {
AF6F74E81B0EFB690053DCBA = {
CreatedOnToolsVersion = 6.3.2;
Expand Down Expand Up @@ -162,8 +162,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 @@ -212,8 +214,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 @@ -233,6 +237,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand All @@ -244,34 +249,36 @@
AF6F75001B0EFB690053DCBA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = NibDesignable/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.justabeech.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
AF6F75011B0EFB690053DCBA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = NibDesignable/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.justabeech.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading