From ae6ae8ee814f08a3f28fb740079c59cf1eb54e94 Mon Sep 17 00:00:00 2001 From: Victor Wang Date: Sat, 2 Jul 2016 10:51:15 +0200 Subject: [PATCH] Add Xcode Source Editor Extension target --- .../EditorPlusExtension.entitlements | 8 + EditorPlusExtension/Info.plist | 51 ++++++ EditorPlusExtension/SourceEditorCommand.swift | 20 +++ .../SourceEditorExtension.swift | 27 +++ XcodeEditorPlus.xcodeproj/project.pbxproj | 163 ++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 EditorPlusExtension/EditorPlusExtension.entitlements create mode 100644 EditorPlusExtension/Info.plist create mode 100644 EditorPlusExtension/SourceEditorCommand.swift create mode 100644 EditorPlusExtension/SourceEditorExtension.swift diff --git a/EditorPlusExtension/EditorPlusExtension.entitlements b/EditorPlusExtension/EditorPlusExtension.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/EditorPlusExtension/EditorPlusExtension.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/EditorPlusExtension/Info.plist b/EditorPlusExtension/Info.plist new file mode 100644 index 0000000..c80c08e --- /dev/null +++ b/EditorPlusExtension/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + EditorPlusExtension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSExtension + + NSExtensionAttributes + + XCSourceEditorCommandDefinitions + + + XCSourceEditorCommandClassName + $(PRODUCT_MODULE_NAME).SourceEditorCommand + XCSourceEditorCommandIdentifier + me.allblue.XcodeEditorPlus.EditorPlusExtension.SourceEditorCommand + XCSourceEditorCommandName + Source Editor Command + + + XCSourceEditorExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).SourceEditorExtension + + NSExtensionPointIdentifier + com.apple.dt.Xcode.extension.source-editor + + NSHumanReadableCopyright + Copyright © 2016 Victor Wang. All rights reserved. + + diff --git a/EditorPlusExtension/SourceEditorCommand.swift b/EditorPlusExtension/SourceEditorCommand.swift new file mode 100644 index 0000000..7a9b010 --- /dev/null +++ b/EditorPlusExtension/SourceEditorCommand.swift @@ -0,0 +1,20 @@ +// +// SourceEditorCommand.swift +// EditorPlusExtension +// +// Created by Victor WANG on 02/07/2016. +// Copyright © 2016 Victor Wang. All rights reserved. +// + +import Foundation +import XcodeKit + +class SourceEditorCommand: NSObject, XCSourceEditorCommand { + + func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: (NSError?) -> Void ) -> Void { + // Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure. + + completionHandler(nil) + } + +} diff --git a/EditorPlusExtension/SourceEditorExtension.swift b/EditorPlusExtension/SourceEditorExtension.swift new file mode 100644 index 0000000..4c47e98 --- /dev/null +++ b/EditorPlusExtension/SourceEditorExtension.swift @@ -0,0 +1,27 @@ +// +// SourceEditorExtension.swift +// EditorPlusExtension +// +// Created by Victor WANG on 02/07/2016. +// Copyright © 2016 Victor Wang. All rights reserved. +// + +import Foundation +import XcodeKit + +class SourceEditorExtension: NSObject, XCSourceEditorExtension { + + /* + func extensionDidFinishLaunching() { + // If your extension needs to do any work at launch, implement this optional method. + } + */ + + /* + var commandDefinitions: [[XCSourceEditorCommandDefinitionKey: AnyObject]] { + // If your extension needs to return a collection of command definitions that differs from those in its Info.plist, implement this optional property getter. + return [] + } + */ + +} diff --git a/XcodeEditorPlus.xcodeproj/project.pbxproj b/XcodeEditorPlus.xcodeproj/project.pbxproj index bd17634..a3776db 100644 --- a/XcodeEditorPlus.xcodeproj/project.pbxproj +++ b/XcodeEditorPlus.xcodeproj/project.pbxproj @@ -10,14 +10,48 @@ 3534EED91D27B73E00CFF7BA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3534EED81D27B73E00CFF7BA /* AppDelegate.swift */; }; 3534EEDB1D27B73E00CFF7BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3534EEDA1D27B73E00CFF7BA /* Assets.xcassets */; }; 3534EEDE1D27B73E00CFF7BA /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3534EEDC1D27B73E00CFF7BA /* MainMenu.xib */; }; + 3534EEEC1D27B7C600CFF7BA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3534EEEB1D27B7C600CFF7BA /* Cocoa.framework */; }; + 3534EEF11D27B7C600CFF7BA /* SourceEditorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3534EEF01D27B7C600CFF7BA /* SourceEditorExtension.swift */; }; + 3534EEF31D27B7C600CFF7BA /* SourceEditorCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3534EEF21D27B7C600CFF7BA /* SourceEditorCommand.swift */; }; + 3534EEF71D27B7C600CFF7BA /* EditorPlusExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 3534EEE91D27B7C600CFF7BA /* EditorPlusExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 3534EEF51D27B7C600CFF7BA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3534EECD1D27B73E00CFF7BA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3534EEE81D27B7C600CFF7BA; + remoteInfo = EditorPlusExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 3534EEFB1D27B7C600CFF7BA /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 3534EEF71D27B7C600CFF7BA /* EditorPlusExtension.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 3534EED51D27B73E00CFF7BA /* XcodeEditorPlus.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XcodeEditorPlus.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3534EED81D27B73E00CFF7BA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 3534EEDA1D27B73E00CFF7BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 3534EEDD1D27B73E00CFF7BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 3534EEDF1D27B73E00CFF7BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3534EEE91D27B7C600CFF7BA /* EditorPlusExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = EditorPlusExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 3534EEEB1D27B7C600CFF7BA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 3534EEEF1D27B7C600CFF7BA /* EditorPlusExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = EditorPlusExtension.entitlements; sourceTree = ""; }; + 3534EEF01D27B7C600CFF7BA /* SourceEditorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorExtension.swift; sourceTree = ""; }; + 3534EEF21D27B7C600CFF7BA /* SourceEditorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorCommand.swift; sourceTree = ""; }; + 3534EEF41D27B7C600CFF7BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -28,6 +62,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3534EEE61D27B7C600CFF7BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3534EEEC1D27B7C600CFF7BA /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -35,6 +77,8 @@ isa = PBXGroup; children = ( 3534EED71D27B73E00CFF7BA /* XcodeEditorPlus */, + 3534EEED1D27B7C600CFF7BA /* EditorPlusExtension */, + 3534EEEA1D27B7C600CFF7BA /* Frameworks */, 3534EED61D27B73E00CFF7BA /* Products */, ); sourceTree = ""; @@ -43,6 +87,7 @@ isa = PBXGroup; children = ( 3534EED51D27B73E00CFF7BA /* XcodeEditorPlus.app */, + 3534EEE91D27B7C600CFF7BA /* EditorPlusExtension.appex */, ); name = Products; sourceTree = ""; @@ -58,6 +103,33 @@ path = XcodeEditorPlus; sourceTree = ""; }; + 3534EEEA1D27B7C600CFF7BA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3534EEEB1D27B7C600CFF7BA /* Cocoa.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 3534EEED1D27B7C600CFF7BA /* EditorPlusExtension */ = { + isa = PBXGroup; + children = ( + 3534EEF01D27B7C600CFF7BA /* SourceEditorExtension.swift */, + 3534EEF21D27B7C600CFF7BA /* SourceEditorCommand.swift */, + 3534EEF41D27B7C600CFF7BA /* Info.plist */, + 3534EEEE1D27B7C600CFF7BA /* Supporting Files */, + ); + path = EditorPlusExtension; + sourceTree = ""; + }; + 3534EEEE1D27B7C600CFF7BA /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 3534EEEF1D27B7C600CFF7BA /* EditorPlusExtension.entitlements */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -68,16 +140,35 @@ 3534EED11D27B73E00CFF7BA /* Sources */, 3534EED21D27B73E00CFF7BA /* Frameworks */, 3534EED31D27B73E00CFF7BA /* Resources */, + 3534EEFB1D27B7C600CFF7BA /* Embed App Extensions */, ); buildRules = ( ); dependencies = ( + 3534EEF61D27B7C600CFF7BA /* PBXTargetDependency */, ); name = XcodeEditorPlus; productName = XcodeEditorPlus; productReference = 3534EED51D27B73E00CFF7BA /* XcodeEditorPlus.app */; productType = "com.apple.product-type.application"; }; + 3534EEE81D27B7C600CFF7BA /* EditorPlusExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3534EEFA1D27B7C600CFF7BA /* Build configuration list for PBXNativeTarget "EditorPlusExtension" */; + buildPhases = ( + 3534EEE51D27B7C600CFF7BA /* Sources */, + 3534EEE61D27B7C600CFF7BA /* Frameworks */, + 3534EEE71D27B7C600CFF7BA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = EditorPlusExtension; + productName = EditorPlusExtension; + productReference = 3534EEE91D27B7C600CFF7BA /* EditorPlusExtension.appex */; + productType = "com.apple.product-type.xcode-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -94,6 +185,12 @@ DevelopmentTeamName = "ShengJia WANG (Personal Team)"; ProvisioningStyle = Automatic; }; + 3534EEE81D27B7C600CFF7BA = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = MH3P7R7924; + DevelopmentTeamName = "ShengJia WANG (Personal Team)"; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 3534EED01D27B73E00CFF7BA /* Build configuration list for PBXProject "XcodeEditorPlus" */; @@ -110,6 +207,7 @@ projectRoot = ""; targets = ( 3534EED41D27B73E00CFF7BA /* XcodeEditorPlus */, + 3534EEE81D27B7C600CFF7BA /* EditorPlusExtension */, ); }; /* End PBXProject section */ @@ -124,6 +222,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3534EEE71D27B7C600CFF7BA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -135,8 +240,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3534EEE51D27B7C600CFF7BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3534EEF11D27B7C600CFF7BA /* SourceEditorExtension.swift in Sources */, + 3534EEF31D27B7C600CFF7BA /* SourceEditorCommand.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 3534EEF61D27B7C600CFF7BA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3534EEE81D27B7C600CFF7BA /* EditorPlusExtension */; + targetProxy = 3534EEF51D27B7C600CFF7BA /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 3534EEDC1D27B73E00CFF7BA /* MainMenu.xib */ = { isa = PBXVariantGroup; @@ -238,6 +360,7 @@ 3534EEE31D27B73E00CFF7BA /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = XcodeEditorPlus/Info.plist; @@ -251,6 +374,7 @@ 3534EEE41D27B73E00CFF7BA /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = XcodeEditorPlus/Info.plist; @@ -261,6 +385,36 @@ }; name = Release; }; + 3534EEF81D27B7C600CFF7BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = EditorPlusExtension/EditorPlusExtension.entitlements; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = EditorPlusExtension/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = me.allblue.XcodeEditorPlus.EditorPlusExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 3534EEF91D27B7C600CFF7BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = EditorPlusExtension/EditorPlusExtension.entitlements; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = EditorPlusExtension/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = me.allblue.XcodeEditorPlus.EditorPlusExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -280,6 +434,15 @@ 3534EEE41D27B73E00CFF7BA /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3534EEFA1D27B7C600CFF7BA /* Build configuration list for PBXNativeTarget "EditorPlusExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3534EEF81D27B7C600CFF7BA /* Debug */, + 3534EEF91D27B7C600CFF7BA /* Release */, + ); + defaultConfigurationIsVisible = 0; }; /* End XCConfigurationList section */ };