Skip to content
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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: objective-c
osx_image: xcode9.4
cache: bundler

cache:
- bundler
- cocoapods

install:
- bundle install # --deployment # to cache vendor/bundle
Expand Down
2 changes: 1 addition & 1 deletion Example/PinLayoutSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
inputPaths = (
"${SRCROOT}/../Pods/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PinLayout/PinLayout.framework",
"${PODS_ROOT}/Reveal-SDK/RevealServer-18/iOS/RevealServer.framework",
"${PODS_ROOT}/Reveal-SDK/RevealServer-17/iOS/RevealServer.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand Down
1 change: 0 additions & 1 deletion PinLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Pod::Spec.new do |spec|
spec.author = { "Luc Dion" => "[email protected]" }
spec.source = { :git => "https://github.com/layoutBox/PinLayout.git", :tag => "#{spec.version}" }
spec.source_files = "Sources/**/*.swift"
spec.swift_version = '4.1'

spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
Expand Down
4 changes: 3 additions & 1 deletion PinLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 4Q596JWQC5;
Expand Down Expand Up @@ -1379,6 +1379,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.layoutbox.PinLayout-macOS";
PRODUCT_NAME = PinLayout;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
Expand Down Expand Up @@ -1411,6 +1412,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.layoutbox.PinLayout-macOS";
PRODUCT_NAME = PinLayout;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- Nimble (7.0.3)
- PinLayout (1.8.4)
- PinLayout (1.8.5)
- Quick (1.2.0)
- Reveal-SDK (18)
- Reveal-SDK (17)
- SwiftLint (0.27.0)

DEPENDENCIES:
Expand All @@ -25,9 +25,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac
PinLayout: 143506c26a2292428e86df058aae15c7c040e9f0
PinLayout: a4b78dd50eb2e85c31b4418013461fa667764783
Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08
Reveal-SDK: cce79388da3fd0bbb6ae19d769b906cfc3a33a89
Reveal-SDK: a6df49f47319bd19a110c960c498af32df72c0af
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073

PODFILE CHECKSUM: 62618887f8155abc1ed3348d9b676cf6915137e2
Expand Down
24 changes: 14 additions & 10 deletions Sources/Impl/Coordinates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,14 @@ import UIKit
import AppKit
#endif

#if os(iOS) || os(tvOS)
internal var displayScale: CGFloat = UIScreen.main.scale
#elseif os(OSX)
internal var displayScale: CGFloat = NSScreen.main?.backingScaleFactor ?? 2.0
#endif
internal var displayScale: CGFloat = getDisplayScale()
internal var onePixelLength: CGFloat = 1 / displayScale

public func _pinlayoutSetUnitTest(scale: CGFloat?) {
if let scale = scale {
displayScale = scale
} else {
#if os(iOS) || os(tvOS)
displayScale = UIScreen.main.scale
#elseif os(OSX)
displayScale = NSScreen.main?.backingScaleFactor ?? 2.0
#endif
displayScale = getDisplayScale()
}
}

Expand Down Expand Up @@ -113,3 +105,15 @@ final class Coordinates<View: Layoutable> {
return CGFloat(ceilf(Float(pointValue * displayScale))) / displayScale
}
}

private func getDisplayScale() -> CGFloat {
#if os(iOS) || os(tvOS)
return UIScreen.main.scale
#elseif os(OSX)
#if swift(>=4.1)
return NSScreen.main?.backingScaleFactor ?? 2.0
#else
return NSScreen.main()?.backingScaleFactor ?? 2.0
#endif
#endif
}
1 change: 0 additions & 1 deletion Sources/SupportingFiles/PinLayoutMacOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// THE SOFTWARE.

#import <Foundation/Foundation.h>
//#import <Cocoa/Cocoa.h>

//! Project version number for PinLayoutMacOS.
FOUNDATION_EXPORT double PinLayoutMacOSVersionNumber;
Expand Down
4 changes: 2 additions & 2 deletions TestProjects/cocoapods/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- PinLayout (1.8.3)
- PinLayout (1.8.5)

