Hi there!
Please advice how I can subscribe to listening system events (Lock Screen/User log off/Device mounted/etc)?
I try to use NSDistributedNotificationCenter to do it, but I can receive only own notifications =(
This is the my test Console application:
//
// main.m
// EventsListener
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#include <iostream>
@interface MyClass : NSObject
-(void)subscribe;
-(void)handleNotification:(NSNotification*)notification;
@end
@implementation MyClass : NSObject
-(void)subscribe
{
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:nil object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification2:) name:nil object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification3:) name:nil object:nil];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil];
}
-(void)handleNotification:(NSNotification*)notification
{
NSLog(@"handleNotification: %@", notification);
}
-(void)handleNotification2:(NSNotification*)notification
{
NSLog(@"handleNotification2: %@", notification);
}
-(void)handleNotification3:(NSNotification*)notification
{
NSLog(@"handleNotification3: %@", notification);
}
-(void)handleNotification4:(NSNotification*)notification
{
NSLog(@"handleNotification3: %@", notification);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
MyClass* mc = [MyClass new];
[mc subscribe];
[[NSNotificationCenter defaultCenter] postNotificationName:@"test notification" object:nil];
NSLog(@"Press enter to abort");
getchar();
}
return 0;
}
What wrong I does?
Thanks!
Post
Replies
Boosts
Views
Activity
Hello,
Is in macOS exist system call which can resolve real path to file/directory for APFS?
For example, in BigSur real path of /Users directory is /System/Volumes/Data/Users. So, I expect something like this:
c++
std::string userFriendlyPath = "/Users/myuser1"
const char* pRealPath = realpath(userFriendlyPath.c_str());
if (pRealPath == nullptr)
_log.info("real path is the same");
// but in this case pRealPath should be == "/System/Volumes/Data/Users/myuser1"
Thanks!
Hello,
We have application which works fine on macOS 10.13-11.0 with x64 architecture and in Rosetta2 on ARM. But the same code rebuilt for ARM64 caused to SEGV on
pthread_mutex_init.
Part of crash report:
Thread 9 Crashed:: MyService server thread
0 libsystempthread.dylib 0x000000019101476c pthreadmutexinit + 368
1 myservice 0x00000001024ea654 0x1024b8000 + 206420 // boost::mutex::mutex() (in myservice) (mutex.hpp:52)
2 myservice 0x00000001024e8ed4 0x1024b8000 + 200404 // boost::mutex::mutex() (in myservice) (mutex.hpp:51)
3 myservice 0x0000000102911290 0x1024b8000 + 4559504 // veeamrpc::CTcpThread::CTcpThread(std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) (in myservice) (TcpThread.cpp:15)
4 myservice 0x00000001029113e0 0x1024b8000 + 4559840
5 myservice 0x00000001024fea64 0x1024b8000 + 289380
6 myservice 0x00000001024febf0 0x1024b8000 + 289776
7 myservice 0x00000001024e9564 0x1024b8000 + 202084
8 myservice 0x00000001024e8d3c 0x1024b8000 + 199996
9 myservice 0x00000001024f0810 boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >::operator()(service::CLpbSvcServer*, boost::sharedptr<api::CSocketIP>) const + 144
10 myservice 0x00000001024f0738 void boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > >::operator()<boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >&, boost::bi::list0&, int) + 144
11 myservice 0x00000001024f069c boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >::operator()() + 72
12 myservice 0x00000001024f03b4 boost::detail::function::voidfunctionobjinvoker0<boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >, void>::invoke(boost::detail::function::functionbuffer&) + 36
13 myservice 0x0000000102737e3c boost::function0<void>::operator()() const + 116
14 myservice 0x0000000102737018 0x1024b8000 + 2617368
15 myservice 0x000000010273a64c boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>::operator()(synch::Thread*, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) const + 152
16 myservice 0x000000010273a56c void boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > >::operator()<boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::_1::allocator<char> > const&>&, boost::bi::list0&, int) + 168
17 myservice 0x000000010273a4b8 boost::bi::bindt<void, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > > >::operator()() + 72
18 myservice 0x00000001027395b4 0x1024b8000 + 2626996
19 libcpprest.2.10.dylib 0x00000001051de4a8 boost::(anonymous namespace)::threadproxy(void*) + 176
20 libsystempthread.dylib 0x000000019101906c pthreadstart + 320
21 libsystempthread.dylib 0x0000000191013da0 thread_start + 8
Maybe some additional code needed for ARM64 platform?
P.S. We have boost 1.70.
Hello,
We have plugin for installer and we use InstallerJS for additional checks before installation. Because of that when I run installer I see that message:
This package will run a program to determine if the software can be installed.
[Cancel] [Allow] And when I allow it my installer re-opens. It reproduces only on AppleSilicon (ARM64) version of BigSur (11.0.1 as well).
Here is part of install.log:
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Install PROJECT:Install-1000
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Installer PROJECT:Installer-1018
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Hardware: ADP3,2 @ 0 MHz (x 8), 16384 MB RAM
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Running OS Build: macOS 11.0.1 (20B5012d)
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: USER=user
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: _CFBundleIdentifier=com.apple.installer
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: COMMANDMODE=unix2003
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: LOGNAME=user
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: PATH=/usr/bin:/bin:/usr/sbin:/sbin
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: SSHAUTHSOCK=/private/tmp/com.apple.launchd.PQMDXH1vBR/Listeners
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: SHELL=/bin/zsh
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: HOME=/Users/user
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: _CFUSERTEXTENCODING=0x1F6:0x0:0x0
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: TMPDIR=/var/folders/ks/n9ygc5yn61bdh1py1pnk7ylh0000gp/T/
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: XPCSERVICENAME=application.com.apple.installer.1152921500312163792.1152921500312163797
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Env: XPCFLAGS=0x0
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: MyPkg 1.0.0.605 1.0.0.605 Installation Log
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Opened from: /Users/user/MyPkg -1.0.0.605-Universal.pkg
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <backgroundscaling> has an unsupported MIME type: X-NSObject/NSNumber
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <backgroundalignment> has an unsupported MIME type: X-NSObject/NSNumber
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Package Authoring Error: <layout-direction> has an unsupported MIME type: X-NSObject/NSNumber
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Failed to load specified background image
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: Product archive /Users/user/MyPkg -1.0.0.605-Universal.pkg trustLevel=350
2020-10-30 09:34:17+01 BigSurARM-MAC Installer[93715]: External component packages (1) trustLevel=350
2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Could not load resource readme: (null)
2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Architecture Translation: Distribution failed architecture check and is about to be re-executed as Intel.
2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: Architecture Translation: Process is about to get executed as Intel.
2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Install PROJECT:Install-1000
2020-10-30 09:34:19+01 BigSurARM-MAC Installer[93715]: @(#)PROGRAM:Installer PROJECT:Installer-1018
So, I have "Architecture Translation: Process is about to get executed as Intel." error, but one thing - it is Universal package (built on Intel based Mac using cross-compilation). It means that plugin for installer was built for both architectures and then Universal binary was made from them, which is actually stored in the package.
Then I built just ARM package:
lipo -archs /tmp/pkgbuild/darwin/flat/Plugins/LicenseAgeementsPlugin.bundle/Contents/MacOS/LicenseAgeementsPlugin
arm64 , but I got the same error:
2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Could not load resource readme: (null)
2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Architecture Translation: Distribution failed architecture check and is about to be re-executed as Intel.
2020-10-30 09:48:34+01 BigSurARM-MAC Installer[93836]: Architecture Translation: Process is about to get executed as Intel.
2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: @(#)PROGRAM:Install PROJECT:Install-1000
2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: @(#)PROGRAM:Installer PROJECT:Installer-1018
2020-10-30 09:48:35+01 BigSurARM-MAC Installer[93836]: Hardware: ADP3,2 @ 2.40 GHz (x 4), 16384 MB RAM
But I didn't have x8664 binaries in my package. How is it possible? What I do wrong?
Thanks.
Hello all,
I have found many articles how to distribute MDM profiles, but no one about using MDM profiles in applications.
Is there some API or any documentation for that?
For example, my application is already installed and now awaiting for MDM profile installed for all users.
How I can determine that I need MDM profile installed?
How I can determine path of this profile to read it in own application?
Should I have some entitlements for that?
Does any API exist for that, maybe?
Thanks!
Hello!I try to read stdout and to write to stdin of a child process using method described here: http://www.microhowto.info/howto/capture_the_output_of_a_child_process_in_c.htmlIt's work fine for typical commandline tools, but it doesn't work for mount utility - password prompt everytime showed in my (parent) process. Why it happens? What is the difference between typical writing to stdout and password prompting in macOS?Thanks