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 support #13

Open
wants to merge 17 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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Carthage
Relayout.framework.zip
build

.build
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEVELOPMENT-SNAPSHOT-2016-09-10-a
31 changes: 16 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
language: objective-c
osx_image: xcode7.3
osx_image: xcode8
xcode_project: Relayout.xcodeproj
xcode_sdk: iphonesimulator9.3

env:
global:
- FRAMEWORK_NAME=Relayout
xcode_sdk: iphonesimulator10.0

before_install:
- brew update
- brew outdated carthage || brew upgrade carthage
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- bundle install

install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"

script:
- xctool clean build -project Relayout.xcodeproj -scheme "Relayout" -sdk iphonesimulator
- xctool test -project Relayout.xcodeproj -scheme "Relayout" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5s"
- xctool clean build -project Relayout.xcodeproj -scheme "Relayout" -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p"
- xctool test -project Relayout.xcodeproj -scheme "Relayout" -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p"
- xctool clean build -project Relayout.xcodeproj -scheme "Relayout" -sdk macosx
- xctool test -project Relayout.xcodeproj -scheme "Relayout" -sdk macosx
- xctool clean build -project Relayout.xcodeproj -scheme "Sample App" -sdk iphonesimulator
- xcodebuild clean -project Relayout.xcodeproj -scheme "Relayout" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5s"
- xcodebuild test -project Relayout.xcodeproj -scheme "Relayout" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5s"
- xcodebuild clean -project Relayout.xcodeproj -scheme "Relayout" -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p"
- xcodebuild test -project Relayout.xcodeproj -scheme "Relayout" -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p"
- xcodebuild clean -project Relayout.xcodeproj -scheme "Relayout" -sdk macosx
- xcodebuild test -project Relayout.xcodeproj -scheme "Relayout" -sdk macosx
- xcodebuild clean -project Relayout.xcodeproj -scheme "Sample App" -sdk iphonesimulator
- xcodebuild build -project Relayout.xcodeproj -scheme "Sample App" -sdk iphonesimulator
- carthage build --no-skip-current
- pod lib lint
- bundle exec pod lib lint
- swift build

before_deploy:
- carthage archive Relayout
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'activesupport',
gem 'cocoapods'
gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git'
5 changes: 5 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import PackageDescription

let package = Package(
name: "Relayout"
)
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Finally, Relayout is not a great tool to use in conjunction with Interface Build
Installing
==========

Relayout supports iOS 8.0+, tvOS 9.0+, and OS X 10.10+. You can install Relayout with Carthage, CocoaPods, or manually.
Relayout supports iOS 8.0+, tvOS 9.0+, and OS X 10.10+. You can install Relayout with Carthage, CocoaPods, the Swift package manager, or manually.

With CocoaPods
--------------
Expand All @@ -60,6 +60,13 @@ Add the following to your `Cartfile`:code:. ::

github "stevestreza/Relayout" ~> 1.1

With Swift Package Manager
-------------------------

Add the following to your `Package.swift`:code: dependencies. ::

.Package(url: "https://github.com/stevestreza/Relayout.git", majorVersion: 1)

Manually
--------

Expand Down
4 changes: 2 additions & 2 deletions Relayout.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Relayout"
s.version = "1.1.0"
s.version = "2.0.0"
s.summary = "Swift microframework for declaring Auto Layout constraints functionally"

s.description = <<-DESC
Expand All @@ -22,7 +22,7 @@ really dynamic layouts that change or react to UI state changes using Auto Layou
s.tvos.deployment_target = '9.0'
s.osx.deployment_target = '10.10'

s.source = { :git => "https://github.com/stevestreza/Relayout.git", :tag => "1.1.0" }
s.source = { :git => "https://github.com/stevestreza/Relayout.git", :branch => "swift-3" }

s.source_files = "Framework", "Framework/**/*.swift"

