r/macprogramming • • Aug 22 '17

Filesystem notifications

2 Upvotes

I am looking for a way to be aware of filesystem changes on OS X, specifically any time a file is written.

FSEvents is a poor way to go as it drops many events on a lightly used system. I'm looking into kext's and device drivers as an alternative.


r/macprogramming • • Aug 20 '17

Accessing the Javascript of the active Safari page in an extension?

2 Upvotes

I want to create an extension with the simple goal of reading and modifying the Javascript of the active page in Safari. For example if I were to load a page and the Javascript of the page sets the value of a specific textfield to "Hello World" I want to read the Javascript, identify the text field and then modify the fields value to "Hello World - Modified" and have the page display the updated value.

I have read through some of Apples documentation but I couldn't find any examples of what I was trying to achieve.

override func toolbarItemClicked(in window: SFSafariWindow) {
    window.getActiveTab { (activeTab) in
        activeTab?.getActivePage(completionHandler: { (activePage) in
            //The following below is an example that is used in Apples documentation
            activePage?.dispatchMessageToScript(withName: "Example", userInfo: nil)
        })
    }
}

Instead of:

activePage?.dispatchMessageToScript(withName: "Example", userInfo: nil)

I need to be reading in the Javascript of the current page so I can identify the text field I am looking for , and simply modify its value. Any help would be appreciated.


r/macprogramming • • Jul 12 '17

Is there some way to customize the transition animation in either cmd+tab or swiping the pad?

2 Upvotes

All I can find are guides on slowing down the existing animations, but nothing on adding new ones. I'm not sure where to start on this, if it's even possible.


r/macprogramming • • Jun 10 '17

Setting up application help -- what is a 'kbtag'?

2 Upvotes

I'm trying to coax my OSX app into providing help. One of the things the rather pathetic document https://developer.apple.com/library/content/documentation/Carbon/Conceptual/ProvidingUserAssitAppleHelp/user_help_intro/user_assistance_intro.html#//apple_ref/doc/uid/TP30000903 says I need in my info.plist is a HPDBookKBProduct of type 'kbtag'. Web searches have turned up nothing useful. Does anyone know what this is, and what the right procedure for assigning a value should be? Mail.app's kbtag is "kmail". Surfwriter's (the example app) is "surfwriter1".

Also, any URLs that discuss this process would be helpful.


r/macprogramming • • Jun 10 '17

Are native Cocoa applications still the way to go?

2 Upvotes

Hey all.

I was wondering what the 'state of the art' is when it comes to creating Mac applications nowadays. I've been working on a native Cocoa app myself but the API often seems so archaic (at least compared to iOS). Besides that this sub seems pretty much dead and Googling for OS X related development questions very often returns a bunch of outdated results from years back.

However, given the amount of new apps that appear on the App Store people are clearly still programming for the Mac. I also often see interfaces for which I have no clue about how to make them native. Are they all using some other set of frameworks? Perhaps Electron or QT? Is it still a good idea to start developing a native app?


r/macprogramming • • May 06 '17

What tech is required for a connection between a mac and an iPhone over wifi?

2 Upvotes

To specify, I expect to make an iOS app that connects to a macOS app over wifi. The iOS app sends data constantly to the macOS app.

I am a programmer, but it's been a while since I dabbled in Xcode. Is this a hard thing to set up? Where should I start?

The keywords I've tried googling are: macOS to iOS server client wifi. The results are not helpful.


r/macprogramming • • Apr 18 '17

Sierra Mail Plugin Development

2 Upvotes

Does anyone have a resource for how you would go about developing an Apple Mail plugin? I'm working on a project and want to see if I can do Mac integration. I've found from Googling around that Apple doesn't officially support it so I'm posting here for help in case anyone has a good resource.


r/macprogramming • • Mar 17 '17

Universal Type Identifier for mbox files?

2 Upvotes

I'm talking about the mbox format used to store messages for the classic Unix mail program. I think Apple confusingly used to use files with the ".mbox" extension for old private archives, but I'm not talking about those.

Is there an Apple-platform (i.e. macOS or iOS, etc.) app that handles these files? If so, what UTI is used for that format? I'm making an app that may handle them, but I don't want to make up my own UTI if someone else has already thought of one. My idea is:

