Re: Debugging a privileged helper

2017-01-26 Thread John Brownie

Damien DeVille wrote:

Are you specifying the MachService you use for your XPC connection in
your launchd job?

I believe so. The launchd plist is:
==

"http://www.apple.com/DTDs/PropertyList-1.0.dtd;>



Label
org.sil.KLMHelper
MachServices

org.sil.KLMHelper


Program
/Library/PrivilegedHelperTools/org.sil.KLMHelper
ProgramArguments

/Library/PrivilegedHelperTools/org.sil.KLMHelper



==

The code to connect to the helper is:
==
helperToolConnection = 
NSXPCConnection.init(machServiceName: toolIdentifier, options: 
NSXPCConnection.Options.privileged)
helperToolConnection?.remoteObjectInterface = 
NSXPCInterface.init(with: Keyboard_Layout_HelperProtocol.self)

helperToolConnection?.invalidationHandler = {
self.helperToolConnection?.invalidationHandler = nil
OperationQueue.main.addOperation({
self.helperToolConnection = nil
})
}
==
where toolIdentifier is "org.sil.KLMHelper"

The code that invokes the code is like this:
==
let connection = connectionManager.helperToolConnection
let proxy = 
connection?.remoteObjectProxyWithErrorHandler { (error) in

NSApp.presentError(error)
} as! Keyboard_Layout_HelperProtocol
let authorization = connectionManager.authorization
// Call the proxy with the appropriate code
proxy.authenticatedCreateDirectory(url: location, 
authorization: authorization) { handler($0, $1) }

==

All of this is derived from Even Better Authorization Sample, translated 
to Swift.

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


WatchOS3 layering?

2017-01-26 Thread Eric Dolecki
I have a quick question. 
I've been asked to make a companion watch app and have been given a sketch file 
for the design. In the design in the center is an image of a product. On top 
and larger is an image that will be hooked up via sequence to the digital crown 
- a semicircle progress thing. 
So it seems like two images atop one another. Is this possible? For iOS it's a 
no brainier. I've dabbled in watch development but it's been a long time. 
Eric

Get Outlook for iOS
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Debugging a privileged helper

2017-01-26 Thread Damien DeVille
Are you specifying the MachService you use for your XPC connection in
your launchd job?

On Thu, Jan 26, 2017, at 10:30 AM, John Brownie wrote:
> I have a working app in Objective-C that has a privileged helper. I am 
> creating a different app, this time in Swift, and need a privileged 
> helper. As far as I can tell, I have mirrored all the appropriate 
> settings, but it's not working.
> 
> Calling SMJobBless succeeds, and the job is installed appropriately in 
> /Library/LaunchDaemons and /Library/PrivilegedHelperTools. However, when 
> I try to activate it via NSXPCConnection, all appears to be fine in the 
> host app, but the helper tool never launches, as far as I can tell. I've 
> run out of places to look for problems, so I need some more ideas on how 
> to track down the problem. Any suggestions?
> 
> Thanks in advance!
> -- 
> John Brownie
> In Finland on furlough from SIL Papua New Guinea
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/damien%40ddeville.me
> 
> This email sent to dam...@ddeville.me
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS app groups sharing SQLite databases, notifications

2017-01-26 Thread Damien DeVille
I haven’t been using SQLite directly in an app group but I’m using Core
Data (with a SQLite store type), which is supported by Apple and works
fine (they’ve also recently added `+[NSManagedObjectContext
mergeChangesFromRemoteContextSave:intoContexts:]` that makes merging
Core Data changes from another process much easier). So I would assume
anything SQLite needs to do multi-process arbitration will work since
it’s used and supported by, at least, Core Data.

Regarding IPC, as you said, you can use Unix domain sockets or Mach IPC.
Sockets are easy, you just bind to a path in the app group and
write/read from both processes. But yeah, fairly low-level.

I personally find Mach IPC somewhat easier to use. On iOS, you can use
`CFMessagePort` (note that these functions are documented as not
available on iOS but they are public, available and work, at least last
time I tried, so keep that in mind). One process will act as the
"server" and call `CFMessagePortCreateLocal` while the other process(es)
will act as "client(s)" and use `CFMessagePortCreateRemote` to get a
matching message port. Note that `CFMessagePortCreateLocal` will need to
register the Mach service name with the bootstrap server and dynamic
Mach service registration is inherently restricted by the Sandbox. The
trick is to use a Mach service name that begins with the app group
identifier, that’s how it also works on Mac.

