Extensions

RSS for tag

Give users access to your app's functionality and content throughout iOS and macOS using extensions.

Posts under Extensions tag

198 Posts
Sort by:
Post not yet marked as solved
2 Replies
92 Views
We have a browser extension using manifest v3 that we publish to the Chrome web store, and soon as a Firefox add-on. We'd also like to publish it for Safari, so we followed the instructions here: https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari This worked just fine, and running the XCode project will install the extension in Safari. The problem is that we do not want to distribute this with a macOS app. We only need the extension itself, all background work is done via a web worker. If I remove the macOS app from the XCode project, it does not seem as if there is a way to try and distribute it via App Store Connect. Is there way to just build and distribute the .webex extension?
Posted Last updated
.
Post not yet marked as solved
2 Replies
183 Views
Hi, since Upgrading to Ventura I cannot Debug my Photos Extension any more. But I urgently need to as we have a new bug that makes our app crash only on Ventura. (it's ONLY extensions that cannot be debugged, anything else works.) Trying to Debug shows: Could not attach to pid : “38699” Details: attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries, when the attach failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.) Console: "macOSTaskPolicy: (com.apple.debugserver) may not get the task control port of (friedmann print ) (pid: 35508): (friedmann print ) is hardened, (friedmann print ) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger(com.apple.debugserver) is not a declared read-only debugger" Is there ANYTHING I can do? Or do I have to wait for the next Ventura or XCode update??? All the best Christoph
Posted Last updated
.
Post not yet marked as solved
2 Replies
614 Views
I have an app which uses the Call Directory Extension to identify callers. It has been downloaded a few hundred times and a small percentage of users are reporting this error. They are logged in to the app but when they go to phone -> settings -> call blocking & identification they get one of two error messages. "An error occurred while attempting to enable app." "Failed to request data for app. You may try enabling the extension again and if the problem persists contact the application developer." I'm not sure how this could be an issue with the app because it works for the majority of users. Furthermore users still experience the error when I ask them to log in with a test account. One user even reported that they could enable it in settings but a little while later it will disable itself. I have seen similar posts where it's been suggested that the error may be due to bad data (out of order, duplicate contacts, etc) but this error shows before the app even begins to load the data. Does anyone know under what conditions this error popup shows? Many thanks
Posted
by lukevdp.
Last updated
.
Post not yet marked as solved
2 Replies
223 Views
I have a FileProvider app consisting of MainApp and FileProviderExtension. MainApp has a popover which should have features like: Button which opens FileProvider folder List of files being uploaded/download and when user clicks on a file, it should either be opened or shown in Finder in containing folder. How to achieve these in Sandboxed macOS app? I know it's possible because Microsoft's OneDrive app is distributed via AppStore and can perform these features. So far I've been able to create an alias to a FileProvider folder in user's home folder by utilizing NSOpenPanel. I tried opening FileProvider files from MainApp with something like: let url = try! await NSFileProviderManager(for: myDomain)?.getUserVisibleURL(for: fileIdentifier) NSWorkspace.shared.open(url!) but getUserVisibleURL returns nil. Does anyone know how to achieve described functionality?
Posted Last updated
.
Post marked as solved
11 Replies
965 Views
I am playing around with Live Activities and got everything working on the iOS 16.1 beta 2 simulator using Xcode 14.1 beta 2 (14B5024i). However, running the same code on a real physical device (iPhone X) running iOS 16.1 beta 2 does not show the Live Activity on the lock screen at all. 😵 Did anyone get their Live Activity working on a real device yet, or is this an issue with the current beta? Things I have already checked: ActivityAuthorizationInfo().areActivitiesEnabled returns true on my physical device let activity = try Activity.request(...) successfully completes without throwing and I can see the activity.id printed to the console Other live activities - such as the iOS system timer activity - do show up on my physical device just fine
Posted
by aschuch.
Last updated
.
Post marked as solved
2 Replies
156 Views
I'm trying to create a Workflow Extension for Final Cut Pro but I'm not able to do any more than install it. I've created a Mac app and added the Workflow Extension, the app builds and runs and shows up in FCP. When I launch the extension in FCP a window opens for the extension showing a label "Loading", the default extension icon (puzzle piece) and a progress indicator which does not animate. Nothing else happens, the default view included in the extension (that belonging to {ExtensionName}ViewController does not appear. The default view contains a TextField "FCP Workflow Extension" so I am expecting that to show. I have compared this behaviour with Ripple Training's workflow extension and this shows the same loading view before cross dissolving to their custom UI. When the Mac app is running from Xcode and the extension is running inside of FCP I can use Xcode's Attach to Process to attach to the extension but as the view of the {ExtensionName}ViewController does not load I can not use breakpoints or print statements to get any information and that is the only class included in the extension. What am I missing?
Posted
by reg890.
Last updated
.
Post not yet marked as solved
0 Replies
133 Views
Apple this is dead easy and quick to reproduce. Just create an app and then add a target of type background download. Xcode automatically assigns a group id to the target and generates a corresponding entitlements file like so: However the extension will not build, there is this error: You can bugger about in the developer portal as long as you want, ensuring the group identifier exists, ensuring provisioning profiles have this group capability, etc. etc. nothing will make this error go away. Now, what is unique about the download extension's entitlements file is the com.apple.developer.team-identifier key. This does not get generated for other extension - go ahead and see for yourself, create an action extension and give it a group, the result is its group appears in the entitlements file but not this com.apple.developer.team-identifier. If you try to print out $(TeamIdentifierPrefix) (via echoing it in a build script), you get this /Users/me/Library/Developer/Xcode/DerivedData/experiments-clpwbtcvdpqwuodxzwmsxwpztguo/Build/Intermediates.noindex/experiments.build/Debug-iphoneos/backgroundDownloadExtension.build/Script-243C9904292461BC001FDE14.sh: line 4: TeamIdentifierPrefix: command not found Hmm, command not found, but if you change the echo to ${TeamIdentifierPrefix} guess what gets printed, yes the team identifier i.e. in my case MV8J9D3236. Now if in the entitlements file I add the team identifier explicitly, like so Then magically the error about automatic signing and the provisioning profile goes away. Change it back to $(TeamIdentifierPrefix) and the error appears, change it to be explicit and it goes away. So by tweaking the entitlements file its possible to get the extension to build, however all is not well, now that it builds, if the extension is installed and run, the OS says: "Event (1) dropped for client (com.company.experiments) failed because the app and extension do not share any application groups." It says that despite the fact the app and extension both do have the same group capability. This is driving me nuts - the auto generated entitlements file is stopping the extension from compiling, but if you fix the build, it can't run. (Xcode 14.1, iOS 16.2)
Posted
by mungbeans.
Last updated
.
Post not yet marked as solved
1 Replies
162 Views
This can easily be reproduced from scratch following these steps: Launch Xcode and choose to create a new iOS app. Organization name: com.company, ProductName:experiments. Therefore the bundle id is: com.company.experiments Create a background download target, productName:backgroundDownloadExtension. Therefore the bundle is is: com.company.experiments.backgroundDownloadExtension When Xcode creates the extension it automatically gives it a group capability with id: group.com.company.experiements. Within the signing & Capabilities section for the extension there is the following error: Within the developer portal, go to the Identifiers section, locate the main app bundle com.company.experiements. If not ticked, tick the App Groups capability. Click on edit, select group.com.company.experiments Within the developer portal Identifiers section, locate the extension bundle, com.company.experiments.backgroundDownloadExtension. Ensure the App Groups capability is ticked. Click on edit, select group.com.company.experiments. Like so for both the app and extension: Back in Xcode, for the app add the group capability, tick group.com.company.experiments. Now it matches the extension and will be like this for both of them: Quit and relaunch Xcode because Xcode is so unbelievably sticky and seems to cache everything, e-v-e-r-y-t-h-i-n-g, and millions of problems can be solved just by quitting/relaunching it. In the Signing & Capabilities section for the extension it still displays this: Back in the developer portal, create a provisioning profile for iOS development, choose the com.company.experiments bundle id, download it. Do likewise for the com.company.experiments.backgroundDownloadExtension After downloading, click on them both. Quit and re-lanch Xcode again. Any luck? No its still displaying the provisioning error. Ok, enough of Xcode's automatic management of signing. Let's turn that off and import the the extension provisioning profile that was just downloaded. Still getting this error: The entitlements file's contents are: <key>com.apple.security.application-groups</key> <array> <string>group.com.company.experiments</string> </array> The contents of the downloaded extension profile are: <key>Entitlements</key> <dict> <key>com.apple.security.application-groups</key> <array> <string>group.com.company.experiments</string> </array> <key>application-identifier</key> <string>MV8J9D3236.com.company.experiments.backgroundDownloadExtension</string> <key>keychain-access-groups</key> <array> <string>MV8J9D3236.*</string> <string>com.apple.token</string> </array> <key>get-task-allow</key> <true/> <key>com.apple.developer.team-identifier</key> <string>MV8J9D3236</string> </dict> I give up, how the hell can you create a background download extension without Xcode displaying the error?
Posted
by mungbeans.
Last updated
.
Post not yet marked as solved
2 Replies
453 Views
Something seems to have changed in the iOS16.1 beta regarding EventKit authorization in extensions - is anybody else seeing this? We have widgets that were able to access calendars and events previously, and are no longer able to do so. Checking EKAuthorizationStatus when debugging the Widget extension is now giving us a status of .denied.
Posted
by siburb2.
Last updated
.
Post not yet marked as solved
0 Replies
129 Views
For example, when I share a link in Safari, a view appears (iOS’s share sheet) where many apps are displayed with which a URL can be shared. I know that I can display my app there as a share extension. Further below the apps a list with actions is displayed. How can I show a menu item with my app in this list? Unfortunately I can't find any information on this.
Posted
by vsmedia.
Last updated
.
Post not yet marked as solved
0 Replies
150 Views
I would like to be able to receive images from Safari in my Share Extension. To do this I need to add public.url in NSExtensionActivationRule. This works and my app can receive shared images from Safari. The problem is that my app also appears in the list when sharing a URL to a website and not an image. Now I'm looking for a way to hide my app when sharing in Safari if the URL doesn't lead to an image.
Posted
by vsmedia.
Last updated
.
Post not yet marked as solved
3 Replies
1.5k Views
Issue Summary Hi all, I'm working on an Intents Extension for my app, however when I try to run an intent, Xcode pops up the following error: Could not attach to pid: "965" attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.) An image of the error: This only happens when I try debugging the Intent Extension. Running the main app target or another extension target (e.g. notifications) doesn't produce this error. Build Setup Here are the details of my build setup: Mac Mini M1 Xcode 13 Building to iPhone 11 Pro Max, iOS 15.0.2. I've also tried building to my iPad Pro 12.9 w/ iOS 15.1 and hit the same issue. Things I've tried: Make sure "Debug executable" is unchecked in the scheme I've tried changing the Launch setting to "Automatic" and "Wait for the executable to be launched" I've made sure to run sudo DevToolsSecurity -enable on my mac Rebooted iPhone devices + mac mini Uninstalled / reinstalled the app Deleted derived data Removing / reinstalling the development certs in my keychain --> this actually seemed to work initially, but then the problem came back and now it doesn't work anymore. Console Logs I've looked at the console logs while this error occurs to see if it can shed light on the issue. Here are the ones that seemed notable to me. These logs seem to show that Siri is trying to save / write to a file that it does not have access too. Seems very suspicious error 11:42:38.341470-0800 kernel System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference error 11:42:38.342204-0800 assistantd failed to save contact runtime data. error=Error Domain=NSCocoaErrorDomain Code=512 "The file “com.apple.siri.inference” couldn’t be saved in the folder “Library”." UserInfo={NSFilePath=/var/mobile/Library/com.apple.siri.inference, NSUnderlyingError=0x100fb03a0 {Error Domain=NSPOSIXErrorDomain Code=5 "Input/output error"}} error 11:42:38.342403-0800 assistantd InferenceError<errorId=crSaveToRunTimeDBFailed file=/Library/Caches/com.apple.xbs/Sources/SiriInference/SiriInference-3100.49.3.1.2/SiriInference/SiriInference/ContactResolver/ContactResolver.swift function=logRunTimeData(runTimeData:config:) line=378 msg=> error 11:42:38.465702-0800 kernel 1 duplicate report for System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference Looking for "debugserver" entries, like the error suggests, shows these logs: default 11:42:44.814362-0800 debugserver error: [LaunchAttach] MachTask::TaskPortForProcessID task_for_pid(965) failed: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) default 11:42:44.814476-0800 debugserver 10 +0.011525 sec [03c6/0103]: error: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) default 11:42:44.825704-0800 debugserver error: MachTask::StartExceptionThread (): task invalid, exception thread start failed. default 11:42:44.825918-0800 debugserver error: [LaunchAttach] END (966) MachProcess::AttachForDebug failed to start exception thread attaching to pid 965: unable to start the exception thread default 11:42:44.826025-0800 debugserver error: Attach failed default 11:42:44.828923-0800 debugserver error: Attach failed: "Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.". I've also attached the full details of the error below via a text file if it helps. Any help with this issue would be great, and I'm happy to provide more information if needed. Thanks in advance! Xcode Attach Full Error Details
Posted Last updated
.
Post not yet marked as solved
1 Replies
902 Views
There is an error when running my app using the "ShortCut" . The error code is "INCExtensionErrorDomain, 1307". I can't find the same error on the internet. Who can help me? Thank you
Posted
by libg.
Last updated
.
Post not yet marked as solved
1 Replies
295 Views
Are “Notification Service Extensions” officially supported on macOS? I’m developing an app for both iOS and macOS (not Catalyst). I’ve successfully setup a separate notification service extension for both the iOS and macOS targets. The iOS extension is modifying the CKSubscription push notification as expected. However the macOS notification service extension is not being launched at all no matter what I seem to try, matching deployment targets etc. I’m also asking because although Apple docs report that support for UNNotificationServiceExtension was added in macOS 10.14, the article at https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications makes no mention of macOS, only iOS.
Posted
by codecomet.
Last updated
.
Post marked as solved
5 Replies
407 Views
Hi, After adding a WidgetExtension (to add a lock screen widget) to my app, I've discovered that when running my app on a device <iOS16, I crash with a Symbol not found error in... Foundation. dyld[99805]: Symbol not found: _$s10Foundation10URLRequestV10httpMethodSSSgvg Referenced from: /Users/thibauddavid/Library/Developer/Xcode/DerivedData/MyAppName-aesniykwuojsmyblczcqnpuiuuzk/Build/Products/DebugDevelopment-iphonesimulator/WidgetsExtensionEngine.framework/WidgetsExtensionEngine Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation Symbol not found: _$s10Foundation10URLRequestV10httpMethodSSSgvg Referenced from: /Users/thibauddavid/Library/Developer/Xcode/DerivedData/MyAppName-aesniykwuojsmyblczcqnpuiuuzk/Build/Products/DebugDevelopment-iphonesimulator/WidgetsExtensionEngine.framework/WidgetsExtensionEngine Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation How is that even possible ? I've double checked my widget mintarget version (iOS16), and that all my targets are using the same Swift version (5). What else can I check ? When I encounter a similar error, it's always because a framework isn't embedded in host target, but there is no way Foundation could be missing. My widget extension is the only extension triggering this issue (NSE, Share etc works fine). I suspect it's because my WidgetExtension target has a min target version of iOS16, but it shouldn't event be embedded nor run in iOS15 devices. Am I missing something ? Any help appreciated
Posted Last updated
.
Post not yet marked as solved
0 Replies
158 Views
Getting a crash when hitting the last line in my app message extension code below. As soon as it tries to insert the message. let messageCaption = NSLocalizedString("Test", comment: "Test Comment")                               let layout = MSMessageTemplateLayout()               layout.image = .add               layout.caption = messageCaption                               let message = MSMessage(session: viewModel.session)               message.summaryText = product.name               message.layout = layout                               viewModel.conversation.insert(message) Once the app crashes, I am presented with this error message. I am on Xcode 14 and this is on an iphone 14 sim - iOS 16 Once I hit report, I get the full logs here ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: F62BD596-CD46-40CB-B798-07EC0AA3158D CrashReporter Key: D89DFC1D-3461-4988-CEA6-FE9F2C7FAEE7 Hardware Model: MacBookPro16,1 Process: MobileSMS [21403] Path: /Applications/Xcode 14.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/MobileSMS.app/MobileSMS Identifier: com.apple.MobileSMS Version: 14.0 (6000) Code Type: X86-64 (Native) Role: Foreground Parent Process: launchd_sim [3466] Coalition: com.apple.CoreSimulator.SimDevice.D4E73F6D-BBC3-4DD9-A3DF-9841739EF83C [1013] Responsible Process: SimulatorTrampoline [2001] Date/Time: 2022-11-08 14:26:13.9868 -0500 Launch Time: 2022-11-08 14:24:24.9288 -0500 OS Version: macOS 12.6.1 (21G217) Release Type: User Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x7ff800427368 __exceptionPreprocess + 226 1 libobjc.A.dylib 0x7ff80004dbaf objc_exception_throw + 48 2 CoreFoundation 0x7ff800436588 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3 CoreFoundation 0x7ff80042b83d ___forwarding___ + 1431 4 CoreFoundation 0x7ff80042db38 _CF_forwarding_prep_0 + 120 5 IMCore 0x7ff810903f11 0x7ff810893000 + 462609 6 ChatKit 0x1038958c0 __46-[CKChatInputController _startEditingPayload:]_block_invoke + 591 7 ChatKit 0x1039ee5ae __69+[CKComposition compositionWithShelfPluginPayload:completionHandler:]_block_invoke + 115 8 libdispatch.dylib 0x7ff80013b7fb _dispatch_call_block_and_release + 12 9 libdispatch.dylib 0x7ff80013ca3a _dispatch_client_callout + 8 10 libdispatch.dylib 0x7ff80014c32c _dispatch_main_queue_drain + 1338 11 libdispatch.dylib 0x7ff80014bde4 _dispatch_main_queue_callback_4CF + 31 12 CoreFoundation 0x7ff8003869f7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 13 CoreFoundation 0x7ff8003813c6 __CFRunLoopRun + 2482 14 CoreFoundation 0x7ff800380637 CFRunLoopRunSpecific + 560 15 GraphicsServices 0x7ff809c0f28a GSEventRunModal + 139 16 UIKitCore 0x10509d425 -[UIApplication _run] + 994 17 UIKitCore 0x1050a2301 UIApplicationMain + 123 18 MobileSMS 0x100194220 0x100174000 + 131616 19 dyld_sim 0x1003e92bf start_sim + 10 20 dyld 0x10930552e start + 462 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x7ff833de600e __pthread_kill + 10 1 libsystem_pthread.dylib 0x7ff833e3d1ff pthread_kill + 263 2 libsystem_c.dylib 0x7ff800132fe0 abort + 130 3 libc++abi.dylib 0x7ff800257742 abort_message + 241 4 libc++abi.dylib 0x7ff80024895d demangling_terminate_handler() + 266 5 libobjc.A.dylib 0x7ff800031fae _objc_terminate() + 96 6 libc++abi.dylib 0x7ff800256b65 std::__terminate(void (*)()) + 8 7 libc++abi.dylib 0x7ff800256b16 std::terminate() + 54 8 libdispatch.dylib 0x7ff80013ca4e _dispatch_client_callout + 28 9 libdispatch.dylib 0x7ff80014c32c _dispatch_main_queue_drain + 1338 10 libdispatch.dylib 0x7ff80014bde4 _dispatch_main_queue_callback_4CF + 31 11 CoreFoundation 0x7ff8003869f7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 12 CoreFoundation 0x7ff8003813c6 __CFRunLoopRun + 2482 13 CoreFoundation 0x7ff800380637 CFRunLoopRunSpecific + 560 14 GraphicsServices 0x7ff809c0f28a GSEventRunModal + 139 15 UIKitCore 0x10509d425 -[UIApplication _run] + 994 16 UIKitCore 0x1050a2301 UIApplicationMain + 123 17 MobileSMS 0x100194220 0x100174000 + 131616 18 dyld_sim 0x1003e92bf start_sim + 10 19 dyld 0x10930552e start + 462 Thread 1:: com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x7ff833ddf97a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x7ff833ddfce8 mach_msg + 56 2 CoreFoundation 0x7ff800386766 __CFRunLoopServiceMachPort + 145 3 CoreFoundation 0x7ff800380f6f __CFRunLoopRun + 1371 4 CoreFoundation 0x7ff800380637 CFRunLoopRunSpecific + 560 5 Foundation 0x7ff800c569fc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213 6 Foundation 0x7ff800c56c75 -[NSRunLoop(NSRunLoop) There's more but I can't fit in this message - any ideas? I'm stumped
Posted
by JMando.
Last updated
.
Post not yet marked as solved
0 Replies
165 Views
Hello, I am a new developer and it is my first time trying to build an iMessage Extension app. I am having an issue with presenting a SwiftUI view using a hosting controller in iOS 16. My code works on earlier OS versions, but for some reason when I updated to iOS 16 the view constraints seem off. I am running the app on an iPhone 13 on iOS 16.03 and what I encounter is the following: When I open the app the view appears all the way at the top of the screen past the safe area. I was able to replicate the issue using the IceCreamBuilderMessagesExtension project in apple docs (https://developer.apple.com/documentation/messages/icecreambuilder_building_an_imessage_extension). I got rid of most of the code in the IceCreamBuilder project to try and isolate just the issue with presenting a SwiftUI view. Here is my code in the IceCreamBuilder project: /* The root view controller shown by the Messages app. */ import UIKit import Messages import SwiftUI class MessagesViewController: MSMessagesAppViewController {   // MARK: Properties       override func willBecomeActive(with conversation: MSConversation) {     super.willBecomeActive(with: conversation)           // Present the view controller appropriate for the conversation and presentation style.     presentViewController(for: conversation, with: presentationStyle)   }       // MARK: MSMessagesAppViewController overrides       override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {     super.willTransition(to: presentationStyle)           // Hide child view controllers during the transition.     removeAllChildViewControllers()   }       override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {     super.didTransition(to: presentationStyle)           // Present the view controller appropriate for the conversation and presentation style.     guard let conversation = activeConversation else { fatalError("Expected an active converstation") }     presentViewController(for: conversation, with: presentationStyle)   }       // MARK: Child view controller presentation       /// - Tag: PresentViewController   private func presentViewController(for conversation: MSConversation, with presentationStyle: MSMessagesAppPresentationStyle) {     // Remove any child view controllers that have been presented.     removeAllChildViewControllers()           let controller = UIHostingController(rootView: TestView())     addChild(controller)     controller.view.frame = view.bounds     controller.view.translatesAutoresizingMaskIntoConstraints = false     view.addSubview(controller.view)           NSLayoutConstraint.activate([       controller.view.leftAnchor.constraint(equalTo: view.leftAnchor),       controller.view.rightAnchor.constraint(equalTo: view.rightAnchor),       controller.view.topAnchor.constraint(equalTo: view.topAnchor),       controller.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)       ])           controller.didMove(toParent: self)   }           // MARK: Convenience       private func removeAllChildViewControllers() {     for child in children {       child.willMove(toParent: nil)       child.view.removeFromSuperview()       child.removeFromParent()     }   }      } // TestView.swift // IceCreamBuilderMessagesExtension import SwiftUI struct TestView: View {   var body: some View {     VStack {       Text("Test")       Text("Test")       Text("Test")       Text("Test")       Text("Test")     }   } } Any help/insight is very much welcomed, Thank you
Posted
by hazyR.
Last updated
.
Post not yet marked as solved
0 Replies
169 Views
We plan to develop a Share extension. The CoreData is storing its SQLite file in AppGroup folder. The share extension will run in a different process than main app's. Since share extension and main app are running in different process, both will have their own instance of CoreData. However, even there are multiple instances of CoreData in different processes, their underlying are pointing to a single same SQLite file. Under https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1 It mentions When you set up a shared container, the containing app—and each contained app extension that you allow to participate in data sharing—have read and write access to the shared container. To avoid data corruption, you must synchronize data accesses. Use Core Data, SQLite, or Posix locks to help coordinate data access in a shared container. But it isn't clear, what are detailed steps required to How can we synchronize access to CoreData among 2 processes? Who should responsible to consume relevant store change, and update the single token file? (https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes) Should it be main app, share extension or both? Thank you.
Posted
by yccheok.
Last updated
.
Post not yet marked as solved
0 Replies
320 Views
Hi there, The Setup/My Goal I have a very standard Finder Sync Extension, which extends the context menu of the finder. I also have a main application which uses the KeyboardShortcuts Package (Keyboard Shortcuts - Github) to record and save a user defined shortcut. This shortcut should execute the menu item of the Finder Sync Extension (therefore getting the selected files and processing them in some way) when used. Currently I am using inter-process communication to send an event to the extension when the shortcut is executed by the user. You can find the Swift Class responsible for the communication between Finder Sync Extension and the Main App as an Attachment here: ProcessCommunicator.swift (although the communication works and this is more an issue of the finder sync extension behaviour than one of inter-process communication). When the Finder Sync Extension receives the event, it executes the same function which is called when the user clicks the menu item like so (this event is registered in the initialisation function of the Finder Sync Extension): processCommunicator = ProcessCommunicatorReceiver(appGroupIdentifier: "group.some.bundle.id.port") processCommunicator?.on(id: 1, event: { _ in self.executeSomeAction(nil) return nil }) The same action is called when the user clicks the menu item: override func menu(for menuKind: FIMenuKind) -> NSMenu { let menu = NSMenu() if menuKind == FIMenuKind.contextualMenuForItems || menuKind == FIMenuKind.toolbarItemMenu { menu.addItem(withTitle: text, action: #selector(executeSomeAction), keyEquivalent: "T") } return menu } The function executeSomeAction would look something like this @IBAction func transfer(_ sender: AnyObject?) { guard let target = finderSyncController.selectedItemURLs() else { NSLog("Failed to obtain targeted URLs: %@") return } // Process the selected items (target) The Problem When the function executeSomeAction is called from the process-communicator-event (sent by the main app), the selectedItemURLs is nil and therefore the function returns without doing anything. If the function executeSomeAction is called by the menu item click event, the selectedItemURLs is an array of paths as expected. Is there some restriction which prevents access to the user selected, when it’s not strictly clicked by the user or am I missing something here? Other possible Solutions to my Issue This whole inter-process communication is only needed because I need the shortcut event to be sent to the extension. I have noticed that in the initialisier of the menu item there is a keyEquivalent (-> shortcut) menu.addItem(withTitle: text, action: #selector(executeSomeAction), /* HERE -->*/ keyEquivalent: "T") This shortcut seems to be ignored by the system, as it neither appears next to the menu item, nor is functional. I am assuming that this is intended but if there is any way to make this work with the inbuilt system shortcut, instead of the communication-hack I am using currently, I would prefer to use this solution. Summary As said before, the selectedItemURLs is only defined if it is called from the menu item event, which eliminates the ability to do some custom processing with the selected files (in my case called by an event sent by another process)
Posted
by Elia314.
Last updated
.