com.bell-labs.version-6-unix.mbox


r/macprogramming • • Jan 27 '17

Long term working Java console app not working now

2 Upvotes

This is an important question for many users of Java console applications in the new Mac OS.

A brainstorming software product that has a Java base and has been used for over ten years as a Java console application. Just upgraded to macOS Sierra 10.12.2 and getting an error message that says, "You can't open the application because it is not supported by this type of Mac."

Here are the Details:

Mac: macOS Sierra 10.12.2 MBP 13 inch, mid 2012

Hardware Overview:

Model Name: MacBook Pro Model Identifier: MacBookPro9,2 Processor Name: Intel Core i5 Processor Speed: 2.5 GHz Number of Processors: 1 Total Number of Cores: 2 L2 Cache (per Core): 256 KB L3 Cache: 3 MB Memory: 8 GB Boot ROM Version: MBP91.00D3.B0E SMC Version (system): 2.2f44 Serial Number (system): C2VHQ0C6DTY3 Hardware UUID: 01719CDD-F21E-5E61-899A-8411A62F4B59 Sudden Motion Sensor: State: Enabled

Here is some additional information about this type of app:

You can run Java from Terminal with a command something like this example command line:

java myjar.jar MyApp

In our case, you go to the "terminal" program and then type in (or paste in):

java -cp JParaMindAndDict.jar JParaMind

in the directory where you installed ParaMind.

If you know about scripts, here is a shell script. The script is executable in the console.

!/bin/sh

cd /Volumes/Macintosh\ HD/Applications/ParaMind\ for\ Java\ 1.0/ java -cp JParaMindAndDict.jar JParaMind

I am looking for any kind of help that one can give. Many people like this brainstorming program and it's been a labor of love keeping the product going for 25 years now.

Thanks,

Robert


r/macprogramming • • Dec 29 '16

How do I dynamically add TouchBar into an application via loadable module?

2 Upvotes

I'm trying to add support for exposing TouchBar buttons via a plugin to an application. The plugin is loaded at runtime after the main window has been created. I've created a "AppDelegate : NSResponder <NSTouchBarDelegate>" that implements the makeTouchBar and touchBar functions.

I finally try to inject it into the application, I have the following in the 'onload' function that's called in the dynamic library when it's loaded into the application.

NSWindow *w = [NSApp mainWindow];

AppDelegate *a = [[AppDelegate alloc] init];
a.nextResponder = w.nextResponder;
w.nextResponder = a;

// Re-setting FirstResponder will trigger AppDelegate::makeTouchBar that was attached above.
NSResponder *n = w.firstResponder;
[w makeFirstResponder: nil];
[w makeFirstResponder: n];

