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

Enable extension-safe API #144

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion ShortcutRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1000;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1330;
TargetAttributes = {
9398377F0DA42965007F53F3 = {
LastSwiftMigration = 1000;
Expand Down Expand Up @@ -830,6 +830,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
Expand All @@ -851,6 +852,7 @@
CLANG_WARN_OBJC_INTERFACE_IVARS = YES_ERROR;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
Expand Down Expand Up @@ -886,6 +888,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
Expand All @@ -907,6 +910,7 @@
CLANG_WARN_OBJC_INTERFACE_IVARS = YES_ERROR;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
Expand Down
18 changes: 0 additions & 18 deletions Sources/ShortcutRecorder/SRRecorderControlStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,6 @@ - (NSComparisonResult)compare:(SRRecorderControlStyleComponents *)anOtherCompone
relativeToComponents:(SRRecorderControlStyleComponents *)anIdealComponents
{
static NSDictionary<NSNumber *, NSArray<NSNumber *> *> *AppearanceOrderMap = nil;
static NSDictionary<NSNumber *, NSArray<NSNumber *> *> *TintOrderMap = nil;
static NSDictionary<NSNumber *, NSArray<NSNumber *> *> *DirectionOrderMap = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
AppearanceOrderMap = @{
Expand All @@ -346,22 +344,6 @@ - (NSComparisonResult)compare:(SRRecorderControlStyleComponents *)anOtherCompone
@(SRRecorderControlStyleComponentsAppearanceAqua),
@(SRRecorderControlStyleComponentsAppearanceUnspecified)]
};

TintOrderMap = @{
@(SRRecorderControlStyleComponentsTintBlue): @[@(SRRecorderControlStyleComponentsTintBlue),
@(SRRecorderControlStyleComponentsTintGraphite),
@(SRRecorderControlStyleComponentsTintUnspecified)],
@(SRRecorderControlStyleComponentsTintGraphite): @[@(SRRecorderControlStyleComponentsTintGraphite),
@(SRRecorderControlStyleComponentsTintBlue),
@(SRRecorderControlStyleComponentsTintUnspecified)]
};

DirectionOrderMap = @{
@(SRRecorderControlStyleComponentsLayoutDirectionLeftToRight): @[@(SRRecorderControlStyleComponentsLayoutDirectionLeftToRight),
@(SRRecorderControlStyleComponentsLayoutDirectionRightToLeft)],
@(SRRecorderControlStyleComponentsLayoutDirectionRightToLeft): @[@(SRRecorderControlStyleComponentsLayoutDirectionRightToLeft),
@(SRRecorderControlStyleComponentsLayoutDirectionLeftToRight)]
};
});

__auto_type CompareEnum = ^(NSUInteger a, NSUInteger b, NSArray<NSNumber *> *order) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ShortcutRecorder/SRShortcut.m
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
+ (instancetype)new
{
[self doesNotRecognizeSelector:_cmd];
return nil;
return [super new];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is undesirable since we don't want to instantiate any object here. An exception that leads to crash is desirable here since this is a programmer's error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it still does throw an exception, basically this line is dead code. But newer Xcode versions warn about returning nil from new, I thought it's better to fix this than to disable the warning in project settings, no?

}

- (instancetype)init
Expand Down