Browse Source

Add Share Extension

HonorLee 8 years ago
parent
commit
4de3102635

+ 26 - 0
ShareSupport/Base.lproj/MainInterface.storyboard

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="j1y-V4-xli">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
+    </dependencies>
+    <scenes>
+        <!--Share View Controller-->
+        <scene sceneID="ceB-am-kn3">
+            <objects>
+                <viewController id="j1y-V4-xli" customClass="ShareViewController" customModuleProvider="" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="8bI-gs-bmD"/>
+                        <viewControllerLayoutGuide type="bottom" id="d5i-Ba-RvD"/>
+                    </layoutGuides>
+                    <view key="view" opaque="NO" contentMode="scaleToFill" id="wbc-yd-nQP">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="CEy-Cv-SGf" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="539" y="97"/>
+        </scene>
+    </scenes>
+</document>

+ 38 - 0
ShareSupport/Info.plist

@@ -0,0 +1,38 @@
+<?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>ShareSupport</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>NSExtension</key>
+	<dict>
+		<key>NSExtensionAttributes</key>
+		<dict>
+			<key>NSExtensionActivationRule</key>
+			<string>TRUEPREDICATE</string>
+		</dict>
+		<key>NSExtensionMainStoryboard</key>
+		<string>MainInterface</string>
+		<key>NSExtensionPointIdentifier</key>
+		<string>com.apple.share-services</string>
+	</dict>
+</dict>
+</plist>

+ 10 - 0
ShareSupport/ShareSupport.entitlements

@@ -0,0 +1,10 @@
+<?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.application-groups</key>
+	<array>
+		<string>group.honorlee.TumblrDownloader</string>
+	</array>
+</dict>
+</plist>

+ 14 - 0
ShareSupport/ShareViewController.h

@@ -0,0 +1,14 @@
+//
+//  ShareViewController.h
+//  ShareSupport
+//
+//  Created by HonorLee on 16/1/13.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <Social/Social.h>
+
+@interface ShareViewController : SLComposeServiceViewController
+
+@end

+ 34 - 0
ShareSupport/ShareViewController.m

@@ -0,0 +1,34 @@
+//
+//  ShareViewController.m
+//  ShareSupport
+//
+//  Created by HonorLee on 16/1/13.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import "ShareViewController.h"
+
+@interface ShareViewController ()
+
+@end
+
+@implementation ShareViewController
+
+- (BOOL)isContentValid {
+    // Do validation of contentText and/or NSExtensionContext attachments here
+    return YES;
+}
+
+- (void)didSelectPost {
+    // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
+    
+    // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
+    [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
+}
+
+- (NSArray *)configurationItems {
+    // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
+    return @[];
+}
+
+@end

+ 172 - 0
TumblrDownloader.xcodeproj/project.pbxproj

@@ -14,8 +14,35 @@
 		D36ACDD21C44D07E00B2C7CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D36ACDD11C44D07E00B2C7CF /* Assets.xcassets */; };
 		D36ACDD51C44D07E00B2C7CF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D36ACDD31C44D07E00B2C7CF /* LaunchScreen.storyboard */; };
 		D36ACDDD1C44D24B00B2C7CF /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = D36ACDDC1C44D24B00B2C7CF /* README.md */; };