DEPENDENCIES:
- PinLayout (from `../../..`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../../.."

SPEC CHECKSUMS:
PinLayout: 1330ea0c6324556e7bdb9b36af32a262a97d2ff2
PinLayout: a4b78dd50eb2e85c31b4418013461fa667764783

PODFILE CHECKSUM: e4d7a00501eec9097d00e6c5397befb6e16ccaec

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PinLayout-tvOS/PinLayout-tvOS-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -325,7 +325,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.layoutbox.project.PinLayout-tvOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PinLayout-tvOS/PinLayout-tvOS-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
10 changes: 10 additions & 0 deletions Tests/Common/AdjustSizeSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class AdjustSizeSpec: QuickSpec {
bViewChild.frame = CGRect(x: 40, y: 10, width: 60, height: 20)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
}

describe("the result of the width(...) methods") {
it("should adjust the width of aView") {
aView.pin.width(35)
Expand Down Expand Up @@ -858,16 +862,22 @@ class AdjustSizeSpec: QuickSpec {
}

it("should produce the same size as the built-in sizeToFit() method") {
_pinlayoutSetUnitTest(scale: nil)

let label = PLabel(frame: CGRect.zero)
label.text = "Lorem ipsum dolor sit amet"
label.pin.sizeToFit()
let size = label.bounds.size

label.bounds.size = CGSize.zero
label.sizeToFit()

expect(size).to(equal(label.bounds.size))
}

it("should produce the same size as the built-in sizeToFit() method when there is a transform applied") {
_pinlayoutSetUnitTest(scale: nil)

let label = PLabel(frame: CGRect.zero)
label.text = "Lorem ipsum dolor sit amet"
label.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
Expand Down
4 changes: 4 additions & 0 deletions Tests/Common/JustifyAlignSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class JustifyAlignSpec: QuickSpec {
aView.sizeThatFitsExpectedArea = 40 * 40
rootView.addSubview(aView)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
}

//
// justify + warning
Expand Down
3 changes: 2 additions & 1 deletion Tests/Common/LayoutMethodSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class LayoutMethodSpec: QuickSpec {
aView.frame = CGRect(x: 40, y: 100, width: 100, height: 60)
rootView.addSubview(aView)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
Pin.logMissingLayoutCalls = false
}

Expand Down
4 changes: 4 additions & 0 deletions Tests/Common/MinMaxWidthHeightSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class MinMaxWidthHeightSpec: QuickSpec {
rootView.addSubview(aView)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
}

//
// minWidth
//
Expand Down
4 changes: 4 additions & 0 deletions Tests/Common/WarningSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class WarningSpec: QuickSpec {
aView.sizeThatFitsExpectedArea = 40 * 40
rootView.addSubview(aView)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
}

//
// pinEdges warnings
Expand Down
4 changes: 4 additions & 0 deletions Tests/Common/WrapContentSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class WrapContentSpec: QuickSpec {
rootView.frame = CGRect(x: 0, y: 100, width: 400, height: 400)
}

afterEach {
_pinlayoutSetUnitTest(scale: nil)
}

describe("wrapContent") {
it("wrap and update subviews position") {
aView.frame = CGRect(x: 20, y: 10, width: 200, height: 100)
Expand Down
25 changes: 14 additions & 11 deletions build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
DERIVED_DATA=${1:-/tmp/PinLayout}

set -o pipefail &&

rm -rf $DERIVED_DATA &&

echo "===============================" &&
echo "fastlane iOS travis" &&
echo "===============================" &&
time bundle exec fastlane ios travis &&


# echo "===============================" &&
# echo "fastlane macOS travis" &&
# echo "===============================" &&
Expand All @@ -21,25 +19,30 @@ echo "===============================" &&
echo "iOS unit test" &&
echo "===============================" &&
time xcodebuild build test -workspace PinLayout.xcworkspace -scheme PinLayout-iOS -derivedDataPath $DERIVED_DATA -sdk iphonesimulator11.4 \
-destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=11.4' \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.4' \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=10.2'\
-destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \
| xcpretty &&

time xcodebuild build test -workspace PinLayout.xcworkspace -scheme PinLayout-iOS -derivedDataPath $DERIVED_DATA -sdk iphonesimulator11.4 \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' \
| xcpretty &&

time xcodebuild build test -workspace PinLayout.xcworkspace -scheme PinLayout-iOS -derivedDataPath $DERIVED_DATA -sdk iphonesimulator11.4 \
-destination 'platform=iOS Simulator,name=iPhone 8,OS=11.4' \
| xcpretty &&

echo "===============================" &&
echo "tvOS unit test" &&
echo "===============================" &&
time xcodebuild build test -workspace PinLayout.xcworkspace -scheme PinLayout-tvOS -derivedDataPath $DERIVED_DATA -sdk appletvsimulator11.4 \
-destination 'platform=tvOS Simulator,name=Apple TV 4K,OS=11.4' \
| xcpretty
| xcpretty &&


echo "===============================" &&
echo "macOS unit test" &&
echo "===============================" &&
time xcodebuild clean test -workspace PinLayout.xcworkspace -scheme PinLayout-macOS -derivedDataPath $DERIVED_DATA -sdk macosx10.13 \
| xcpretty
| xcpretty &&


echo "===============================" &&
Expand All @@ -49,9 +52,9 @@ cd TestProjects/cocoapods/ios &&
rm -rf $DERIVED_DATA &&
pod install &&
time xcodebuild clean build -workspace PinLayout-iOS.xcworkspace -scheme PinLayout-iOS -sdk iphonesimulator11.4 -derivedDataPath $DERIVED_DATA \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.4' \
-destination 'platform=iOS Simulator,name=iPhone 8,OS=11.4' \
| xcpretty &&
cd ../../..
cd ../../.. &&


echo "===============================" &&
Expand All @@ -62,7 +65,7 @@ rm -rf $DERIVED_DATA &&
pod install &&
time xcodebuild clean build -workspace PinLayout-macOS.xcworkspace -scheme PinLayout-macOS -sdk macosx10.13 -derivedDataPath $DERIVED_DATA \
| xcpretty &&
cd ../../..
cd ../../.. &&


echo "===============================" &&
Expand All @@ -74,7 +77,7 @@ pod install &&
time xcodebuild clean build -workspace PinLayout-tvOS.xcworkspace -scheme PinLayout-tvOS -sdk appletvsimulator11.4 -derivedDataPath $DERIVED_DATA \
-destination 'platform=tvOS Simulator,name=Apple TV,OS=11.4' \
| xcpretty &&
cd ../../..
cd ../../.. &&


echo "===============================" &&
Expand Down
6 changes: 3 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ platform :ios do
workspace: "PinLayout.xcworkspace",
devices: [
"iPhone 7 (10.2)",
"iPhone 7 (11.2)",
"iPad Air (11.2)",
"iPhone X (11.2)"
"iPhone 8 (11.4)",
"iPad Air (11.4)",
"iPhone X (11.4)"
]
)
end
Expand Down