API documentation: LSOpenURLsWithRole() - objective-c

Recently, starting Preview on a list of gif images produced the error :-
LSOpenURLsWithRole() failed with error -600 for the file /Users/uki/repos/gif-fuzzing/test/234.gif.
However on opening 234.gif the error could not be reproduced. This error keeps repeating at random intervals of time. I've been searching around for Apple Developer Documentation on what LSOpenURLsWithRole actually does, but I could not find any(which is weird).
Could anyone point me to where the API docs of this function would be?
Has anyone had a similar error before?

fbernardo's link provides a good starting point... In this case, it's a more generic error as explained here:
https://web.archive.org/web/20191128225313/http://office.mvps.org/error/number.html#error-600
An inability to send a 'launch' event to the mach port sounds like a runtime kernel level issue... in my case, it was a zombie of a process I'd killed form the terminal holding on to certain resources, which only a reboot could solve.

I had the same issue, and found a fix without rebooting. If you Kill the WindowServer the issue with Finder no longer opening windows will be resolved. You will be returned to the login screen, and when you login again Finder should be working perfectly!

This function was available in version 10.4 to 10.10 of MacOS.
It's official complete documentation is here:
LSOpenURLsWithRole Apple documentation
To answer:
Has anyone had a similar error before?
Yes with many different applications and with many different versions of MacOS. For example, I am running a clean version of MacOS 10.13.5 where this function is deprecated. Nonetheless I have a process track which shows /usr/bin/open is calling this function.
See this other question:
Old bug: The application “Preview.app” is not open anymore

Related

Why won't CodeBlocks attach to a process?

I recently ran into an issue that I want to share Q&A style here. Hopefully it will help others, at minimum it is documented so I can find it later :)
When trying to run Ncurses in CodeBlocks it blows up when it hit initscr();. With VSCode this was not a problem, so I know there was something I am missing. With the help of StackOverflow it appears the best way to approach this with gdb (and CodeBlocks) is to attach to the process itself after it is running, rather than starting it in CodeBlocks. (Debugging ncurses application with gdb)
However, when I try to attach to the PID it just says that it was unable to attach to the process. Why is this?
I found that if I tried to run it through gdb on the commandline I also got this same issue. It comes from Kernal Hardening to prevent hacking. With this answer: https://stackoverflow.com/a/32274645/1770034
I discovered I needed to switch over to the root user. Then run echo 0 > /proc/sys/kernel/yama/ptrace_scope Now Code blocks will happily attach to the process and you can use your break points.

Using new iTunesLibrary Framework to access iTunes library on Mac OS-X

