Skip to content

Social.framework (& ShareKit.framework)

Aditya Vaidyam edited this page Sep 22, 2017 · 1 revision

While Social.framework can be used to post to different social media, it can also be used to quickly create share extensions using SLComposeServiceViewController without needing to actually be social media related. Using the private API allows flexibility to do what you want with a pretty standard but well built UI.

Note: NSSharingComposeViewController is an identical twin of SLComposeServiceViewController found in PrivateFrameworks/ShareKit.framework.

// @import Social
/*
@interface SLComposeServiceViewController : NSViewController <NSTextViewDelegate>

@property (readonly) NSTextView *textView;
@property (readonly) NSString *contentText;
@property (copy) NSString *placeholder;
@property (strong) NSNumber *charactersRemaining;

- (void)presentationAnimationDidFinish;

- (void)didSelectPost;
- (void)didSelectCancel;
- (void)cancel;

- (BOOL)isContentValid;
- (void)validateContent;

@end
*/

@interface SLComposeServiceViewController (Private)

+ (id)keyPathsForValuesAffectingImage;

@property NSUInteger mainItemIndex;
@property BOOL timedOutComputingThumbnail;
@property (readonly, retain) id selectedAccount;
@property (readonly) SLXShareLocationController *locationController;
@property (readonly) NSPopUpButton *audiencePopUpButton;
@property (readonly) NSPopUpButton *accountsPopUpButton;
@property (readonly) NSTextView *messageTextView;
@property (readonly) NSButton *sendButton;
@property (readonly) NSButton *cancelButton;
@property BOOL showsCompletionPopUpInMessage;
@property (readonly) CGRect imageContentFrame;
@property (readonly) CGRect imageFrame;
@property (readonly) NSImage *decoratedImage;
@property (readonly) NSImage *image;
@property (readonly) NSImageView *imageView;
@property BOOL showsAudiencePopUp;
@property BOOL showsAccountsPopUp;
@property BOOL showsProgressIndicator;
@property BOOL showsLocationPin;
@property BOOL showsRemainingCharactersCounter;
@property (retain) NSString *message;
@property NSInteger textureStyle;
@property (readonly) NSString *contentText;
@property (getter=isPreviewImageVisible) BOOL previewImageVisible;
@property NSImage *previewImage;
@property CALayer *previewImageLayer;
@property NSString *placeholderText;

- (id)displayNameForLocation:(id)arg1;
- (id)locationController:(id)arg1 displayNameForLocation:(id)arg2;
- (void)stopUpdatingLocation;
- (void)startUpdatingLocation;
- (BOOL)supportsLocation;

- (void)contentDidChange;
- (void)_send:(id)arg1;
- (void)_cancel:(id)arg1;

- (CGRect)imageContentFrameForItemProvider:(id)arg1;
- (CGRect)imageFrameForItemProvider:(id)arg1;
- (id)imageForItemProvider:(id)arg1;

- (void)audiencePopUpChanged:(id)arg1;
- (void)accountsPopUpChanged:(id)arg1;
- (void)adjustAudiencePopUpFrame;
- (void)adjustAccountsPopUpFrame;
- (void)adjustTextFrame;
- (void)_updateSpaceBetweenImageAndPopUp;
- (void)displayErrorString:(NSString *)errorString;
- (void)_makeUIBusy:(BOOL)busy showsProgressIndicator:(BOOL)showIndicator;

- (id)mainItem;
- (BOOL)wantsPaperclip;
- (void)_validateUI;
- (void)_updateCharactersCountField;
- (NSUInteger)_alertCharacterThreshold;
- (BOOL)_canSendMediaWithNoText;
- (void)_validateSendButton;
- (void)_setupUIWithInputItems;
- (void)_messageTextViewDidScroll:(id)arg1;
- (void)activateFirstResponder;
- (BOOL)_areAttachmentsReady;

@end

///

@interface SLXShareLocationController : NSViewController

+ (id)keyPathsForValuesAffectingCurrentLocationDisplayName;
+ (id)keyPathsForValuesAffectingCurrentLocation;

@property (retain) id <SLXShareLocationControllerDelegate> delegate;
@property (copy) id /*block*/ updateLocationsBlock;
@property NSInteger currentLocationIndex;
@property (readonly) id currentLocation;
@property (copy) NSArray *locations;
@property NSInteger status;
@property BOOL enabled;

- (void)locationPopupChanged:(id)arg1;
- (void)locationClicked:(id)arg1;
- (id)currentLocationDisplayName;
- (void)updateFailedAndIsUnavailable:(BOOL)arg1;
- (void)_showRemoveImage;
- (void)_showAndUpdateArrowImage;
- (void)_removeTrackingAreaForButton;
- (void)_addTrackingAreaForButton;
- (void)_updateLocationsPopupWidth;
- (void)_updateLocationsPopup;
- (id)_titleForLocation:(id)arg1;
- (void)invalidate;
- (id)initWithParentView:(id)arg1;
- (BOOL)isTextDirectionRTL;

@end

In addition, an observation about Messages.app's share extensions: there are two, the Reply and the Share extension, with very similar binaries but different Info.plist extension settings (a diff is provided):

<key>NSExtensionPrincipalClass</key>
<string>NSSharingContainerViewController</string>
<key>NSSharingAccountConfigurationViewControllerClass</key>
<string>MessagesAccountConfigurationController</string>
<key>NSSharingRecentIconFile</key>
<string>RecentIcon</string>
<key>NSSharingTitle</key>
<string>Message &lt;SenderName&gt;</string>
<key>NSSharingViewControllerClass</key>
<string>MessagesViewController</string>
<key>com.apple.showsInExtensionsManager</key>
<false/>
<key>NSSharingNotificationCenterIconFile</key>
<string>NC-icon</string>
<key>NSExtensionAttributes</key>
<dict>
    <key>NSSharingShowsInNotificationCenter</key>
    <true/>
</dict>
Clone this wiki locally