If you don’t need to send any user data but simply notify the other
process, the simplest way is probably to use the Darwin notification
center (as you said). You can get it via
`CFNotificationCenterGetDarwinNotifyCenter` and send notifications as
you do in process. It’s based on notify.h so I guess the messages bounce
via `notifyd`. Note that your user info dictionary will not make it
through (that’s the same behavior for sandboxed apps on Mac) so it’s
marginally useful if you need to send user data. I believe it also used
to be the "Apple recommended approach" when they introduced WatchKit
extensions a few years ago and was mentioned in some WWDC session.

On Mon, Jan 23, 2017, at 01:20 PM, Jens Alfke wrote:
> I’m looking into the feasibility of sharing a SQLite database between
> multiple iOS apps by the same developer, using an “app group”. 
> 
> The app group entitlement grants a shared directory where the database
> file can be stored, but SQLite also relies on file locking and shared
> memory (via a mapped file) to arbitrate access. The Apple docs I’ve seen
> don’t explicitly say whether those mechanisms will work. I can’t think of
> any reason they wouldn’t work for any file that both processes have
> access to, but it would be nice to have confirmation. Have other people
> successfully shared SQLite databases using an app group?
> 
> I’ll also be needing some limited inter-process notifications, so that
> one app can notify the others after it makes changes in the database.
> Most of the time this won’t be necessary since generally only one app is
> active, but there can be situations where a backgrounded app can modify
> the database, e.g. if it receives a push notification while in the
> background, or if it uses a background task to finish some activity after
> being backgrounded.
> 
> Apple’s docs say that Mach IPC and Unix domain sockets can be used; but
> I’ve used both in the past and they’re rather low-level and messy. The
> CFNotification “Darwin Notification Center” seems like a better approach;
> it’s available on iOS, and the docs say it’s implemented using Mach
> notifications, which should work. Has anyone used it within an app group?
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/damien%40ddeville.me
> 
> This email sent to dam...@ddeville.me

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

setFontManagerFactory:

2017-01-26 Thread Raglan T. Tiger
According to the docs if one does:

   [ NSFontManager setFontManagerFactory:[ EFontManager class ] ];

before the main nib file is loaded and where EFontManager is a subclass of 
NSFontManager and EFontManager does implement init as its designated 
initializer.

My problem is that my init method for EFontManager is never called.

@implementation EFontManager

- (instancetype)init
{
self = [super init];
if (self)
{
NSLog ( @"EFontManager" );
}
return self;
}


So, what secret sauce am I missing for my init method to be called?





-rags



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem using NSView's scrollRect:by:

2017-01-26 Thread Quincey Morris
On Jan 25, 2017, at 23:37 , Quincey Morris 
 wrote:
> 
> There’s yet something else going on here

I tried creating a project with your code, and there is indeed something else 
going on here:

1. In a default, non-storyboard, non-document macOS application created in 
Xcode 8.2.1, the main window’s content view (the parent of your 
programmatically created view) has “wantsLayer” turned on. You can see this in 
the “View Effects” inspector (the rightmost inspector tab in IB). This is 
enough to prevent the scroll method from doing what you expect.

2. When I turned this off, the scroll method call (in the action method) was 
not enough to trigger redrawing of the view, so nothing happened immediately. 
However, as soon as something happened to trigger a view update, the moved 
image appeared.

3. It still did not work exactly right, because the window has rounded corners 
at the bottom left and right, and the bottom left of the red rectangle was 
clipped away by the round corner. When copied by the scroll method, the 
“missing” piece of the red rect was filled in with another color.

So:

— you are going to have to turn off Core Animation for your view hierarchy

and then you are going to have to do all 3 things that it says to do in the 
documentation:

— scroll to move pixels

— origin change so that your draw method re-draws the rest of the revealed 
content in the correct, “scrolled” place

— a call to the setNeedsDisplayInRect method to trigger a view draw/update cycle

plus:

— careful calculation of which pixels are actually moved, in case the visible 
area of your view is not the simple rect that you expect it to be


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Debugging a privileged helper

