Skip to content

Commit

Permalink
Add Xcode Source Editor Extension target
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshengjia committed Jul 2, 2016
1 parent a9f4521 commit ae6ae8e
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 0 deletions.
8 changes: 8 additions & 0 deletions EditorPlusExtension/EditorPlusExtension.entitlements
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
51 changes: 51 additions & 0 deletions EditorPlusExtension/Info.plist
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>EditorPlusExtension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>XCSourceEditorCommandDefinitions</key>
<array>
<dict>
<key>XCSourceEditorCommandClassName</key>
<string>$(PRODUCT_MODULE_NAME).SourceEditorCommand</string>
<key>XCSourceEditorCommandIdentifier</key>
<string>me.allblue.XcodeEditorPlus.EditorPlusExtension.SourceEditorCommand</string>
<key>XCSourceEditorCommandName</key>
<string>Source Editor Command</string>
</dict>
</array>
<key>XCSourceEditorExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SourceEditorExtension</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.dt.Xcode.extension.source-editor</string>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Victor Wang. All rights reserved.</string>
</dict>
</plist>
20 changes: 20 additions & 0 deletions 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)
}

}
27 changes: 27 additions & 0 deletions 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 []
}
*/

}
163 changes: 163 additions & 0 deletions XcodeEditorPlus.xcodeproj/project.pbxproj
Expand Up @@ -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 = "<group>"; };
3534EEDA1D27B73E00CFF7BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3534EEDD1D27B73E00CFF7BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
3534EEDF1D27B73E00CFF7BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
3534EEF01D27B7C600CFF7BA /* SourceEditorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorExtension.swift; sourceTree = "<group>"; };
3534EEF21D27B7C600CFF7BA /* SourceEditorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorCommand.swift; sourceTree = "<group>"; };
3534EEF41D27B7C600CFF7BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -28,13 +62,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
3534EEE61D27B7C600CFF7BA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3534EEEC1D27B7C600CFF7BA /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3534EECC1D27B73E00CFF7BA = {
isa = PBXGroup;
children = (
3534EED71D27B73E00CFF7BA /* XcodeEditorPlus */,
3534EEED1D27B7C600CFF7BA /* EditorPlusExtension */,
3534EEEA1D27B7C600CFF7BA /* Frameworks */,
3534EED61D27B73E00CFF7BA /* Products */,
);
sourceTree = "<group>";
Expand All @@ -43,6 +87,7 @@
isa = PBXGroup;
children = (
3534EED51D27B73E00CFF7BA /* XcodeEditorPlus.app */,
3534EEE91D27B7C600CFF7BA /* EditorPlusExtension.appex */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -58,6 +103,33 @@
path = XcodeEditorPlus;
sourceTree = "<group>";
};
3534EEEA1D27B7C600CFF7BA /* Frameworks */ = {
isa = PBXGroup;
children = (
3534EEEB1D27B7C600CFF7BA /* Cocoa.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
3534EEED1D27B7C600CFF7BA /* EditorPlusExtension */ = {
isa = PBXGroup;
children = (
3534EEF01D27B7C600CFF7BA /* SourceEditorExtension.swift */,
3534EEF21D27B7C600CFF7BA /* SourceEditorCommand.swift */,
3534EEF41D27B7C600CFF7BA /* Info.plist */,
3534EEEE1D27B7C600CFF7BA /* Supporting Files */,
);
path = EditorPlusExtension;
sourceTree = "<group>";
};
3534EEEE1D27B7C600CFF7BA /* Supporting Files */ = {
isa = PBXGroup;
children = (
3534EEEF1D27B7C600CFF7BA /* EditorPlusExtension.entitlements */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -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 */
Expand All @@ -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" */;
Expand All @@ -110,6 +207,7 @@
projectRoot = "";
targets = (
3534EED41D27B73E00CFF7BA /* XcodeEditorPlus */,
3534EEE81D27B7C600CFF7BA /* EditorPlusExtension */,
);
};
/* End PBXProject section */
Expand All @@ -124,6 +222,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
3534EEE71D27B7C600CFF7BA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 */
Expand All @@ -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 */
};
Expand Down

0 comments on commit ae6ae8e

Please sign in to comment.