Posts

Post not yet marked as solved
3 Replies
265 Views
I am trying to pass an array of C-structs to an XPC Service, but the service receives only the first element. Following is the C struct struct MyStruct { char *name; unsigned char v1; unsigned char v2; Status status; // a c-style enum }; and I am using it like this struct MyStruct structs[3] = {{"name1", 0, 0, success}, {"name2", 1,1, success}, {0}}; [[_connectionToService remoteObjectProxy] doSomething:structs]; and doSomething is declared as - (void)doSomething: (struct MyStruct[]) structs; The document Creating XPC Services mentions that C structures and arrays containing only the types listed above are supported, but I am unable to get it to work even for an array of c-strings or ints. Also, there's an API for making synchronous RPC calls but there is no documentation available for it. - (id)synchronousRemoteObjectProxyWithErrorHandler:(void (^)(NSError *error))handler It does seem to block but only if the remote method has a reply block. Is this the expected behaviour? And is it safe to cache the proxy object returned by this method?
Posted Last updated
.
Post marked as solved
4 Replies
283 Views
I have a task that uses a CFRunLoopObserver like the following. class Task { CFRunLoopObserverRef fObserver; public: Task() { CFRunLoopObserverContext context = {0, this, NULL, NULL, NULL}; fObserver = CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, &MainRunLoopObserverCallback, &context); ::CFRunLoopAddObserver(CFRunLoopGetMain(), fObserver, kCFRunLoopCommonModes); } static void MainRunLoopObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) { Task* task = reinterpret_cast<Task*>(info); // task->member causes a crash if task deleted } ~Task() { if (fObserver) { ::CFRunLoopRemoveObserver(CFRunLoopGetMain(), fObserver, kCFRunLoopCommonModes); ::CFRelease(fObserver); } } }; I have noticed that the app crashes sometimes when the task object gets deleted before the CFRunLoopObserverCallBack is completed. Would it be possible to make sure that the observer callback is complete before the observer is removed from the runloop?
Posted Last updated
.
Post not yet marked as solved
0 Replies
334 Views
I am trying to get the execution time of a function in Instruments Time Profiler using the signpost APIs, but it is reporting incorrect time. I have reduced it to the following code sample #import <os/log.h> #import <os/signpost.h>    os_log_t _log = os_log_create("com.example.parser", OS_LOG_CATEGORY_POINTS_OF_INTEREST);   os_signpost_id_t spid = os_signpost_id_generate(_log);       os_signpost_interval_begin(_log, spid, "Parse", "Start");   auto b = clock();   auto begin = std::chrono::high_resolution_clock::now();     // dummy loop instead of actual parse   for(int i = 0; i < INT_MAX; ++i) {   }       auto e = clock();   auto end = std::chrono::high_resolution_clock::now();         auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();   os_signpost_interval_end(_log, spid, "Parse", "End");   NSLog(@"CPU Time: %lf s", (e-b)/(double)CLOCKS_PER_SEC);   NSLog(@"Chrono: %lld ms", duration); As per chrono/CPU time, it takes ~3s to execute this code, but in Instruments Time Profiler, it shows the duration as 145 microseconds. Is this not the correct way to use the signpost API? XCode - 11.3 macOS 10.15.7
Posted Last updated
.
Post marked as solved
3 Replies
1k Views
We have multiple macOS applications (non sandboxed) that share a lot of core frameworks. So if the user installs two of our apps, there are essentially duplicate copies of the same frameworks inside the app bundles. This duplication can cost the user around 450 MB. Is there an apple recommended way to avoid duplication in such scenarios? One approach would be to install the common frameworks in a location like /Library/Application Support/MyCompany/Shared Frameworks/ and then add this to the rpath of all the applications, but I am not sure if this will work after signing and notarization. Note - These apps are not distributed through the app store and are not sandboxed.
Posted Last updated
.
Post marked as solved
6 Replies
516 Views
The main app communicates with the helper app periodically, but how to handle situations where the helper app gets stuck and stops responding to messages? [NSRunningApplication forceTerminate] would have worked, but it always returns NO when app sandbox is enabled, even if the app being terminated is part of the same app group.
Posted Last updated
.
Post marked as solved
3 Replies
499 Views
I am working on an application with multiple helper apps and tools with a fairly nested structure, like the following A.app └── Contents   └── MacOS     ├── A     ├── B.app     │  └── Contents     │    └── MacOS     │      ├── B     │      └── D.app     └── C.app and have the following queries I. How to sign bundles correctly? Should the top-level bundle be signed or signing the internal contents is enough or both? For eg: Currently, after signing any nested code, I sign frameworks (and plugins) as codesign -s *** ABC.framework/Versions/A/ABC, which is what I believe Xcode does. However, in this - https://developer.apple.com/forums/thread/130855 thread  the codesign command is run on the .framework directory. 2. How to verify that the app has been signed correctly? I have encountered issues where the following codesign command reports no errors, but the app crashes on launch with Code Signature Invalid exception. codesign --verify --deep --strict --verbose=2|3|4 Foo.app 3. Do Mac App Store apps need to incorporate protections required for notarization? As per docs, Mac App Store apps don't need to go through the notarization process, are they still required to enable hardened runtime, signature timestamps etc? 4. Can helper apps have symlinks that point outside their app bundle? In the structure that I have shared, apps B, C and D share a lot of common frameworks. Can C.app's Frameworks directory be symlinked with D.app's Frameworks directly, even though it is pointing outside C.app's bundle? Note: This app will be distributed via the App Store
Posted Last updated
.