+		D386B1241C46991400D7E0C5 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D386B1231C46991400D7E0C5 /* ShareViewController.m */; };
+		D386B1271C46991400D7E0C5 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D386B1251C46991400D7E0C5 /* MainInterface.storyboard */; };
+		D386B12B1C46991400D7E0C5 /* ShareSupport.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = D386B1201C46991400D7E0C5 /* ShareSupport.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXContainerItemProxy section */
+		D386B1291C46991400D7E0C5 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = D36ACDBA1C44D07E00B2C7CF /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D386B11F1C46991400D7E0C5;
+			remoteInfo = ShareSupport;
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		D386B12F1C46991400D7E0C5 /* Embed App Extensions */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "";
+			dstSubfolderSpec = 13;
+			files = (
+				D386B12B1C46991400D7E0C5 /* ShareSupport.appex in Embed App Extensions */,
+			);
+			name = "Embed App Extensions";
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
 		D36ACDC21C44D07E00B2C7CF /* TumblrDownloader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TumblrDownloader.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		D36ACDC61C44D07E00B2C7CF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -28,6 +55,13 @@
 		D36ACDD41C44D07E00B2C7CF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		D36ACDD61C44D07E00B2C7CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		D36ACDDC1C44D24B00B2C7CF /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
+		D386B1201C46991400D7E0C5 /* ShareSupport.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareSupport.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+		D386B1221C46991400D7E0C5 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareViewController.h; sourceTree = "<group>"; };
+		D386B1231C46991400D7E0C5 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = "<group>"; };
+		D386B1261C46991400D7E0C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
+		D386B1281C46991400D7E0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		D386B1301C469FDB00D7E0C5 /* TumblrDownloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = TumblrDownloader.entitlements; sourceTree = "<group>"; };
+		D386B1311C46A0F900D7E0C5 /* ShareSupport.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ShareSupport.entitlements; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -38,6 +72,13 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D386B11D1C46991400D7E0C5 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
@@ -46,6 +87,7 @@
 			children = (
 				D36ACDDC1C44D24B00B2C7CF /* README.md */,
 				D36ACDC41C44D07E00B2C7CF /* TumblrDownloader */,
+				D386B1211C46991400D7E0C5 /* ShareSupport */,
 				D36ACDC31C44D07E00B2C7CF /* Products */,
 			);
 			sourceTree = "<group>";
@@ -54,6 +96,7 @@
 			isa = PBXGroup;
 			children = (
 				D36ACDC21C44D07E00B2C7CF /* TumblrDownloader.app */,
+				D386B1201C46991400D7E0C5 /* ShareSupport.appex */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -61,6 +104,7 @@
 		D36ACDC41C44D07E00B2C7CF /* TumblrDownloader */ = {
 			isa = PBXGroup;
 			children = (
+				D386B1301C469FDB00D7E0C5 /* TumblrDownloader.entitlements */,
 				D36ACDC81C44D07E00B2C7CF /* AppDelegate.h */,
 				D36ACDC91C44D07E00B2C7CF /* AppDelegate.m */,
 				D36ACDCB1C44D07E00B2C7CF /* ViewController.h */,
@@ -82,6 +126,18 @@
 			name = "Supporting Files";
 			sourceTree = "<group>";
 		};
+		D386B1211C46991400D7E0C5 /* ShareSupport */ = {
+			isa = PBXGroup;
+			children = (
+				D386B1311C46A0F900D7E0C5 /* ShareSupport.entitlements */,
+				D386B1221C46991400D7E0C5 /* ShareViewController.h */,
+				D386B1231C46991400D7E0C5 /* ShareViewController.m */,
+				D386B1251C46991400D7E0C5 /* MainInterface.storyboard */,
+				D386B1281C46991400D7E0C5 /* Info.plist */,
+			);
+			path = ShareSupport;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -92,16 +148,35 @@
 				D36ACDBE1C44D07E00B2C7CF /* Sources */,
 				D36ACDBF1C44D07E00B2C7CF /* Frameworks */,
 				D36ACDC01C44D07E00B2C7CF /* Resources */,
+				D386B12F1C46991400D7E0C5 /* Embed App Extensions */,
 			);
 			buildRules = (
 			);
 			dependencies = (
+				D386B12A1C46991400D7E0C5 /* PBXTargetDependency */,
 			);
 			name = TumblrDownloader;
 			productName = TumblrDownloader;
 			productReference = D36ACDC21C44D07E00B2C7CF /* TumblrDownloader.app */;
 			productType = "com.apple.product-type.application";
 		};
+		D386B11F1C46991400D7E0C5 /* ShareSupport */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = D386B12E1C46991400D7E0C5 /* Build configuration list for PBXNativeTarget "ShareSupport" */;
+			buildPhases = (
+				D386B11C1C46991400D7E0C5 /* Sources */,
+				D386B11D1C46991400D7E0C5 /* Frameworks */,
+				D386B11E1C46991400D7E0C5 /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = ShareSupport;
+			productName = ShareSupport;
+			productReference = D386B1201C46991400D7E0C5 /* ShareSupport.appex */;
+			productType = "com.apple.product-type.app-extension";
+		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
@@ -114,6 +189,23 @@
 					D36ACDC11C44D07E00B2C7CF = {
 						CreatedOnToolsVersion = 7.2;
 						DevelopmentTeam = G3JVW2BPA6;
+						SystemCapabilities = {
+							com.apple.ApplicationGroups.iOS = {
+								enabled = 1;
+							};
+							com.apple.BackgroundModes = {
+								enabled = 0;
+							};
+						};
+					};
+					D386B11F1C46991400D7E0C5 = {
+						CreatedOnToolsVersion = 7.2;
+						DevelopmentTeam = G3JVW2BPA6;
+						SystemCapabilities = {
+							com.apple.ApplicationGroups.iOS = {
+								enabled = 1;
+							};
+						};
 					};
 				};
 			};