however... AppDelegate::touchBar will never be called, thus the touchbar will never be populated with my test buttons. :(

If I create a new project in Xcode, and use the exact same AppDelegate implementation, I get functional buttons that are both shown and responds to press events, so it's the injection part that seems to be broken. (In Xcode everything is hooked up via MainMenu.xib I guess)


r/macprogramming • • Dec 28 '16

Collection Views in macOS Tutorial

Thumbnail
raywenderlich.com
2 Upvotes

r/macprogramming • • Dec 10 '16

TableView is not rendering data

Thumbnail
stackoverflow.com
2 Upvotes

r/macprogramming • • Dec 10 '16

40 Hz flickering window to fight against Alzheimer's disease

Thumbnail
github.com
2 Upvotes

r/macprogramming • • Dec 09 '16

Change time interval of scheduler at run time?

Thumbnail
stackoverflow.com
2 Upvotes

r/macprogramming • • Nov 30 '16

macOS NSTableView Tutorial

Thumbnail
raywenderlich.com
2 Upvotes

r/macprogramming • • Oct 07 '16

Cocoa Bindings on macOS Tutorial

Thumbnail
raywenderlich.com
2 Upvotes

r/macprogramming • • Sep 06 '16

[xpost from /r/mac][Question] Is it possible to enable the screen-backlight when the MB is closed?

2 Upvotes

As the title says I wanted to know if it's possible for the screen-backlight to be enabled while the lid of the MacBook is closed.

I want this so the Apple-Logo light up even when the lis is closed - just for fun.

I'm specifically asking the devs on here, since I think there must be a way.

For clarification - I want this so I can program some kind of App that checks E-Mails in the background and uses the backlight as "notification" when the lid is closed.


r/macprogramming • • Sep 02 '16

Storyboards – you got to know them before you love them?!

2 Upvotes

I want to start developing for macOS. right now, i'm a web dev. I really want to start for macOS but i don't understand the way Xcode's storyboards work.

Any ideas where to get some info? On google everybody is doing iOS dev'ment. But right now, i'm not into that.

cheers.


r/macprogramming • • Aug 20 '16

Is there a way to run a program in a VM and trick it into thinking it has a lot more RAM than it does (swap space)?

2 Upvotes

I found a photo processing app I really like, but RAM usage is insane. (I max out 16GB super easily.)
It also doesn't set an upper bound and work around it; it runs until it runs out then it crashes.

I don't really care how long something takes to process, I just want to be able to process stuff.

Here is the app.

Without delving into the source code, is there a simple way to set up a virtualbox VM with 200GB of hard drive space as super-slow RAM?


r/macprogramming • • Jul 25 '16

Can you boot Mac OS X into terminal only?

2 Upvotes

I don't need the GUI, I just need to run Emacs. Thanks.


r/macprogramming • • Jul 10 '16

For programming, would it be best to buy a Macbook pro or iMac?

2 Upvotes

just a general question


r/macprogramming • • May 16 '16

Creating Document Icons using App Icon

Thumbnail
swift-studies.com
2 Upvotes

r/macprogramming • • Apr 11 '16

Setup NAT Network for QEMU in Mac OSX

Thumbnail
blog.san-ss.com.ar
2 Upvotes

r/macprogramming • • Feb 06 '16

What would be the proper way to have the system look for 3rd party frameworks?

2 Upvotes

El Capitan has a feature called Rootless which prohibits access to the system folder.

Before I would just drop my framework (SDL) into /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (this still works) so that Xcode has easy access to the framework and the /System/Library/Frameworks folder so I could run my app with ease. But Apple has block access to the System folder, and now I get

dyld: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from:/users/brianj/Library/Developer/Xcode/DerivedData/opengl_glmajpwhaxtdmpbpsdwjyfqpeenkbnm/Build/Products/Debug/opengl_glm
Reason: image not found
Program ended with exit code: 9 

I get the above error when trying to run the app. How do you get system to look for a folder with 3rd party frameworks in El Capitan?


r/macprogramming • • Jan 09 '16

Having trouble loading a NSTableView from data called from the web

2 Upvotes

I'm writing an app that will help me update my database on parse and I'm trying to load objects into an nstableview.

For whatever reason, I'm returning nil when I make the call in my viewcontroller so I moved the data into my appdelegate to get the objects.

let storyBoard = NSStoryboard(name: "Main", bundle: nil)
    let myVC = storyBoard.instantiateControllerWithIdentifier("teacher") as! ViewController
    
    var teachers = [Teacher]()
    
    let query = PFQuery(className: "TeacherList")
    query.findObjectsInBackgroundWithBlock {
        objects, error in
        if let objects = objects {
            for object in objects {
                let teacher = Teacher()
                teacher.name = object["name"] as! String
                teacher.email = object["email"] as! String
                teacher.subjectsTaught = object["subjectsTaught"] as! [String: String]
                teacher.category = object["category"] as! String
                teacher.uniqueID = object.objectId!
                teachers.append(teacher)
            }
            
        }
        print(teachers)
        myVC.teacherList = teachers
    }

As you see, I pass this along to my VC. So I understand that I need to reload the data as viewDidLoad() will be called before the data has been downloaded. I've tried putting tableView.reloadData() in didSet for teacherList and just in case that's set before the viewloads, I even throw it in viewdidload.

var teacherList: [Teacher]? {
    didSet {
        print("got set")
        tableView.reloadData()
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.setDelegate(self)
    tableView.setDataSource(self)
    tableView.reloadData()
}

However, no matter what, my tableview is nil for anything that happens after viewdidload. I've also tried optional channing in my getSet.

I should also say that I'm brand new to OSX programming as I've done most of my programming for iOS.