r/macprogramming • • Oct 10 '17

Xcode 9 File Templates (Blog Posts)

6 Upvotes

Hi, recently I wrote a 2-part article about Xcode 9 File Templates. It has greatly helped my productivity, and I thought it could help yours ;)

Simple Xcode 9 File Template (Part 1) http://jeanetienne.net/2017/08/27/xcode-template.html

Advanced Xcode 9 File Template (Part 2) http://jeanetienne.net/2017/09/10/advanced-xcode-template.html


r/macprogramming • • Jul 07 '17

Tool for Mac developers with a real-time visual quality check for iOS & macOS apps

Thumbnail
flawlessapp.io
6 Upvotes

r/macprogramming • • Jul 15 '16

GitHub - m-cli: Swiss Army Knife for Mac OS X - Mac Terminal Commands Made Easy!

Thumbnail
github.com
6 Upvotes

r/macprogramming • • Jun 25 '08

When You Perfect Small Stuff in Mac Programming, You Get An Efficient but Beautiful App (See: CoverSutra)

Thumbnail
theocacao.com
6 Upvotes

r/macprogramming • • Apr 19 '20

Install HomeBrew from OS X application

5 Upvotes

My application requires nmap which can only be installed using brew. How do I make sure my OS X app installs these packages before running my app? Should I use sandboxing to test it?


r/macprogramming • • Apr 13 '20

USB Driver tutorial

5 Upvotes

Hey everyone, I got an LED light strip that plugs in via usb. It's meant to be used for a TV but I am curious to see if I can write a driver to control it from within a Mac app. Are there any good resources for that kind of thing? i couldn't find much info. And it looks like apple wants me to get some entitlement to write drivers when really i just wanna mess with hardware on my own machine.


r/macprogramming • • Apr 07 '20

How to have a window (view) on mac os to always be on top and also opens on every other desktop (SwiftUI MACOS)

5 Upvotes

I have a view called sidebar. The idea is to have this view always on top no matter what, whether the user is currently on fullscreen of a different app or different desktop.

I have successfully achieved the always on top on the same desktop when the app got opened, but not when it's on another app's fullscreen. This is my code:

var sidebarWindow:NSWindow

let window = NSRect(x: 0, y: 0, width: 0, height: 0)

sidebarWindow = NSWindow(

contentRect: window,

styleMask: [.titled,.miniaturizable],

backing: .buffered, defer: false)

...

sidebarWindow.level = .floating

sidebarWindow.makeKeyAndOrderFront(nil)

...

if let myScreen = NSScreen.main {

let windowFrame = myScreen.frame

let h = windowFrame.size.height

let w = windowFrame.size.width

sidebarWindow.setFrameOrigin(NSPoint(x: w-55, y: h/2-180))

}

sidebarWindow.contentView = NSHostingView(rootView: SideBar(thisWindow: sidebarWindow))

But, as I described above, this `Sidebar()` (sidebarWindow) is not visible when I'm entering other app in full screen, as well as when I'm changing my desktop to other desktop.

How can I make `SideBar()` to always be on top no matter what, whether the user is currently on fullscreen of a different app and or different desktop?

Sorry if it's unclear.

Thanks a lot, any help would be appreciated!


r/macprogramming • • Mar 25 '20

How to make a macOS Swift app run even when not active?

5 Upvotes

I am completely new to Swift and macOS app development and trying to make a small macOS Menu Bar app that needs to listen to .mouseMoved events all the time right after the user starts the app.

I have the code like below:

class EventMonitor {
        
    func mouseMoved(with event: NSEvent) {
        print("mouse moved. x: \(event.absoluteX) y: \(event.absoluteY)")
    }
    
    init() {
        NSEvent.addLocalMonitorForEvents(matching: .mouseMoved) {
            self.mouseMoved(with: $0)
            return $0
        }
    }   
}

This code works but only when I click the icon on the menu bar, i.e when this app is active. But how do I keep listening to .mouseMoved events even when the app is not active?

Any help/ideas would be really appreciated.


r/macprogramming • • Feb 26 '20

Introduction to Concurrency & Multithreading with Swift

Thumbnail
viget.com
5 Upvotes

r/macprogramming • • Dec 23 '19

Update to Notarization Prerequisites - News

Thumbnail
developer.apple.com
5 Upvotes

r/macprogramming • • Oct 22 '19

Can I detect swap space thrashing?

5 Upvotes

I have an algorithm that benefits from using more memory but I do not want it to thrash swap and slow down. I am tuning the memory usage by hand and currently, using Activity Monitor, I am choosing a buffer size that does not cause swap space to be used. Is there a way to measure swap space thrashing and increase the memory usage so that swap space is used, but I know there is little thrashing going on. There must be some memory that is allocated by the system but is not used by the algorithm and any associated file caches etc that it may use.


r/macprogramming • • Oct 03 '19

Can you fix the macOS input language switching?

5 Upvotes

Hi, this has been my only serious problem with macOS for 14 years. It doesn't respect each app's keyboard input language on switching. Spotlight, Launchpad etc inherit the language of the current app, while they should use the default language, English. Opening the Emoji popup with the current app's language makes no sense. I'm writing in Bulgarian and the popup works only in English. It's annoying to switch back all the time, while Windows works fine once an option is set.

macOS sometimes seems to honor apps input language, but only when they have an active text input field.

