From 62ac3ea117fa7728dbf96a7f96fe8bdf1d00d5e4 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sat, 18 Oct 2025 17:09:34 +0100 Subject: [PATCH] added imessage app, async is hardv2 --- StickerSlack.xcodeproj/project.pbxproj | 198 ++++++++++++++++++ StickerSlack/Emoji/Emoji.swift | 5 + StickerSlack/EmojiHoarder.swift | 20 +- .../Assets.xcassets/Contents.json | 6 + .../Contents.json | 78 +++++++ .../Base.lproj/MainInterface.storyboard | 37 ++++ StickerSlackiMessageExtension/Info.plist | 13 ++ .../MessagesViewController.swift | 66 ++++++ 8 files changed, 417 insertions(+), 6 deletions(-) create mode 100644 StickerSlackiMessageExtension/Assets.xcassets/Contents.json create mode 100644 StickerSlackiMessageExtension/Assets.xcassets/iMessage App Icon.stickersiconset/Contents.json create mode 100644 StickerSlackiMessageExtension/Base.lproj/MainInterface.storyboard create mode 100644 StickerSlackiMessageExtension/Info.plist create mode 100644 StickerSlackiMessageExtension/MessagesViewController.swift diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 04d70ed..af550e0 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -14,8 +14,37 @@ A949B1F82EA04F2300215164 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; }; A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1FA2EA0518800215164 /* SlackResponse.swift */; }; A949B1FD2EA158DB00215164 /* testData.json in Resources */ = {isa = PBXBuildFile; fileRef = A949B1FC2EA158DB00215164 /* testData.json */; }; + A969D6942EA3E86500399C05 /* Messages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A969D6932EA3E86500399C05 /* Messages.framework */; }; + A969D6A02EA3E86600399C05 /* StickerSlackiMessageExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A969D6912EA3E86500399C05 /* StickerSlackiMessageExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + A969D6AC2EA3F1AF00399C05 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A62EA3F1AF00399C05 /* Assets.xcassets */; }; + A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */; }; + A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + A969D69E2EA3E86600399C05 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A949B1D72EA04C0B00215164 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A969D6902EA3E86500399C05; + remoteInfo = StickerSlackiMessageExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + A969D6A12EA3E86600399C05 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + A969D6A02EA3E86600399C05 /* StickerSlackiMessageExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ A940FE3C2EA232590016870B /* Emoji.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Emoji.swift; sourceTree = ""; }; A949B1DF2EA04C0B00215164 /* StickerSlack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StickerSlack.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -25,6 +54,12 @@ A949B1F72EA04F2300215164 /* EmojiHoarder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiHoarder.swift; sourceTree = ""; }; A949B1FA2EA0518800215164 /* SlackResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlackResponse.swift; sourceTree = ""; }; A949B1FC2EA158DB00215164 /* testData.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = testData.json; sourceTree = ""; }; + A969D6912EA3E86500399C05 /* StickerSlackiMessageExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = StickerSlackiMessageExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + A969D6932EA3E86500399C05 /* Messages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Messages.framework; path = Library/Frameworks/Messages.framework; sourceTree = DEVELOPER_DIR; }; + A969D6A62EA3F1AF00399C05 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A969D6A72EA3F1AF00399C05 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A969D6A82EA3F1AF00399C05 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,6 +70,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A969D68E2EA3E86500399C05 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A969D6942EA3E86500399C05 /* Messages.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -42,6 +85,8 @@ isa = PBXGroup; children = ( A949B1F22EA04E8200215164 /* StickerSlack */, + A969D6AB2EA3F1AF00399C05 /* StickerSlackiMessageExtension */, + A969D6922EA3E86500399C05 /* Frameworks */, A949B1E02EA04C0B00215164 /* Products */, ); sourceTree = ""; @@ -50,6 +95,7 @@ isa = PBXGroup; children = ( A949B1DF2EA04C0B00215164 /* StickerSlack.app */, + A969D6912EA3E86500399C05 /* StickerSlackiMessageExtension.appex */, ); name = Products; sourceTree = ""; @@ -92,6 +138,25 @@ path = Emoji; sourceTree = ""; }; + A969D6922EA3E86500399C05 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A969D6932EA3E86500399C05 /* Messages.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + A969D6AB2EA3F1AF00399C05 /* StickerSlackiMessageExtension */ = { + isa = PBXGroup; + children = ( + A969D6A62EA3F1AF00399C05 /* Assets.xcassets */, + A969D6A72EA3F1AF00399C05 /* Info.plist */, + A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */, + A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */, + ); + path = StickerSlackiMessageExtension; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -102,10 +167,12 @@ A949B1DB2EA04C0B00215164 /* Sources */, A949B1DC2EA04C0B00215164 /* Frameworks */, A949B1DD2EA04C0B00215164 /* Resources */, + A969D6A12EA3E86600399C05 /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( + A969D69F2EA3E86600399C05 /* PBXTargetDependency */, ); name = StickerSlack; packageProductDependencies = ( @@ -114,6 +181,25 @@ productReference = A949B1DF2EA04C0B00215164 /* StickerSlack.app */; productType = "com.apple.product-type.application"; }; + A969D6902EA3E86500399C05 /* StickerSlackiMessageExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = A969D6A52EA3E86600399C05 /* Build configuration list for PBXNativeTarget "StickerSlackiMessageExtension" */; + buildPhases = ( + A969D68D2EA3E86500399C05 /* Sources */, + A969D68E2EA3E86500399C05 /* Frameworks */, + A969D68F2EA3E86500399C05 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = StickerSlackiMessageExtension; + packageProductDependencies = ( + ); + productName = StickerSlackiMessageExtension; + productReference = A969D6912EA3E86500399C05 /* StickerSlackiMessageExtension.appex */; + productType = "com.apple.product-type.app-extension.messages"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -127,6 +213,9 @@ A949B1DE2EA04C0B00215164 = { CreatedOnToolsVersion = 26.0.1; }; + A969D6902EA3E86500399C05 = { + CreatedOnToolsVersion = 26.0.1; + }; }; }; buildConfigurationList = A949B1DA2EA04C0B00215164 /* Build configuration list for PBXProject "StickerSlack" */; @@ -144,6 +233,7 @@ projectRoot = ""; targets = ( A949B1DE2EA04C0B00215164 /* StickerSlack */, + A969D6902EA3E86500399C05 /* StickerSlackiMessageExtension */, ); }; /* End PBXProject section */ @@ -158,6 +248,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A969D68F2EA3E86500399C05 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A969D6AC2EA3F1AF00399C05 /* Assets.xcassets in Resources */, + A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -173,8 +272,35 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A969D68D2EA3E86500399C05 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + A969D69F2EA3E86600399C05 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A969D6902EA3E86500399C05 /* StickerSlackiMessageExtension */; + targetProxy = A969D69E2EA3E86600399C05 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A969D6A82EA3F1AF00399C05 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ A949B1E82EA04C0C00215164 /* Debug */ = { isa = XCBuildConfiguration; @@ -380,6 +506,69 @@ }; name = Release; }; + A969D6A22EA3E86600399C05 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "iMessage App Icon"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8JGND254B7; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = StickerSlackiMessageExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = StickerSlackiMessageExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.StickerSlack.StickerSlackiMessageExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A969D6A32EA3E86600399C05 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "iMessage App Icon"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8JGND254B7; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = StickerSlackiMessageExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = StickerSlackiMessageExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.StickerSlack.StickerSlackiMessageExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -401,6 +590,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A969D6A52EA3E86600399C05 /* Build configuration list for PBXNativeTarget "StickerSlackiMessageExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A969D6A22EA3E86600399C05 /* Debug */, + A969D6A32EA3E86600399C05 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = A949B1D72EA04C0B00215164 /* Project object */; diff --git a/StickerSlack/Emoji/Emoji.swift b/StickerSlack/Emoji/Emoji.swift index 63d71d6..5a496b9 100644 --- a/StickerSlack/Emoji/Emoji.swift +++ b/StickerSlack/Emoji/Emoji.swift @@ -61,5 +61,10 @@ struct Emoji: EmojiProtocol { print(UIImage(data: response.0)) return Emoji(name: name, url: urlString, image: UIImage(data: response.0)!) } + + mutating func grabImageSync() { + let data = try! Data(contentsOf: url) + uiImage = UIImage(data: data)! + } } diff --git a/StickerSlack/EmojiHoarder.swift b/StickerSlack/EmojiHoarder.swift index 8564a57..bce4a34 100644 --- a/StickerSlack/EmojiHoarder.swift +++ b/StickerSlack/EmojiHoarder.swift @@ -12,7 +12,7 @@ import Combine class EmojiHoarder: ObservableObject { private let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")! - @Published var emojis: [Emoji] = [] + @Published var emojis: [Emoji] init() { // guard let testURL = Bundle.main.url(forResource: "testData", withExtension: "json") else { @@ -29,11 +29,19 @@ class EmojiHoarder: ObservableObject { let data = try! Data(contentsOf: endpoint) let decoded: [SlackResponse] = try! JSONDecoder().decode([SlackResponse].self, from: data) - emojis = decoded.prefix(100).map { Emoji(name: $0.name, url: $0.imageUrl) } - Task { - for i in 0.. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StickerSlackiMessageExtension/Info.plist b/StickerSlackiMessageExtension/Info.plist new file mode 100644 index 0000000..52e0429 --- /dev/null +++ b/StickerSlackiMessageExtension/Info.plist @@ -0,0 +1,13 @@ + + + + + NSExtension + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.message-payload-provider + + + diff --git a/StickerSlackiMessageExtension/MessagesViewController.swift b/StickerSlackiMessageExtension/MessagesViewController.swift new file mode 100644 index 0000000..ebd9f72 --- /dev/null +++ b/StickerSlackiMessageExtension/MessagesViewController.swift @@ -0,0 +1,66 @@ +// +// MessagesViewController.swift +// StickerSlackiMessageExtension +// +// Created by neon443 on 18/10/2025. +// + +import UIKit +import Messages + +class MessagesViewController: MSMessagesAppViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + // MARK: - Conversation Handling + + override func willBecomeActive(with conversation: MSConversation) { + // Called when the extension is about to move from the inactive to active state. + // This will happen when the extension is about to present UI. + + // Use this method to configure the extension and restore previously stored state. + } + + override func didResignActive(with conversation: MSConversation) { + // Called when the extension is about to move from the active to inactive state. + // This will happen when the user dismisses the extension, changes to a different + // conversation or quits Messages. + + // Use this method to release shared resources, save user data, invalidate timers, + // and store enough state information to restore your extension to its current state + // in case it is terminated later. + } + + override func didReceive(_ message: MSMessage, conversation: MSConversation) { + // Called when a message arrives that was generated by another instance of this + // extension on a remote device. + + // Use this method to trigger UI updates in response to the message. + } + + override func didStartSending(_ message: MSMessage, conversation: MSConversation) { + // Called when the user taps the send button. + } + + override func didCancelSending(_ message: MSMessage, conversation: MSConversation) { + // Called when the user deletes the message without sending it. + + // Use this to clean up state related to the deleted message. + } + + override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) { + // Called before the extension transitions to a new presentation style. + + // Use this method to prepare for the change in presentation style. + } + + override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) { + // Called after the extension transitions to a new presentation style. + + // Use this method to finalize any behaviors associated with the change in presentation style. + } + +}