@@ -131,6 +223,7 @@
 			projectRoot = "";
 			targets = (
 				D36ACDC11C44D07E00B2C7CF /* TumblrDownloader */,
+				D386B11F1C46991400D7E0C5 /* ShareSupport */,
 			);
 		};
 /* End PBXProject section */
@@ -146,6 +239,14 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D386B11E1C46991400D7E0C5 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				D386B1271C46991400D7E0C5 /* MainInterface.storyboard in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
@@ -160,8 +261,24 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D386B11C1C46991400D7E0C5 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				D386B1241C46991400D7E0C5 /* ShareViewController.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+		D386B12A1C46991400D7E0C5 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D386B11F1C46991400D7E0C5 /* ShareSupport */;
+			targetProxy = D386B1291C46991400D7E0C5 /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
 /* Begin PBXVariantGroup section */
 		D36ACDCE1C44D07E00B2C7CF /* Main.storyboard */ = {
 			isa = PBXVariantGroup;
@@ -179,6 +296,14 @@
 			name = LaunchScreen.storyboard;
 			sourceTree = "<group>";
 		};
+		D386B1251C46991400D7E0C5 /* MainInterface.storyboard */ = {
+			isa = PBXVariantGroup;
+			children = (
+				D386B1261C46991400D7E0C5 /* Base */,
+			);
+			name = MainInterface.storyboard;
+			sourceTree = "<group>";
+		};
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
@@ -266,10 +391,14 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_ENTITLEMENTS = TumblrDownloader/TumblrDownloader.entitlements;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = TumblrDownloader/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
 			};
 			name = Debug;
 		};
@@ -277,10 +406,44 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_ENTITLEMENTS = TumblrDownloader/TumblrDownloader.entitlements;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = TumblrDownloader/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
+			};
+			name = Release;
+		};
+		D386B12C1C46991400D7E0C5 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_ENTITLEMENTS = ShareSupport/ShareSupport.entitlements;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				INFOPLIST_FILE = ShareSupport/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.ShareSupport;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
+				SKIP_INSTALL = YES;
+			};
+			name = Debug;
+		};
+		D386B12D1C46991400D7E0C5 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_ENTITLEMENTS = ShareSupport/ShareSupport.entitlements;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				INFOPLIST_FILE = ShareSupport/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.ShareSupport;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
+				SKIP_INSTALL = YES;
 			};
 			name = Release;
 		};
@@ -303,6 +466,15 @@
 				D36ACDDB1C44D07E00B2C7CF /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		D386B12E1C46991400D7E0C5 /* Build configuration list for PBXNativeTarget "ShareSupport" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				D386B12C1C46991400D7E0C5 /* Debug */,
+				D386B12D1C46991400D7E0C5 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
 		};
 /* End XCConfigurationList section */
 	};

+ 10 - 0
TumblrDownloader.xcodeproj/xcuserdata/HonorLee.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -4,6 +4,11 @@
 <dict>
 	<key>SchemeUserState</key>
 	<dict>
+		<key>ShareSupport.xcscheme</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>1</integer>
+		</dict>
 		<key>TumblrDownloader.xcscheme</key>
 		<dict>
 			<key>orderHint</key>
@@ -17,6 +22,11 @@
 			<key>primary</key>
 			<true/>
 		</dict>
+		<key>D386B11F1C46991400D7E0C5</key>
+		<dict>
+			<key>primary</key>
+			<true/>
+		</dict>
 	</dict>
 </dict>
 </plist>

+ 10 - 0
TumblrDownloader/TumblrDownloader.entitlements

@@ -0,0 +1,10 @@
+<?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.application-groups</key>
+	<array>
+		<string>group.honorlee.TumblrDownloader</string>
+	</array>
+</dict>
+</plist>