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

Fully NS/UILayoutGuide and SwiftPM support #595

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
084f446
Add MASLayoutGuide for UI/NSLayoutGuide support
cntrump May 30, 2021
08e05b1
update deployment target of Masonry.podspec
cntrump May 30, 2021
dcbe1d9
move edges/size/center to MASLayoutConstraint protocol
cntrump May 30, 2021
7cf6452
add MASLayoutGuide as secondViewAttribute support
cntrump May 30, 2021
b59824e
add tvos deployment target
cntrump May 30, 2021
9301688
rename [MASConstraintMaker initWithView:item:] to [MASConstraintMaker…
cntrump May 30, 2021
a6d20a2
replace _firstViewAttribute with self.firstViewAttribute
cntrump May 31, 2021
852b469
add swiftpm support
cntrump May 31, 2021
3116754
Use Xcode 12 for travis
cntrump May 31, 2021
91b6f93
add shorthand for MASLayoutGuide
cntrump May 31, 2021
320cc21
unset translatesAutoresizingMaskIntoConstraints of MASLayoutGuide’s o…
cntrump Jun 1, 2021
cc7d2eb
fix MASLayoutGuide constant with value issue
cntrump Jun 1, 2021
37534c4
fix issue: can’t set width and height for MASLayoutGuide
cntrump Jun 1, 2021
9e83016
replace NS_DEPRECATED_IOS with API_DEPRECATED
cntrump Jun 1, 2021
21c1be7
improve un/install methods of MASViewConstraint
cntrump Jun 1, 2021
598ff1d
fix issue: MASLayoutGuide can’t remake constraints correctly
cntrump Jun 1, 2021
a3f8ed8
move MASShorthandAdditions implementation to sources
cntrump Jun 1, 2021
dead167
improve [MAS_VIEW mas_closestCommonSuperview:]
cntrump Jun 1, 2021
43635cb
add macro NS_ASSUME_NONNULL_BEGIN/END
cntrump Jun 3, 2021
92e1ecd
remove inline flag of _MASBoxValue method
cntrump Jun 3, 2021
41a55a2
update pod spec for travis ci
cntrump Jun 3, 2021
468998d
update updateConstraints of MASExampleUpdateView case
cntrump Jun 3, 2021
b114a99
support mix with swift
cntrump Jun 4, 2021
72b3031
remove useless macro MAS_DISCARDABLE_RESULT
cntrump Jun 4, 2021
99010cb
make MASConstraintDelegate public
cntrump Jun 4, 2021
4ee9477
replace id with instancetype for init method
cntrump Jun 4, 2021
73c3723
Use Xcode 12.5 for travis
cntrump Jun 4, 2021
4666e27
fix issue: build error with ObjC++
cntrump Jun 4, 2021
1866250
fix issue: build error with <iso646.h>
cntrump Jun 4, 2021
7fe0eda
add NS_DESIGNATED_INITIALIZER
cntrump Jun 4, 2021
fa1a87f
enable GitHub Actions
cntrump Jun 5, 2021
79bb3dc
update init method of examples
cntrump Jun 6, 2021
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
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: macOS-latest
steps:
- name: Test
uses: actions/checkout@v2
- name: Build for iOS
run: xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry' -configuration Debug -sdk iphonesimulator clean build ARCHS=x86_64 VALID_ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO
- name: Build for macOS
run: xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry' -configuration Debug -sdk macosx clean build
- name: Build and Test
run: xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry iOS Tests' -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' clean test ARCHS=x86_64 VALID_ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES
- name: Upload coverage to Codecov
uses: codecov/[email protected]
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
language: objective-c
osx_image: xcode9
osx_image: xcode12.5
before_install:
- sudo easy_install cpp-coveralls
- curl -L https://bootstrap.pypa.io/pip/2.7/get-pip.py | sudo python
- sudo pip install cpp-coveralls
- gem install xcpretty -N
- export LANG=en_US.UTF-8

script:
- set -o pipefail
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry iOS Tests' -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.0' clean test ARCHS=i386 VALID_ARCHS=i386 ONLY_ACTIVE_ARCH=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -c
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry iOS' -configuration Debug -sdk iphonesimulator clean build ARCHS=i386 VALID_ARCHS=i386 ONLY_ACTIVE_ARCH=NO | xcpretty -c
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry OSX' -configuration Debug clean build | xcpretty -c
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry iOS Tests' -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' clean test ARCHS=x86_64 VALID_ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -c
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry' -configuration Debug -sdk iphonesimulator clean build ARCHS=x86_64 VALID_ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO | xcpretty -c
- xcodebuild -workspace 'Masonry.xcworkspace' -scheme 'Masonry' -configuration Debug -sdk macosx clean build | xcpretty -c

after_success:
- ./script/coveralls.sh
32 changes: 0 additions & 32 deletions Examples/Masonry iOS Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@
DD52F223179CAD57005CD195 /* Sources */,
DD52F224179CAD57005CD195 /* Frameworks */,
DD52F225179CAD57005CD195 /* Resources */,
5C6517785DFF4287BCDF458D /* [CP] Copy Pods Resources */,
9A6DE33A61510E8F9549C5EE /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -282,21 +280,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
5C6517785DFF4287BCDF458D /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples-resources.sh\"\n";
showEnvVarsInLog = 0;
};
621F6A1FCAEF44F880874959 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -315,21 +298,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9A6DE33A61510E8F9549C5EE /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AED05B61AD59FD40053CC65"
BuildableName = "Masonry.framework"
BlueprintName = "Masonry iOS"
BlueprintName = "Masonry"
ReferencedContainer = "container:../Masonry.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -40,10 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -53,14 +50,13 @@
ReferencedContainer = "container:Masonry iOS Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -77,8 +73,6 @@
ReferencedContainer = "container:Masonry iOS Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
113 changes: 56 additions & 57 deletions Examples/Masonry iOS Examples/MASExampleAnimatedView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,62 @@ @interface MASExampleAnimatedView ()

