Skip to content

Commit

Permalink
Fix initWithCoder crash
Browse files Browse the repository at this point in the history
— Make sure `super.init()` is directly called in each IB initializer;
— Update project settings;
— Update CI settings;
— Bump version;
— Disable stats sending for pods in Sample project.
  • Loading branch information
taflanidi committed Apr 8, 2019
1 parent 1466b24 commit c2f0d9b
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
language: objective-c
osx_image: xcode10
osx_image: xcode10.2
script: swift test
2 changes: 1 addition & 1 deletion InputMask.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "InputMask"
spec.version = "4.1.0"
spec.version = "4.1.1"
spec.summary = "InputMask"
spec.description = "User input masking library."
spec.homepage = "https://github.com/RedMadRobot/input-mask-ios"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,27 @@ open class MaskedTextFieldDelegate: NSObject, UITextFieldDelegate {
super.init()
}

public override convenience init() {
// Interface Builder support
self.init(primaryFormat: "")
public override init() {
/**
Interface Builder support
https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2
From known issue no.2:
> To reduce the size taken up by Swift metadata, convenience initializers defined in Swift now only allocate an
> object ahead of time if they’re calling a designated initializer defined in Objective-C. In most cases, this
> has no effect on your program, but if your convenience initializer is called from Objective-C, the initial
> allocation from +alloc is released without any initializer being called.
*/
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,27 @@ open class MaskedTextInputListener: NSObject {
super.init()
}

public override convenience init() {
// Interface Builder support
self.init(primaryFormat: "")
public override init() {
/**
Interface Builder support
https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2
From known issue no.2:
> To reduce the size taken up by Swift metadata, convenience initializers defined in Swift now only allocate an
> object ahead of time if they’re calling a designated initializer defined in Objective-C. In most cases, this
> has no effect on your program, but if your convenience initializer is called from Objective-C, the initial
> allocation from +alloc is released without any initializer being called.
*/
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,27 @@ open class MaskedTextViewDelegate: NSObject, UITextViewDelegate {
super.init()
}

public override convenience init() {
// Interface Builder support
self.init(primaryFormat: "")
public override init() {
/**
Interface Builder support
https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2
From known issue no.2:
> To reduce the size taken up by Swift metadata, convenience initializers defined in Swift now only allocate an
> object ahead of time if they’re calling a designated initializer defined in Objective-C. In most cases, this
> has no effect on your program, but if your convenience initializer is called from Objective-C, the initial
> allocation from +alloc is released without any initializer being called.
*/
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Source/Sample/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
Expand Down
16 changes: 9 additions & 7 deletions Source/Sample/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Egor Taflanidi";
TargetAttributes = {
8A0185591D64C1AA007B5EBD = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 8A0185551D64C1AA007B5EBD /* Build configuration list for PBXProject "Sample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -168,7 +168,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/InputMask/InputMask.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -177,7 +177,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
6E2326DC78E515DD28D4BAD9 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -238,6 +238,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -295,6 +296,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -353,7 +355,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -368,7 +370,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down

0 comments on commit c2f0d9b

Please sign in to comment.