I've been looking at adding iTunes Library access to a Mac app I'm developing.
I looked at some of the existing open source implementations, such as EyeTunes and iMedia - but found them to not be quite what I was looking for. Overkill in general.
So I tried out using the Scripting Bridge, and found that while functional it was slow. And since I didn't really need to control iTunes, the slowness was not worth it. It also had the downside of relying on iTunes to be running. It also is a bit irritating to get it working in a sandboxed app (though possible.)
So I finally started to roll my own by reading the iTunes Library.xml file. That seems to be working OK. But in the process of investigating the meaning of the Distinguished Kind key/value I stumbled upon a brand new, Apple supplied iTunesLibrary.framework !!!
Beautiful - the iTunesLibrary framework docs are here.
However, when I try to initialize the framework using the code as shown in the reference link:
NSError * error = nil;
ITLibrary* library = [ITLibrary libraryWithAPIVersion:#"1.0" error:&error];
It returns nil and provides the very helpful error like so (in my Sandboxed app):
Error Domain=NSPOSIXErrorDomain Code=100001 "Could not load."
UserInfo=0x1140025b0 {NSLocalizedDescription=Could not load.,
NSUnderlyingError=0x1026fbe20 "The operation couldn’t be completed.
(OSStatus error -50.)"}
Thinking it might be a sandboxing issue, I also created a quick command line utility that attempts to init the library and it returns an almost identical error:
Failed to open library: Error Domain=NSPOSIXErrorDomain Code=100001
"Could not load." UserInfo=0x1018015b0 {NSLocalizedDescription=Could
not load., NSUnderlyingError=0x103a000e0 "The operation couldn’t be
completed. (OSStatus error 100005.)"}
Has anyone else tried out this new iTunes Library framework with anymore luck than I have had?
// EDIT: Answer below is correct. Code signing is required. The sample code in the answer is a handy starting point for using the framework. Additionally, in my case the problem was also that the iTunesLibrary framework code does not appear to work when the iTunes library is hosted on a network drive. Make this a bit of a deal breaker unless Apple fixes it.
You'll need to codesign your app using a certificate from the Mac Developer Program.
It's not documented anywhere, but, my suspicion is that this requirement was added due to iTunes cloud being a web service thing that requires accessing user accounts.
// Edit: In addition to setting CODE_SIGN_IDENTITY in the project settings as discussed above, you will also need to add /Library/Frameworks to the FRAMEWORK_SEARCH_PATHS in the project settings so that Xcode will know where to look for the #import's.
// Edit 2: I wrote a quick little sample app to show how iTunesLibrary is used, since, Apple's sample code and documentation is rather sparse: https://github.com/zadr/iTunesLibraryExample
From iTunes Library Framework Reference
You must code sign your app in order to get information back from the
iTunes Library framework.
The iTunes Library framework is available to users running iTunes
v11.0 or above.
Not sure if this is true for all of you, but in my case, I kept Code-Signing-Identity to - helped me. Now I don't need to sign the app.

Splunk Sideview Editor throws 404

I installed latest sideview utils app in my spunk 4.2.2 installation and ran straight away into a problem. Evertime I try to launch sideview editor it throws 404 errors.
Any pointers would help
This just means that you have not restarted Splunk after installing the app.
Splunk should give you a notification after installing the app through the Manager section, that a restart is required. I think that notification system in Splunk may not be working on all Splunk's supported platforms, because we seem to be getting this problem reported with some regularity, where something or other doesn't work properly and ends up being just because the server hasn't been restarted.
By the way, you'll find a ton of questions and answers about this app over on answers.splunk.com rather than here on stackoverflow.

Running Uncrustify by selecting Behavior in Xcode does nothing

I installed Uncrustify as per the instructions here:
http://noiseandheat.com/blog/2012/01/uncrustifying-objective-c-source-in-xcode-4/
Used brew for installation and added new behavior in Xcode(4.3.2) preferences.
However running the behavior from the menu does nothing. What might I be missing?
For me https://github.com/tonyarnold/Xcode-4-Uncrustify-Automator-Services worked : Automator is used to create a workflow, which will be available in Xcode to format the selected code (The link above could describe a better way - I am just saying what worked for me...)
Thanks Thomas, resource provided by you was very useful and allowed me to add automator workflows into Xcode. Only problem is that script "Uncrustify Document then Re-Indent" is showing an error "System Events got an error: Access for assistive devices is disabled". Initially I sudo touch /private/var/db/.AccessibilityAPIEnabled to enable assistive devices but this did not help.
I found a thread on similar issue here: AppleScript - System Events Error : Access for assistive devices is disabled
fanaugen says:
The problem is not the assistive devices. AppleScript seems to incorrectly return that error code when it tries to access windows of a process that can never have any windows
and he suggest to rewrite script with some changes. I am not sure if it is actually the same issue here and it's first time I am having to deal with this type of script, so I am lacking of knowledge here. Do you have any advice? Did you have a similar issue?

bootstrap server. Error in iPhone SDK

Can anyone help for the following ERROR:
Couldn't register com.india.XXX with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.
here m using xcode 4.1 and i have same project folders in my local desk.
When ever i open multiple projects with the same name its showing the above error.
Thanks in advance.
Some of the fixes that the links Saif contain may work for some, but not for me.
I have a very simple solution without restarting that will usually get you through the day.
When you get this error, before you do anything else, build for the other device (if you are running a universal application).
When you build for the other device, it kind of "overwrites" the process that creates this error. Once the other device is up and running, immediately build for the device that created the error. This will work most if not all the time, and will save you time digging through the multitude of fixes you will find in the other links.
I tried almost all of the fixes found there and none of them worked in my case. This works, but you should check your appDelegate for any bugs in your willEnter/didEnter (and other related methods).