-
Notifications
You must be signed in to change notification settings - Fork 38
Description
After running a profiling script to check the compilation times of the project (because it began to be really slow) I noticed that the methods where I set up the constraints with this library are the ones that take the longest to compile and it's making the project to take between 4 - 5 min to run. The project is really small so it shouldn't be the case.
This is the method that takes the longest to compile. 56690.86ms
fileprivate func setupConstraints() {
playerComponentView.translatesAutoresizingMaskIntoConstraints = false
headerComponentView.translatesAutoresizingMaskIntoConstraints = false
tabsComponentView.translatesAutoresizingMaskIntoConstraints = false
componentsScrollView.translatesAutoresizingMaskIntoConstraints = false
topHeaderView.translatesAutoresizingMaskIntoConstraints = false
closeButton.translatesAutoresizingMaskIntoConstraints = false
chromecastButton.translatesAutoresizingMaskIntoConstraints = false
topTitleLabel.translatesAutoresizingMaskIntoConstraints = false
if UIDevice.current.userInterfaceIdiom == .pad {
addConstraints([componentsScrollView.width == width * 0.7,
componentsScrollView.top == top,
componentsScrollView.bottom == bottom,
componentsScrollView.centerX == centerX])
} else {
addConstraints([componentsScrollView.leading == leading,
componentsScrollView.top == top,
componentsScrollView.bottom == bottom,
componentsScrollView.trailing == trailing])
}
let playerHeight = (((UIScreen.main.bounds.height * 0.7) * 9) / 16)
addConstraints([playerComponentView.leading == componentsScrollView.leading,
playerComponentView.trailing == componentsScrollView.trailing,
playerComponentView.top == componentsScrollView.top,
playerComponentView.height == playerHeight,
playerComponentView.width == componentsScrollView.width])
addConstraints([headerComponentView.top == playerComponentView.bottom,
headerComponentView.leading == componentsScrollView.leading,
headerComponentView.trailing == componentsScrollView.trailing,
headerComponentView.width == componentsScrollView.width])
addConstraints([tabsComponentView.leading == componentsScrollView.leading,
tabsComponentView.trailing == componentsScrollView.trailing,
tabsComponentView.top == headerComponentView.bottom,
tabsComponentView.bottom == componentsScrollView.bottom,
tabsComponentView.width == componentsScrollView.width])
topHeaderBottomConstraint = (topHeaderView.bottom == top)
addConstraints([topHeaderBottomConstraint,
topHeaderView.leading == componentsScrollView.leading,
topHeaderView.trailing == componentsScrollView.trailing])
let buttonsTopMargin = (UIApplication.shared.statusBarFrame.height + 8)
addConstraints([closeButton.trailing == topHeaderView.trailing - 8,
closeButton.top == top + buttonsTopMargin,
closeButton.width == 48,
closeButton.height == 48])
addConstraints([chromecastButton.trailing == closeButton.leading - 8,
chromecastButton.top == closeButton.top,
chromecastButton.width == 48,
chromecastButton.height == 48])
addConstraints([topTitleLabel.leading == topHeaderView.leading + DetailsViewDesignGuidelines.contentMargin,
topTitleLabel.trailing == chromecastButton.leading - 8,
topTitleLabel.top == topHeaderView.top + (UIApplication.shared.statusBarFrame.height + 20),
topTitleLabel.bottom == topHeaderView.bottom - 16])
}
By changing the constraints configuration to use NSLayoutConstraint directly it goes down to 10.56ms As you can see is quite difference.
Any ideas on what could be the problem or how to fix this? I would really like to continue using this library because it makes so much easier and faster the constraints setup, but the impact it has on the build time is just too big and it will only get worse as the project gets bigger.