Expand Down
41 changes: 25 additions & 16 deletions Relayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
isa = PBXGroup;
children = (
9BC247281D85128400A8E79B /* Configuration */,
A7EC54FF1D51B20B00A579B9 /* Sources */,
A7EC54E41D51B15200A579B9 /* Framework */,
A7EC54F01D51B15300A579B9 /* Tests */,
A70D4A4E1D51D29E00DD71AE /* Sample App */,
Expand All @@ -169,8 +170,8 @@
A7EC54E41D51B15200A579B9 /* Framework */ = {
isa = PBXGroup;
children = (
A7EC54FF1D51B20B00A579B9 /* Layout */,
A7EC54FE1D51B1FF00A579B9 /* Support Files */,
A7EC54E51D51B15200A579B9 /* Relayout.h */,
A7EC54E71D51B15300A579B9 /* Relayout-Info.plist */,
);
path = Framework;
sourceTree = "<group>";
Expand All @@ -185,16 +186,7 @@
path = RelayoutTests;
sourceTree = "<group>";
};
A7EC54FE1D51B1FF00A579B9 /* Support Files */ = {
isa = PBXGroup;
children = (
A7EC54E51D51B15200A579B9 /* Relayout.h */,
A7EC54E71D51B15300A579B9 /* Relayout-Info.plist */,
);
name = "Support Files";
sourceTree = "<group>";
};
A7EC54FF1D51B20B00A579B9 /* Layout */ = {
A7EC54FF1D51B20B00A579B9 /* Sources */ = {
isa = PBXGroup;
children = (
A7EC55021D51B24200A579B9 /* LayingOut.swift */,
Expand All @@ -207,7 +199,7 @@
A782C3FE1D5311E20080701E /* ListLayout.swift */,
9BC247241D850FD500A8E79B /* PlatformSupport.swift */,
);
path = Layout;
path = Sources;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -285,17 +277,20 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Steve Streza";
TargetAttributes = {
A70D4A4C1D51D29E00DD71AE = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
};
A7EC54E11D51B15200A579B9 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
};
A7EC54EB1D51B15300A579B9 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -423,8 +418,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "$(SRCROOT)/SampleApp/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.TestRelayout.macOS;
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.TestRelayout;
PRODUCT_NAME = RelayoutSampleApp;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -434,8 +431,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "$(SRCROOT)/SampleApp/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.TestRelayout.macOS;
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.TestRelayout;
PRODUCT_NAME = RelayoutSampleApp;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -453,8 +452,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 @@ -478,6 +479,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -499,8 +501,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 @@ -518,6 +522,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MTL_ENABLE_DEBUG_INFO = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -541,6 +546,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -559,6 +565,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.Relayout;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -571,6 +578,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.RelayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -583,6 +591,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.stevestreza.RelayoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
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
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
14 changes: 7 additions & 7 deletions RelayoutTests/RelayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTest

class TestView: UIView {
#if os(OSX)
override var flipped: Bool {
override var isFlipped: Bool {
return true
}
#endif
Expand All @@ -30,10 +30,10 @@ class RelayoutTests: XCTestCase {
let layout = Layout { rootView -> [NSLayoutConstraint] in
XCTAssertEqual(rootView, view)
return [
subview.widthAnchor.constraintEqualToConstant(40),
subview.heightAnchor.constraintEqualToConstant(40),
subview.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor, constant: 20),
subview.topAnchor.constraintEqualToAnchor(view.topAnchor, constant: 20),
subview.widthAnchor.constraint(equalToConstant: 40),
subview.heightAnchor.constraint(equalToConstant: 40),
subview.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
subview.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
]
}
return (view, subview, layout)
Expand Down Expand Up @@ -68,14 +68,14 @@ class RelayoutTests: XCTestCase {
XCTAssertEqual(view.constraints.count, 0)

identifiedLayout.layout()
let regex = try! NSRegularExpression(pattern: "Test \\[[0-9]*\\]", options: NSRegularExpressionOptions())
let regex = try! NSRegularExpression(pattern: "Test \\[[0-9]*\\]", options: NSRegularExpression.Options())
view.constraints.forEach { constraint in
guard let identifier = constraint.identifier else {
XCTAssertNotNil(constraint.identifier)
return
}

XCTAssertTrue(regex.matchesInString(identifier, options: NSMatchingOptions(), range: NSRange(location: 0, length: identifier.characters.count)).count == 1)
XCTAssertTrue(regex.matches(in: identifier, options: NSRegularExpression.MatchingOptions(), range: NSRange(location: 0, length: identifier.characters.count)).count == 1)
}
}

Expand Down
12 changes: 6 additions & 6 deletions SampleApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
10 changes: 10 additions & 0 deletions SampleApp/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down
Loading