diff --git a/ExtensionApp.xcodeproj/project.pbxproj b/ExtensionApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4b75a0b --- /dev/null +++ b/ExtensionApp.xcodeproj/project.pbxproj @@ -0,0 +1,332 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + B39AD237229FD14D00F97FA9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39AD236229FD14D00F97FA9 /* AppDelegate.swift */; }; + B39AD239229FD14D00F97FA9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39AD238229FD14D00F97FA9 /* ViewController.swift */; }; + B39AD23B229FD14E00F97FA9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B39AD23A229FD14E00F97FA9 /* Assets.xcassets */; }; + B39AD23E229FD14E00F97FA9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B39AD23C229FD14E00F97FA9 /* Main.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B39AD233229FD14D00F97FA9 /* ExtensionApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExtensionApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B39AD236229FD14D00F97FA9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B39AD238229FD14D00F97FA9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + B39AD23A229FD14E00F97FA9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B39AD23D229FD14E00F97FA9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B39AD23F229FD14E00F97FA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B39AD240229FD14E00F97FA9 /* ExtensionApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExtensionApp.entitlements; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B39AD230229FD14D00F97FA9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B39AD22A229FD14D00F97FA9 = { + isa = PBXGroup; + children = ( + B39AD235229FD14D00F97FA9 /* ExtensionApp */, + B39AD234229FD14D00F97FA9 /* Products */, + ); + sourceTree = ""; + }; + B39AD234229FD14D00F97FA9 /* Products */ = { + isa = PBXGroup; + children = ( + B39AD233229FD14D00F97FA9 /* ExtensionApp.app */, + ); + name = Products; + sourceTree = ""; + }; + B39AD235229FD14D00F97FA9 /* ExtensionApp */ = { + isa = PBXGroup; + children = ( + B39AD236229FD14D00F97FA9 /* AppDelegate.swift */, + B39AD238229FD14D00F97FA9 /* ViewController.swift */, + B39AD23A229FD14E00F97FA9 /* Assets.xcassets */, + B39AD23C229FD14E00F97FA9 /* Main.storyboard */, + B39AD23F229FD14E00F97FA9 /* Info.plist */, + B39AD240229FD14E00F97FA9 /* ExtensionApp.entitlements */, + ); + path = ExtensionApp; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B39AD232229FD14D00F97FA9 /* ExtensionApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = B39AD243229FD14E00F97FA9 /* Build configuration list for PBXNativeTarget "ExtensionApp" */; + buildPhases = ( + B39AD22F229FD14D00F97FA9 /* Sources */, + B39AD230229FD14D00F97FA9 /* Frameworks */, + B39AD231229FD14D00F97FA9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ExtensionApp; + productName = ExtensionApp; + productReference = B39AD233229FD14D00F97FA9 /* ExtensionApp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B39AD22B229FD14D00F97FA9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1020; + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "Michal Rentka"; + TargetAttributes = { + B39AD232229FD14D00F97FA9 = { + CreatedOnToolsVersion = 10.2.1; + }; + }; + }; + buildConfigurationList = B39AD22E229FD14D00F97FA9 /* Build configuration list for PBXProject "ExtensionApp" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B39AD22A229FD14D00F97FA9; + productRefGroup = B39AD234229FD14D00F97FA9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B39AD232229FD14D00F97FA9 /* ExtensionApp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B39AD231229FD14D00F97FA9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B39AD23B229FD14E00F97FA9 /* Assets.xcassets in Resources */, + B39AD23E229FD14E00F97FA9 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B39AD22F229FD14D00F97FA9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B39AD239229FD14D00F97FA9 /* ViewController.swift in Sources */, + B39AD237229FD14D00F97FA9 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B39AD23C229FD14E00F97FA9 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B39AD23D229FD14E00F97FA9 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B39AD241229FD14E00F97FA9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B39AD242229FD14E00F97FA9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + B39AD244229FD14E00F97FA9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ExtensionApp/ExtensionApp.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 8AQ7YSWBDJ; + INFOPLIST_FILE = ExtensionApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.michalrentka.ExtensionApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + B39AD245229FD14E00F97FA9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ExtensionApp/ExtensionApp.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 8AQ7YSWBDJ; + INFOPLIST_FILE = ExtensionApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.michalrentka.ExtensionApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B39AD22E229FD14D00F97FA9 /* Build configuration list for PBXProject "ExtensionApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B39AD241229FD14E00F97FA9 /* Debug */, + B39AD242229FD14E00F97FA9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B39AD243229FD14E00F97FA9 /* Build configuration list for PBXNativeTarget "ExtensionApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B39AD244229FD14E00F97FA9 /* Debug */, + B39AD245229FD14E00F97FA9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B39AD22B229FD14D00F97FA9 /* Project object */; +} diff --git a/ExtensionApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ExtensionApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..bb032a6 --- /dev/null +++ b/ExtensionApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ExtensionApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ExtensionApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ExtensionApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ExtensionApp.xcodeproj/xcuserdata/michalrentka.xcuserdatad/xcschemes/xcschememanagement.plist b/ExtensionApp.xcodeproj/xcuserdata/michalrentka.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..d5dbea4 --- /dev/null +++ b/ExtensionApp.xcodeproj/xcuserdata/michalrentka.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + ExtensionApp.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/ExtensionApp/AppDelegate.swift b/ExtensionApp/AppDelegate.swift new file mode 100644 index 0000000..7e061a1 --- /dev/null +++ b/ExtensionApp/AppDelegate.swift @@ -0,0 +1,26 @@ +// +// AppDelegate.swift +// ExtensionApp +// +// Created by Michal Rentka on 30/05/2019. +// Copyright © 2019 Michal Rentka. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } + + +} + diff --git a/ExtensionApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ExtensionApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/ExtensionApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ExtensionApp/Assets.xcassets/Contents.json b/ExtensionApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/ExtensionApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ExtensionApp/Base.lproj/Main.storyboard b/ExtensionApp/Base.lproj/Main.storyboard new file mode 100644 index 0000000..4cbb3df --- /dev/null +++ b/ExtensionApp/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExtensionApp/ExtensionApp.entitlements b/ExtensionApp/ExtensionApp.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/ExtensionApp/ExtensionApp.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/ExtensionApp/Info.plist b/ExtensionApp/Info.plist new file mode 100644 index 0000000..2300336 --- /dev/null +++ b/ExtensionApp/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2019 Michal Rentka. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/ExtensionApp/ViewController.swift b/ExtensionApp/ViewController.swift new file mode 100644 index 0000000..de7f629 --- /dev/null +++ b/ExtensionApp/ViewController.swift @@ -0,0 +1,27 @@ +// +// ViewController.swift +// ExtensionApp +// +// Created by Michal Rentka on 30/05/2019. +// Copyright © 2019 Michal Rentka. All rights reserved. +// + +import Cocoa + +class ViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + +} + diff --git a/SafariExtension/Base.lproj/SafariExtensionViewController.xib b/SafariExtension/Base.lproj/SafariExtensionViewController.xib new file mode 100644 index 0000000..10ae8b0 --- /dev/null +++ b/SafariExtension/Base.lproj/SafariExtensionViewController.xib @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SafariExtension/Info.plist b/SafariExtension/Info.plist new file mode 100644 index 0000000..41b9edb --- /dev/null +++ b/SafariExtension/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + SafariExtension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSExtension + + NSExtensionPointIdentifier + com.apple.Safari.extension + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).SafariExtensionHandler + SFSafariContentScript + + + Script + script.js + + + SFSafariToolbarItem + + Action + Command + Identifier + Button + Image + ToolbarItemIcon.pdf + Label + Your Button + + SFSafariWebsiteAccess + + Allowed Domains + + *.webkit.org + + Level + Some + + + NSHumanReadableCopyright + Copyright © 2019 Michal Rentka. All rights reserved. + NSHumanReadableDescription + This is a Safari Extension. You should tell us what your extension does here. + + diff --git a/SafariExtension/SafariExtension.entitlements b/SafariExtension/SafariExtension.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/SafariExtension/SafariExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/SafariExtension/SafariExtensionHandler.swift b/SafariExtension/SafariExtensionHandler.swift new file mode 100644 index 0000000..da54530 --- /dev/null +++ b/SafariExtension/SafariExtensionHandler.swift @@ -0,0 +1,61 @@ +// +// SafariExtensionHandler.swift +// SafariExtension +// +// Created by Michal Rentka on 30/05/2019. +// Copyright © 2019 Michal Rentka. All rights reserved. +// + +import SafariServices + +struct ApiResponseData: Decodable { + let userId: Int + let id: Int + let title: String + let completed: Bool +} + +class SafariExtensionHandler: SFSafariExtensionHandler { + + // MARK: - Actions + + private func loadData(completed: @escaping (Int, String?) -> Void) { + let url = URL(string: "https://jsonplaceholder.typicode.com/todos/1")! + + let task = URLSession.shared.dataTask(with: url) { data, response, error in + guard let httpResponse = response as? HTTPURLResponse else { return } + let responseData = data.flatMap({ try? JSONDecoder().decode(ApiResponseData.self, from: $0) }) + completed(httpResponse.statusCode, responseData?.title) + } + + task.resume() + } + + // MARK: - SFSafariExtensionHandler + + override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) { + switch messageName { + case "loadData": + self.loadData { code, title in + page.dispatchMessageToScript(withName: "loadedData", userInfo: ["code": code, + "title": title ?? ""]) + } + default: break + } + } + + override func toolbarItemClicked(in window: SFSafariWindow) { + // This method will be called when your toolbar item is clicked. + NSLog("The extension's toolbar item was clicked") + } + + override func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) { + // This is called when Safari's state changed in some way that would require the extension's toolbar item to be validated again. + validationHandler(true, "") + } + + override func popoverViewController() -> SFSafariExtensionViewController { + return SafariExtensionViewController.shared + } + +} diff --git a/SafariExtension/SafariExtensionViewController.swift b/SafariExtension/SafariExtensionViewController.swift new file mode 100644 index 0000000..b9e271d --- /dev/null +++ b/SafariExtension/SafariExtensionViewController.swift @@ -0,0 +1,19 @@ +// +// SafariExtensionViewController.swift +// SafariExtension +// +// Created by Michal Rentka on 30/05/2019. +// Copyright © 2019 Michal Rentka. All rights reserved. +// + +import SafariServices + +class SafariExtensionViewController: SFSafariExtensionViewController { + + static let shared: SafariExtensionViewController = { + let shared = SafariExtensionViewController() + shared.preferredContentSize = NSSize(width:320, height:240) + return shared + }() + +} diff --git a/SafariExtension/ToolbarItemIcon.pdf b/SafariExtension/ToolbarItemIcon.pdf new file mode 100644 index 0000000..36d749c Binary files /dev/null and b/SafariExtension/ToolbarItemIcon.pdf differ diff --git a/SafariExtension/script.js b/SafariExtension/script.js new file mode 100644 index 0000000..34f7e35 --- /dev/null +++ b/SafariExtension/script.js @@ -0,0 +1,3 @@ +document.addEventListener("DOMContentLoaded", function(event) { + safari.extension.dispatchMessage("Hello World!"); +});