XPC | XPC and Friends | iOS library
kandi X-RAY | XPC Summary
kandi X-RAY | XPC Summary
An open-source reimplementation of Apple's XPC library and launchd for PureDarwin. Based on launchd 842.91.1 and iXsystems's skeleton re-implementation of libxpc.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of XPC
XPC Key Features
XPC Examples and Code Snippets
Community Discussions
Trending Discussions on XPC
QUESTION
I'm able to connect to a BLE device, but .discoverServices()
doesn't work. My logs show an unhelpfully generic error: [CoreBluetooth] XPC connection invalid
Connecting to it does work:
...ANSWER
Answered 2022-Feb-07 at 19:22I figured out two bugs in my code.
- I was calling
startScanning()
whencentralManagerDidUpdateState()
was called withcentral.state == .poweredOn
. This causing scanning to start again right after callingmyCentral.connect(connectedPeripheral!, options: nil)
- Calling
myCentral.stopScan()
aftermyCentral.connect(connectedPeripheral!, options: nil)
was causing disconnections
I don't understand why either of those were happening, but fixing them allowed me to now connect and get services and characteristics!
QUESTION
I am having a problem where a mac binary that interacts with CoreBluetooth fails as CBCentralManager reports "unsupported". I have already ensured entitlements, codesigning, and Security & Privacy are set properly. When I do verbose bluetooth logging I see the following:
...ANSWER
Answered 2022-Feb-04 at 19:32I upgraded from XCode 12.5.0 to 13.2.1 and the problem is resolved. It seems to have been an SDK mismatch and therefore the XPC messages were not being deserialized properly.
It would be good to get a more robust answer of how XPC messages work but I have not found a lot of resources on that. In lieu of that I can at least say this has solved the problem.
QUESTION
I have two GUI applications which use shared memory (8 memory instances, each ~100MB) with frequent read/write operations where one application ("server") writes to the memory, and the other reads from it.
On Windows the "server" application creates a shared memory using CreateFileMappingA
function, while the other app reads from it using OpenFileMappingA
. The buffer is accessed via MapViewOfFile
. Locking is done via named mutexes.
Now I am looking for a way to implement this on macOS. XPC (especially xpc_shmem_map
) seems to be a good fit but I do not entirely understand how it works. From the documentation and other sources (https://developer.apple.com/forums/thread/126716) it looks as if we always (?) have to create a service which acts as a bridge between the two applications? Or can one application just act as a "server" (like on Windows)?
What is the best way to share memory between two applications with as little copying on macOS (non-sandboxed)?
Regards,
...ANSWER
Answered 2022-Jan-25 at 10:21Two applications by themselves cannot directly talk to one another via XPC. If you need to securely share memory between two applications on macOS, XPC likely is your best option - it will just involve some additional setup.
The core concept to understand here is that there are only two ways to establish an XPC connection:
- Connecting to a named service managed by
launchd
. - Connecting to an XPC endpoint. However, the only way for a process to get access to an XPC endpoint that is associated with a listener connection in another service is over another XPC connection.
The reason you can't have one GUI application directly connection to another over XPC is neither of your GUI applications are going to be managed by launchd
. And if you're wondering, well can my GUI application be managed by launchd
? The answer is no; launchd
only manages services (which are dynamically started and can be terminated if system resources are needed).
The way you'll need to do this is:
- Create a Launch Agent. (Theoretically you could instead create a Launch Daemon, but there's no good reason to — you don't need root permission for what you're trying to do.)
- Have your Launch Agent vend a XPC Mach service. (This corresponds with #1 above when I was describing the core concept.)
- Have one of your GUI applications create an anonymous listener connection. Then get that listener's endpoint.
- Have that GUI application send your Launch Agent its endpoint.
- Have your other GUI application ask your Launch Agent for the endpoint.
- Have the other GUI application create a connection using that endpoint.
At this point your two GUI applications can directly talk to one another.
What I described is a bit oversimplified. For example you may way to have a design where both of them create an anonymous listener connection, send it to the Launch Agent, and if one already exists from the other application then it can return that. To avoid race conditions inside the Launch Agent you can DispatchQueue to serialize its processing of requests from the GUI applications.
FYI I linked to the Objective-C versions of the API because your post tagged nsxpcconnection
. However, there are also C API equivalents for all of this. If you have a cross-platform codebase, you may find the C API much easier to integrate.
QUESTION
To receive data from my bluetooth peripheral I need to write bytes to it (every time I write I get a response). The goal is to automaticly write to the peripheral every 1 second and to be able to view the data and trigger functions from the class in multiple views.
The problem I currently face is where to put the timer, I currently set it up here
...ANSWER
Answered 2022-Jan-05 at 21:58It does not duplicate the Timer it creates a new Class instance with a new Timer, you can try and use a singleton for the beginning - forcing only one instance of the class. A long-run solution will be to use some Dependency Injection solution to control the class lifecycle
QUESTION
I have extended my example project from my previous question with an attempt to establish an XPC connection.
In a different project we have successfully implemented the file provider for iOS. The exposed service must be resolved by URLs it is responsible for. On iOS it is the only possibility and on macOS it appears like that, too. Because on macOS the system takes care of managing files there are no URLs except the one which can be resolved through NSFileProviderItemIdentifier.rootContainer
.
In the AppDelegate.didFinishLaunching()
method I try to retrieve the service like this (see linked code for full reference, I do not want to unnecessarily bloat this question page for now):
ANSWER
Answered 2021-Nov-12 at 01:00There is a protocol which your extension's principal class can implement, NSFileProviderServicing.
https://developer.apple.com/documentation/fileprovider/nsfileproviderservicing
QUESTION
On MacOS (catalyst app, but AppKit bundle) I am creating Share submenu in main app menu "on fly" from menu delegate like this:
...ANSWER
Answered 2021-Nov-01 at 08:44So I could not fing the error, but I managed to make workaround. I added folloowing code to my func openSharingService(), in order to recognize Add to Photos and handle it in a different way:
QUESTION
Given the log line
...ANSWER
Answered 2021-Oct-21 at 16:09Here's one way to do this in zsh
and bash
:
QUESTION
I try to add a new node to an XML (svg) document, but when I try to query it afterwards with an XPath expression, it does not find the new node.
...ANSWER
Answered 2021-Oct-13 at 18:49While your print statement is outputting XML that, if reparsed, would give you the correct result, your in-memory DOM doesn't have awareness of the namespace of the new element. To tell the new element about the namespaces, we can use SetNamespace
and SetAttributeNS
per the docs
QUESTION
I am hoping to make a loop that allows me to use less lines of code to make changes to a settings file with Perl. Currently my code reads an XML file and locates a settings ID and replaces the setting value in that ID with a new one. The current request involves a lot of changes to the settings file and the code is very long. I have set my values in an array and my settings ID's in an array. Like this:
...ANSWER
Answered 2021-Oct-05 at 20:35Following code sample demonstrates how you could use %hash
for alternation you try to achieve.
QUESTION
Right after the splash screen fades out, the app is stuck on a blank page leaving this error in the console (ProxyWeb::didFailProvisionalLoadForFrame)
Note that the same app works perfectly on all previous IOS versions. I tried to change the webview plugin version, cordova-ios, and played around with angular build process but no luck.
I suspect that the angular portion of the project does not initialize, cordova itself loads successfully but anything beyond that is just an empty blank screen.
...ANSWER
Answered 2021-Sep-24 at 12:03Problem solved by a colleague, turned out a few providers (DatePipe, Location, Market, InAppBrowser) in app.component.ts
and a router animation were causing the fuss.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install XPC
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page