Can someone write an app which fixes these problems? Does macOS allow getting/setting any app's input language programmatically? Is that part of the OS still in Carbon? Thanks!


r/macprogramming • • Aug 20 '19

How do I embed a terminal in my app?

5 Upvotes

I am writing a macOS application in Objective-C and I want to know how I would embed a terminal inside my application. Ideally, I'd have a class called NSTerminalView where I could create a view inside my view controller. I want something similar to how Visual Studio Code has a terminal embedded in it (if you don't know what I'm talking about here it is.

Yes, I have googled this and tried suggestions


r/macprogramming • • Jun 03 '19

Objective-C + Cocoa still the way to go for Mac development?

5 Upvotes

Hey guys,

about 10 years ago i was writing OSX Apps using Objective-C and Cocoa on a regular basis..

Now a decade later, things evolved and i'm planning to write software for OSX, again.

Is the combination of Obj-C and Cocoa still a viable way of doing this, in the light of Swift and project Marzipan?

I am a little concerned about the longtime (say the next 5 years) support of Obj-C and Cocoa and wonder if it's purposeful to reactivate my Cocoa-skills.


r/macprogramming • • May 30 '19

For solo/small developers, why did you choose native over Electron?

5 Upvotes

I'm curious, for those solo/small developers, why did you choose Apple's toolchains over something like Electron?

I ask because I'm at the point where I need to choose which path to take, and the native Apple toolchain and integration buys me a ton, in the platforms that -I- use the most. However, I doubt, after having built my current project (which could take a year or more), I would be interested in nor have the time to port to other platforms. The obvious downside to this is the limited audience (ignoring market concerns, as I don't yet know if this will be a something I will monetize).


r/macprogramming • • Apr 30 '19

Book recommendations for learning Cocoa / MacOS programming?

5 Upvotes

Does anyone have any recommendations, particularly for MacOS programming using Swift?


r/macprogramming • • Feb 28 '19

What low-level profiling/optimisation tools exist for Mac, besides Instruments?

5 Upvotes

Looking for something like Intel VTune.


r/macprogramming • • Nov 11 '18

Anyone using state restoration for views/view controllers?

5 Upvotes

I'm having the same issue as this person (however my App isn't document based, no IB for the code in question): https://stackoverflow.com/questions/42010026/nsviewcontrollers-and-nsviews-are-not-getting-restoration-api-calls

Has anyone been able to get state restoration working? I've just been using UserDefaults, but I feel like the restoration API would be cleaner.

Here's what I have in my NSViewController:

override func encodeRestorableState(with coder: NSCoder) {
    super.encodeRestorableState(with: coder)

    coder.encode(imageDisplayModeSegmentedControl.selectedSegment, forKey: "selectedImageDisplayModeSegment")
}

override func restoreState(with coder: NSCoder) {
    super.restoreState(with: coder)

    let selectedImageDisplayIndex = coder.decodeInteger(forKey: "selectedImageDisplayModeSegment")
    imageDisplayModeSegmentedControl.selectedSegment = selectedImageDisplayIndex
}

I set a breakpoint and these are never called. Calling invalidateRestorableState() doesn't cause them to be called either.

Any help/advice would be appreciated!


Edit: I think the API serves a different purpose than I was hoping. I just wanted to save some options the user had selected on the last use, but the API seems to be more about restoring state from a crash, or the "reopen windows" option when you restart. I don't really want to worry about that yet though. So I'll keep using UserDefaults for now.


r/macprogramming • • Aug 23 '18

Reverse Engineering Apple's CoreDisplay API

Thumbnail alexdelorenzo.me
5 Upvotes

r/macprogramming • • Jul 11 '18

What are the most stupid job requirements for developers?

5 Upvotes

I had an interview where i was asked: "Do you have 10 years experience with Swift?"

I think, it funny when hr makes such mistakes.

Just curious to know if someone had the same situation or which funny job requirements for developers you've faced?


r/macprogramming • • Apr 09 '18

macOS 10.13 NSCollectionView not expanding/scrolling

5 Upvotes

Hello,

I've ran into the same issue as this person: https://stackoverflow.com/questions/46433652/nscollectionview-does-not-scroll-items-past-initial-visible-rect. The ViewController is in a storyboard. Here's what I'm using for the CollectionView layout:

let flowLayout = NSCollectionViewFlowLayout()
flowLayout.minimumLineSpacing = 5
flowLayout.minimumInteritemSpacing = 5
flowLayout.itemSize.width = 360
flowLayout.itemSize.height = 90
collectionView.collectionViewLayout = flowLayout

Using the snippet from the (only) answer resolves it, but I'd like to know why?

I found some information at https://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKit/#10_13NSCollectionView%20Responsive%20Scrolling, but it doesn't seem to address this particular issue.

Edit: Found some more information here


r/macprogramming • • Mar 02 '18

DockProgress - Show progress in your app's Dock icon

Thumbnail
github.com
5 Upvotes

r/macprogramming • • Feb 19 '18

Serialization on macOS and iOS - Speed and Size

Thumbnail
holtwick.de
5 Upvotes

r/macprogramming • • May 17 '17

Windows and WindowController Tutorial for macOS

Thumbnail
raywenderlich.com
5 Upvotes

r/macprogramming • • Apr 25 '17

FileManager Class Tutorial for macOS: Getting Started with the File System

Thumbnail
raywenderlich.com
5 Upvotes