@implementation MASExampleAnimatedView

- (id)init {
self = [super init];
if (!self) return nil;

UIView *greenView = UIView.new;
greenView.backgroundColor = UIColor.greenColor;
greenView.layer.borderColor = UIColor.blackColor.CGColor;
greenView.layer.borderWidth = 2;
[self addSubview:greenView];

UIView *redView = UIView.new;
redView.backgroundColor = UIColor.redColor;
redView.layer.borderColor = UIColor.blackColor.CGColor;
redView.layer.borderWidth = 2;
[self addSubview:redView];

UIView *blueView = UIView.new;
blueView.backgroundColor = UIColor.blueColor;
blueView.layer.borderColor = UIColor.blackColor.CGColor;
blueView.layer.borderWidth = 2;
[self addSubview:blueView];

UIView *superview = self;
int padding = self.padding = 10;
UIEdgeInsets paddingInsets = UIEdgeInsetsMake(self.padding, self.padding, self.padding, self.padding);

self.animatableConstraints = NSMutableArray.new;

[greenView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.bottom.equalTo(blueView.mas_top).offset(-padding),
]];

make.size.equalTo(redView);
make.height.equalTo(blueView.mas_height);
}];

[redView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.left.equalTo(greenView.mas_right).offset(padding),
make.bottom.equalTo(blueView.mas_top).offset(-padding),
]];

make.size.equalTo(greenView);
make.height.equalTo(blueView.mas_height);
}];

[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
]];

make.height.equalTo(greenView.mas_height);
make.height.equalTo(redView.mas_height);
}];
- (instancetype)init {
if (self = [super init]) {
UIView *greenView = UIView.new;
greenView.backgroundColor = UIColor.greenColor;
greenView.layer.borderColor = UIColor.blackColor.CGColor;
greenView.layer.borderWidth = 2;
[self addSubview:greenView];

UIView *redView = UIView.new;
redView.backgroundColor = UIColor.redColor;
redView.layer.borderColor = UIColor.blackColor.CGColor;
redView.layer.borderWidth = 2;
[self addSubview:redView];

UIView *blueView = UIView.new;
blueView.backgroundColor = UIColor.blueColor;
blueView.layer.borderColor = UIColor.blackColor.CGColor;
blueView.layer.borderWidth = 2;
[self addSubview:blueView];

UIView *superview = self;
int padding = self.padding = 10;
UIEdgeInsets paddingInsets = UIEdgeInsetsMake(self.padding, self.padding, self.padding, self.padding);

self.animatableConstraints = NSMutableArray.new;

[greenView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.bottom.equalTo(blueView.mas_top).offset(-padding),
]];

make.size.equalTo(redView);
make.height.equalTo(blueView.mas_height);
}];

[redView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.left.equalTo(greenView.mas_right).offset(padding),
make.bottom.equalTo(blueView.mas_top).offset(-padding),
]];

make.size.equalTo(greenView);
make.height.equalTo(blueView.mas_height);
}];

[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.animatableConstraints addObjectsFromArray:@[
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
]];

make.height.equalTo(greenView.mas_height);
make.height.equalTo(redView.mas_height);
}];
}

return self;
}
Expand Down
63 changes: 31 additions & 32 deletions Examples/Masonry iOS Examples/MASExampleArrayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,37 @@ @interface MASExampleArrayView ()

@implementation MASExampleArrayView

- (id)init {
self = [super init];
if (!self) return nil;

UIButton *raiseButton = [UIButton buttonWithType:UIButtonTypeSystem];
[raiseButton setTitle:@"Raise" forState:UIControlStateNormal];
[raiseButton addTarget:self action:@selector(raiseAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:raiseButton];

UIButton *centerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[centerButton setTitle:@"Center" forState:UIControlStateNormal];
[centerButton addTarget:self action:@selector(centerAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:centerButton];

UIButton *lowerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[lowerButton setTitle:@"Lower" forState:UIControlStateNormal];
[lowerButton addTarget:self action:@selector(lowerAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:lowerButton];

[lowerButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).with.offset(10.0);
}];

[centerButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
}];

[raiseButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self).with.offset(-10);
}];

self.buttonViews = @[ raiseButton, lowerButton, centerButton ];
- (instancetype)init {
if (self = [super init]) {
UIButton *raiseButton = [UIButton buttonWithType:UIButtonTypeSystem];
[raiseButton setTitle:@"Raise" forState:UIControlStateNormal];
[raiseButton addTarget:self action:@selector(raiseAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:raiseButton];

UIButton *centerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[centerButton setTitle:@"Center" forState:UIControlStateNormal];
[centerButton addTarget:self action:@selector(centerAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:centerButton];

UIButton *lowerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[lowerButton setTitle:@"Lower" forState:UIControlStateNormal];
[lowerButton addTarget:self action:@selector(lowerAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:lowerButton];

[lowerButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).with.offset(10.0);
}];

[centerButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
}];

[raiseButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self).with.offset(-10);
}];

self.buttonViews = @[ raiseButton, lowerButton, centerButton ];
}

return self;
}
Expand Down
Loading