2017-01-26 Thread John Brownie
I have a working app in Objective-C that has a privileged helper. I am 
creating a different app, this time in Swift, and need a privileged 
helper. As far as I can tell, I have mirrored all the appropriate 
settings, but it's not working.


Calling SMJobBless succeeds, and the job is installed appropriately in 
/Library/LaunchDaemons and /Library/PrivilegedHelperTools. However, when 
I try to activate it via NSXPCConnection, all appears to be fine in the 
host app, but the helper tool never launches, as far as I can tell. I've 
run out of places to look for problems, so I need some more ideas on how 
to track down the problem. Any suggestions?


Thanks in advance!
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Overriding the release mehod

2017-01-26 Thread Bill Cheeseman
I don't disagree with this sentiment, but I would like to point out the other 
side of the coin.

When I ask a question about how to do something, I find all too often that my 
question never gets answered. Instead, the thread gets taken over by an 
argument over whether anybody should ever do that.

While it's good to hear about the dangers of doing something or alternative 
ways of doing it, I would generally also like an answer to my question.

> On Jan 26, 2017, at 7:50 AM, Sandor Szatmari  
> wrote:
> 
> I would take that one step further and say that because I expect that type of 
> deep introspection I enjoy when find the answers to questions I intend to 
> post before posting them, while preparing an email.  As such, I find reading 
> the discourse of this list interesting and valuable.
> 
> Sandor
> 
>> On Jan 25, 2017, at 18:49, Jonathan Hull > > wrote:
>> 
>> One of my favorite things about this list is that the standard response to a 
>> question is to ask about the underlying motivation.  It shows that they are 
>> prepared to think deeply about your problem and don’t want to just give you 
>> a cookie cutter answer.  One of the main signs of an intelligent person in 
>> my mind :-)
>> 
>> Thanks,
>> Jon

-- 

Bill Cheeseman - wjcheese...@comcast.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Overriding the release mehod

2017-01-26 Thread Sandor Szatmari
I would take that one step further and say that because I expect that type of 
deep introspection I enjoy when find the answers to questions I intend to post 
before posting them, while preparing an email.  As such, I find reading the 
discourse of this list interesting and valuable.

Sandor

> On Jan 25, 2017, at 18:49, Jonathan Hull  wrote:
> 
> One of my favorite things about this list is that the standard response to a 
> question is to ask about the underlying motivation.  It shows that they are 
> prepared to think deeply about your problem and don’t want to just give you a 
> cookie cutter answer.  One of the main signs of an intelligent person in my 
> mind :-)
> 
> Thanks,
> Jon
> 
>> On Jan 25, 2017, at 3:38 PM, Greg Parker  wrote:
>> 
>> What Are You Trying To Do™ is in fact precisely the correct response to your 
>> question. Some overrides of -release need to call [super release]. Others do 
>> not. It depends on … what they are trying to do.
>> 
>> Overriding release to unregister an observer is almost certainly a bad idea, 
>> but yes, such an override ought to call [super release] if the object is 
>> expected to be retained and released and deallocated normally. 
>> 
>> 
>> -- 
>> Greg Parker gpar...@apple.com  Runtime 
>> Wrangler
>> 
>> 
>>> On Jan 25, 2017, at 8:23 AM, Dave  wrote:
>>> 
>>> I hate it when people as that question! There are some memory leaks in a 
>>> 3rd party package. It overrides release to unregister an observer but 
>>> doesn’t call super. If I call super the leaks go away and all is well. I 
>>> just want to know where is it documented really, I can’t find it searching 
>>> the docs.
>>> 
>>> Cheers
>>> Dave
>>> 
 On 25 Jan 2017, at 15:55, Mike Abdullah  wrote:
 
 You’re inevitably going to get asked this:
 Why on earth are you overriding release? It’s an incredibly niche thing to 
 do, and the answer probably depends a lot on why you’re overriding it.
 
> On 25 Jan 2017, at 16:52, Dave  wrote:
> 
> Hi,
> 
> Does [suoer release] need to be called if you override this method? I’m 
> 99.9% sure it does, but I can’t find it anywhere it actually says it 
> in black and white.
> 
> All the Best
> Dave
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
>> 
>> This email sent to jh...@gbis.com
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com