Fixed crash when loading via SPM using Xcode 11.3.1

This commit is contained in:
Darren Ford 2020-01-16 15:30:20 +11:00
parent 69fa2990c7
commit dcaf1087c5
4 changed files with 27 additions and 29 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "DSFFloatLabelledTextControl" s.name = "DSFFloatLabelledTextControl"
s.version = "1.0" s.version = "1.1"
s.summary = "A macOS Cocoa single-line NSTextField that implements the Float Label Pattern" s.summary = "A macOS Cocoa single-line NSTextField that implements the Float Label Pattern"
s.description = <<-DESC s.description = <<-DESC
A macOS Cocoa single-line NSTextField that implements the Float Label Pattern. A macOS Cocoa single-line NSTextField that implements the Float Label Pattern.

View File

@ -474,6 +474,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.darrenford.DSFFloatLabelledTextControls; PRODUCT_BUNDLE_IDENTIFIER = com.darrenford.DSFFloatLabelledTextControls;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -496,6 +497,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.darrenford.DSFFloatLabelledTextControls; PRODUCT_BUNDLE_IDENTIFIER = com.darrenford.DSFFloatLabelledTextControls;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View File

@ -78,10 +78,29 @@ import Cocoa
} }
} }
/// Return the cell as a float cell type /// Return the custom cell type
private var fieldCell: DSFFloatLabelledTextFieldCell { fileprivate lazy var fieldCell: DSFFloatLabelledTextFieldCell = {
return self.cell as! DSFFloatLabelledTextFieldCell let customCell = DSFFloatLabelledTextFieldCell()
} customCell.topOffset = self.placeholderHeight
customCell.isEditable = true
customCell.wraps = false
customCell.usesSingleLineMode = true
customCell.placeholderString = self.placeholderString
customCell.title = self.stringValue
customCell.font = self.font
customCell.isBordered = self.isBordered
customCell.isBezeled = self.isBezeled
customCell.bezelStyle = self.bezelStyle
customCell.isScrollable = true
customCell.isContinuous = self.isContinuous
customCell.alignment = self.alignment
customCell.formatter = self.formatter
self.cell = customCell
return customCell
}()
/// Set the fonts to be used in the control /// Set the fonts to be used in the control
open func setFonts(primary: NSFont, secondary: NSFont) { open func setFonts(primary: NSFont, secondary: NSFont) {
@ -150,28 +169,6 @@ import Cocoa
self.addConstraint(x) self.addConstraint(x)
} }
/// Build the text field's custom cell
private func createCustomCell() {
let customCell = DSFFloatLabelledTextFieldCell()
customCell.topOffset = self.placeholderHeight
customCell.isEditable = true
customCell.wraps = false
customCell.usesSingleLineMode = true
customCell.placeholderString = self.placeholderString
customCell.title = self.stringValue
customCell.font = self.font
customCell.isBordered = self.isBordered
customCell.isBezeled = self.isBezeled
customCell.bezelStyle = self.bezelStyle
customCell.isScrollable = true
customCell.isContinuous = self.isContinuous
customCell.alignment = self.alignment
customCell.formatter = self.formatter
self.cell? = customCell
}
private func commonSetup() { private func commonSetup() {
self.wantsLayer = true self.wantsLayer = true
self.translatesAutoresizingMaskIntoConstraints = false self.translatesAutoresizingMaskIntoConstraints = false
@ -179,7 +176,6 @@ import Cocoa
self.delegate = self self.delegate = self
self.createFloatingLabel() self.createFloatingLabel()
self.createCustomCell()
self.heightConstraint = NSLayoutConstraint( self.heightConstraint = NSLayoutConstraint(
item: self, attribute: .height, item: self, attribute: .height,