Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
spm support
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetppro authored and Vadim Shpakovski committed Jun 27, 2021
1 parent 0318732 commit 1b7ac3d
Show file tree
Hide file tree
Showing 38 changed files with 71 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ Fastlane/README.md
Fastlane/report.xml
# Finder
.DS_Store
.swiftpm
.build
6 changes: 0 additions & 6 deletions Framework/MASShortcut.modulemap

This file was deleted.

1 change: 1 addition & 0 deletions Framework/Shortcut.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import <AppKit/AppKit.h>
#import "MASKeyMasks.h"
#import "MASShortcut.h"
#import "MASShortcutValidator.h"
Expand Down
2 changes: 1 addition & 1 deletion Framework/UI/MASLocalization.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
NSLocalizedString throughout the framework, it wouldn’t work
properly.
*/
NSString *MASLocalizedString(NSString *key, NSString *comment);
NSString *MASLocalizedString(NSString *key, NSString *comment);
16 changes: 1 addition & 15 deletions Framework/UI/MASLocalization.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,7 @@
static NSBundle *localizationBundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSBundle *frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]];
// first we'll check if resources bundle was copied to MASShortcut framework bundle when !use_frameworks option is active
NSURL *cocoaPodsBundleURL = [frameworkBundle URLForResource:@"MASShortcut" withExtension:@"bundle"];
if (cocoaPodsBundleURL) {
localizationBundle = [NSBundle bundleWithURL: cocoaPodsBundleURL];
} else {
// trying to fetch cocoapods bundle from main bundle
cocoaPodsBundleURL = [[NSBundle mainBundle] URLForResource: @"MASShortcut" withExtension:@"bundle"];
if (cocoaPodsBundleURL) {
localizationBundle = [NSBundle bundleWithURL: cocoaPodsBundleURL];
} else {
// fallback to framework bundle
localizationBundle = frameworkBundle;
}
}
localizationBundle = SWIFTPM_MODULE_BUNDLE;
});
return [localizationBundle localizedStringForKey:key
value:MASPlaceholderLocalizationString
Expand Down
1 change: 1 addition & 0 deletions Framework/UI/MASShortcutView+Bindings.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import <AppKit/AppKit.h>
#import "MASShortcutView.h"

/**
Expand Down
2 changes: 2 additions & 0 deletions Framework/UI/MASShortcutView.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import <AppKit/AppKit.h>

@class MASShortcut, MASShortcutValidator;

extern NSString * _Nonnull const MASShortcutBinding;
Expand Down
2 changes: 2 additions & 0 deletions Framework/User Defaults Storage/MASDictionaryTransformer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import <AppKit/AppKit.h>

extern NSString *const MASDictionaryTransformerName;

/**
Expand Down
1 change: 1 addition & 0 deletions Framework/include/MASDictionaryTransformer.h
1 change: 1 addition & 0 deletions Framework/include/MASHotKey.h
1 change: 1 addition & 0 deletions Framework/include/MASKeyCodes.h
1 change: 1 addition & 0 deletions Framework/include/MASKeyMasks.h
1 change: 1 addition & 0 deletions Framework/include/MASLocalization.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcut.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcutBinder.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcutMonitor.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcutValidator.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcutView+Bindings.h
1 change: 1 addition & 0 deletions Framework/include/MASShortcutView.h
1 change: 1 addition & 0 deletions Framework/include/Shortcut.h
5 changes: 5 additions & 0 deletions Framework/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework module MASShortcut {
umbrella header "include/Shortcut.h"
export *
module * { export * }
}
13 changes: 9 additions & 4 deletions MASShortcut.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
0D827D771990F81E0010B8EF /* Shortcut.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D761990F81E0010B8EF /* Shortcut.h */; settings = {ATTRIBUTES = (Public, ); }; };
0D827D9419910B740010B8EF /* MASShortcutTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D827D9319910B740010B8EF /* MASShortcutTests.m */; };
0D827D9519910C1E0010B8EF /* MASShortcut.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D827CD31990D4420010B8EF /* MASShortcut.framework */; };
0D827D9719910FF70010B8EF /* MASKeyCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D9619910FF70010B8EF /* MASKeyCodes.h */; settings = {ATTRIBUTES = (Public, ); }; };
0D827D9719910FF70010B8EF /* MASKeyCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D9619910FF70010B8EF /* MASKeyCodes.h */; };
0D827D99199110F60010B8EF /* Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D98199110F60010B8EF /* Prefix.pch */; };
0D827D9E19911A190010B8EF /* MASShortcutValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D9C19911A190010B8EF /* MASShortcutValidator.h */; settings = {ATTRIBUTES = (Public, ); }; };
0D827D9F19911A190010B8EF /* MASShortcutValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D827D9D19911A190010B8EF /* MASShortcutValidator.m */; };
0D827DA519912D240010B8EF /* MASShortcutMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827DA319912D240010B8EF /* MASShortcutMonitor.h */; settings = {ATTRIBUTES = (Public, ); }; };
0D827DAD199132840010B8EF /* MASShortcutBinder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827DAB199132840010B8EF /* MASShortcutBinder.h */; settings = {ATTRIBUTES = (Public, ); }; };
0DA8BCFC1DC37D8000C96EB9 /* MASKeyMasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DA8BCFB1DC37D8000C96EB9 /* MASKeyMasks.h */; settings = {ATTRIBUTES = (Public, ); }; };
0DC2F17619922798003A0131 /* MASHotKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DC2F17419922798003A0131 /* MASHotKey.h */; };
0DC2F17619922798003A0131 /* MASHotKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DC2F17419922798003A0131 /* MASHotKey.h */; settings = {ATTRIBUTES = (Public, ); }; };
0DC2F17719922798003A0131 /* MASHotKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DC2F17519922798003A0131 /* MASHotKey.m */; };
0DC2F17C199232EA003A0131 /* MASShortcutMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D827DA419912D240010B8EF /* MASShortcutMonitor.m */; };
0DC2F17D199232F7003A0131 /* MASShortcutBinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D827DAC199132840010B8EF /* MASShortcutBinder.m */; };
Expand Down Expand Up @@ -101,7 +101,7 @@
0D827D6B1990D6110010B8EF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0D827D6C1990D6110010B8EF /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
0D827D6D1990D6110010B8EF /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
0D827D761990F81E0010B8EF /* Shortcut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shortcut.h; sourceTree = "<group>"; };
0D827D761990F81E0010B8EF /* Shortcut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Shortcut.h; path = include/Shortcut.h; sourceTree = "<group>"; };
0D827D8319910AFF0010B8EF /* MASShortcutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MASShortcutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0D827D8719910AFF0010B8EF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0D827D8D19910AFF0010B8EF /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
Expand Down Expand Up @@ -229,7 +229,8 @@
children = (
0D2CAB151B8332E5005431FC /* Localizable.strings */,
);
path = Resources;
name = Resources;
path = Framework/Resources;
sourceTree = "<group>";
};
0DBA0B9E22A4FAC5008685CD /* Framework */ = {
Expand Down Expand Up @@ -665,12 +666,14 @@
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Framework/Prefix.pch;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = Framework/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = Framework/MASShortcut.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = "com.github.shpakovski.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = framework;
};
name = Debug;
Expand All @@ -687,12 +690,14 @@
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Framework/Prefix.pch;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = Framework/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = Framework/MASShortcut.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = "com.github.shpakovski.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = framework;
};
name = Release;
Expand Down
35 changes: 35 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version:5.4

import PackageDescription

let package = Package(
name: "MASShortcut",
defaultLocalization: "en",
platforms: [
.macOS(.v10_11),
],
products: [
.library(name: "MASShortcut",
targets: ["MASShortcut"])
],
targets: [
.target(
name: "MASShortcut",
path: "Framework",
exclude: [
"Model/MASShortcutTests.m",
"Monitoring/MASHotKeyTests.m",
"Monitoring/MASShortcutMonitorTests.m",
"User Defaults Storage/MASDictionaryTransformerTests.m",
"User Defaults Storage/MASShortcutBinderTests.m",
"Info.plist",
"Prefix.pch"
],
resources: [
.process("Resources")
],
publicHeadersPath: "include"
)
],
swiftLanguageVersions: [.v5]
)

0 comments on commit 1b7ac3d

Please sign in to comment.