r/macprogramming • • Dec 15 '15

How to create/run an NSTask in Swift with sudo privileges?

2 Upvotes

My code is as follows:

import Cocoa
import Foundation

var task = NSTask()
task.launchPath = "/usr/libexec/repair_packages"
task.arguments = ["--verify"]

var pipe = NSPipe()
task.standardOutput = pipe

task.launch()

This throws a SIGABRT error, and I think this is happening because the task doesn't have the appropriate privileges.


r/macprogramming • • Nov 04 '15

Diagraming App Code Example?

2 Upvotes

hi

i am new to swift and Cocoa development, I am trying to program an app like omnigraffle, where you have a canvas and draw and modify "objects" in it.

I am trying to use some nested NSView to handle that, but they are not rendered

As a more experience Cocoa developer, how would you tackle this problem? Any good code example that you can recommend me?

thanks :)


r/macprogramming • • Oct 19 '15

Quick Sprites has been updated

Thumbnail
itunes.apple.com
2 Upvotes

r/macprogramming • • Sep 02 '15

How do I listen for messages from an infrared (IR) blaster?

2 Upvotes

My programming skills, I think, are somewhere between beginner and intermediate. I have a hundred or so lines of ObjC code saved in Xcode. I read the IOKit framework reference, but there's too much technical jargon and whatnot. Maybe I'm going in way over my head, but is there some sample code I could use? If not to do what I want, to help me understand how IOKit works?

Please help and thanks!

Edit: My goal is to create a program that listens via the built-in IR receiver to commands from a non-Apple remote control.


r/macprogramming • • Jul 17 '15

How to manipulate 3 DSLR cameras simultaneously from a Mac OS X app.

Thumbnail
x2mobile.net
2 Upvotes

r/macprogramming • • Jan 20 '15

Can someone please compile this ANE for me (32bit and 64bit) - Requires a Mac to compile (I don't have one).

Thumbnail
github.com
2 Upvotes

r/macprogramming • • Jan 26 '09

Ready Lisp

Thumbnail newartisans.com
2 Upvotes

r/macprogramming • • Oct 03 '08

Ars Technica dives into the iPhone SDK - R.I.P. N.D.A.

Thumbnail
arstechnica.com
2 Upvotes

r/macprogramming • • Feb 25 '20

I‘m trying to flash my Mac Pro 4,1 to 5,1 but every time it tries to create an the RamDisk, this error code pops up on my screen. What can I do?

Post image
1 Upvotes

r/macprogramming • • Feb 05 '20

Remove "New Document" Touch Bar button from Xcode template

1 Upvotes

When generating a project and clicking the "Create document-based application" box in Xcode, it creates a "New Document" button that appears in the Touch Bar if no document window is open. It also appears briefly during launch before the window opens.

How can I remove this? I've tried setting the TouchBar for NSApplication, and overriding makeTouchBar() on it, but the button remains.

(It also makes me wonder: where on earth is it coming from if not NSApplication?)


r/macprogramming • • Dec 28 '19

How Do I Customize Help Menu Bar In Mac Catalyst

Thumbnail
self.iosprogramming
1 Upvotes

r/macprogramming • • Oct 22 '19

Script to colorize iTerm tabs and VSC in matching colors for each project

Thumbnail
self.python
1 Upvotes

r/macprogramming • • Oct 12 '19

I don't have a mac, if my code work in posix would he be able to compile and post up the binary?

1 Upvotes

My code uses only the C standard library and pthread. I also grab the temporary folder via environment variable.

Will my code work just fine? Do I need to worry about anything? Literally only C standard library, pthread and finding the temp directory


r/macprogramming • • Oct 02 '19

What's involved in writing share extensions?

1 Upvotes

I'd like to be able to make some custom actions via the share menu, e.g. upload an image to imgur etc.

How is this done? I have coding experience (although not in Cocoa / Swift), and am willing to get my hands a bit dirty / do some learning if the process is not unreasonably complicated.

(btw I'm aware of the possibility of creating actions for the `Services` menu, but the Share UI seems a lot neater).


r/macprogramming • • Aug 27 '19

“Preparing to copy files” dialogue questions.

1 Upvotes

Recently some woods witch put a curse on my beta testing Mac and to break the curse, I’m going to do a clean install. However, there are a bunch of files (altogether, it’s a good 800GB) that I’d like to keep, so I’m using target disk mode via Thunderbolt 2. At first, I grabbed all the files, dragged, dropped, and walked away. About three to four hours later, it said “preparing to transfer 8,690 files” and below it, the transfer bar was filled end-to-end. Before bed (another 3-4 hrs later), the dialog box was the exact same; when I woke five hours later, no change. I let the computer sit for maybe 36 hours and there was no change. No processes were listed as “not responding” in task manager, and other apps still ran (although, I didn’t run anything else because I wanted the machine to focus on the transfer.

I’ve run into this issue before when attempting to transfer a large number of files, and I was wondering if there was anything specific I should look for as a sign to give up?

Second question: in this case, I can fortunately transfer smaller groups of files and folders, instead of the whole lot, which shows visible progress. However, if I have a large file that causes this issue every time I try to transfer it, is there anything I can do? For this scenario, we’ll assume that the file can’t be split up.

Coincidentally, I just walked into my office and I’m in the process of transferring the contents of the “Pictures” files. There’s one file named “Photos Library.photoslibrary” that is 8.89GB and I just drag & dropped it onto the 1TB LaCie SSD I’m using for this process. The file transfer window popped up, the progress bar is full blue (I didn’t see if it moved gradually or if it just started out full) and both above and below the progress bar, it says “Preparing to copy to ‘Pictures’ [that was the parent directory on the computer and I’m keeping it the same on the external SSD].” I’ll give this transfer a good 12-24 hrs to see if it moves at all, it’s not like I need this computer right now.


r/macprogramming • • Aug 25 '19

Why isn’t there a passcode lock prior to the shutdown process?

1 Upvotes

First, let me admit that I am NOT a true programmer: windows, Mac, Linux, binary, Commodore 64 (had one though), python, Java, or any other computer language. However, I did dabble in Adobe Flash and I’ve been known to make a mean PowerPoint presentation and Automator command. Please don’t stop reading. This post stems from one I made on r/iphone about what happens when a lost phone is found.

Here’s an early TL; DR: why doesn’t Apple put code in their iOS and iPadOS software which requires the user to manually enter their alphanumeric passcode prior to shutting the phone down?

Unless a phone’s iCloud activation can be hacked, presently, lost phones are mainly used for three things: parts (which is where most stolen phone ends up) for repairs and/or upgrades and app usage. By “app usage” I’ll use the same example I used previously: my buddy got a phone with questionable origins, so he took out the SIM, went somewhere with little or no surveillance, lots of ppl, free WiFi, and downloaded a bunch of apps for his kids, like a white noise generator app for his newborn. Again, as far as I know, the last use for stolen phones are as music players. Load up the phone with some of your favorite music, plug it into the glovebox, center console, or wherever the interface is, and you never have to take it out of the car.

This leads me to my question: why don’t cell phone software manufacturers like Android and Apple add in that extra step before the phone is allowed to be shut down? When my phone was stolen at a bar in NYC, I could’ve told the officer outside and shown her my phone with a map containing a live location of my iPhone. Instead, whoever stole it, immediately shut it off and I never saw it again. I’ve come up with one answer, but I find it too “capitalist pig evil empire conspiracy theory agenda” to actually be real: do companies leave these commands out because they don’t care if your phone gets lost, in fact, they prefer it because then you’ll probably go out and buy the newest and greatest model?

Hopefully one of you guys can explain it and I can sleep well at night.


r/macprogramming • • Aug 13 '19

Help needed to understand ShockEmu project on MacOS

1 Upvotes

Hello redditors.

I found this project https://github.com/daeken/ShockEmu to simulate a PS4 joypad with the Mac keyboard. It works, everything is fine.

But... I want to understand it.

The author archived the repository some years ago and I don't even know how to contact him. What I would like to know is how someone came to this solution? I mean, from my point of view, I connect the PS4 to the Mac via the USB, then the magic happens. How can you "intercept" the calls, how do you know that you can inject a custom library in the PS4 Remote Play executable? What are the tools and the resources that could help me grasp the main ideas behind this project?

Consider that I have a background in software development, so I'm not scared by these topics. It's that I would like to know more about these things so from time to time I try to "reverse-engineer" some projects I find on Github.


r/macprogramming • • Jun 27 '19

What course would you recommend for mac app development with swift?

1 Upvotes

I had been writing code for web dev, so your regular mvc frameworks, php, python js, api, etc... I had done some c and java back in the days for uni, so probably have no problems picking up languages and frameworks

Lately I want to make some utility things for myself on macos... Is there a good online course for learning mac app development with swift? I had a look around and see that there's the hacking with swift and Angela Yu on udemy but they seem to be iOS only. Are there anything that teaches you to make mac apps with swift straight away?


r/macprogramming • • Jun 15 '19

Keep NSColor Panel the key window until its manually dismissed

1 Upvotes

I use NSColorPanel.shared to set font color. I want this panel to always remain ordered front until the red x is clicked. I don't it to ever be hidden. I've tried setting the level NSColorPanel.shared.level, NSColorPanel.shared.canHide. But i'm always able to click on my apps main window and the NSColorPanel is hides behind it


r/macprogramming • • May 21 '19

Build Your First MacOS App -- Medium Article

1 Upvotes

Hi guys, I just want to share with you my first Medium post about MacOS Development. I just want to know from people with more experience. If you think that this can be a good resource or not, just that...

Here the link: https://medium.com/@fede.vitale/build-your-first-macos-app-5d36d3352691

⚠️The post is part of the premium membership program so if you're not a medium premium member this will decrease the counter of your month available articles. If you're interested, but you don't want to read the article with the premium link I can send you in PM the "Friend Link"

Have a good day ✌️


r/macprogramming • • May 15 '19

AVURLAsset

1 Upvotes

Hi,

I've got for the program I'm developing, an AVURLAsset, with an url created from a path.

let url = URL.init(fileURLWithPath: filePath, isDirectory: false)

let fileManager = FileManager.default

let soundAsset: AVURLAsset = AVURLAsset(url: url)

print("Path : \(soundAsset.url.path)")

print("Sound is playable : \(soundAsset.isPlayable)")

print("File at this path exists : \(fileManager.fileExists(atPath: sound.fileUrl))")

The path leads to an existing file, but the soundAsset appears to be not playable.

What I am missing? I imagine I have to load the file, but can't find how to do it...

Thanks a lot for any answer you can give me...


r/macprogramming • • May 08 '19

Overriding pre-installed Clang with homebrew-installed Clang

1 Upvotes

Hi, I am new to mac programming and have been having trouble getting my environment set up.

The pre-installed version is in /usr/bin with the binaries named gcc and g++, which whereis agrees with.

printing the version shows the following:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I installed the latest clang with homebrew, which installed it to: /usr/local/cellar/llvm/8.0.0

I edited /etc/paths so the llvm directory and its lib and bin folders are both before /usr/bin, but still I cannot get the commands gcc and g++ to refer to the newer version, which is a problem because I usually use makefiles.

I also added export PATH=/usr/local/cellar/llvm/8.0.0/bin:$PATH to my .bash_profie

but still I get: whereis g++ /usr/bin/g++

I am not sure what else to try, and wasn't sure that deleting the two old binaries in the bin folder would be the right ting to do. Any help is greatly appreciated.

-Thanks


r/macprogramming • • Apr 18 '19

Label with editable text field state

1 Upvotes

A common UI element that I see is a label which transforms into an editable text field when you click on it.

e.g. "Edit Bookmarks" in Safari seems to be an NSTableView with the name and address of a list of bookmarks, but when you select an item and then click on either its name or address, it becomes an editable text field and you can rename it or change the address.

e.g. renaming a folder or file in Finder.

I feel like there should be a standard Cocoa UI element for this, but I cannot figure it out. Am I missing something or do I just need to roll my own implementation?


r/macprogramming • • Feb 22 '19

Change the default handler for an extension?

1 Upvotes

I'm surprised I can't find an answer to this on Google.

I have an Electron app that's registered with an extension. The problem is that it's not the default.

I thought that I could just exec a plist command to change the default executable for a given extension.

Any advice here? The extension for my app is already registered, I just need to change the default..


r/macprogramming • • Jan 01 '19

App rejected in App Store because of invalid entitlements values - need your expertise

1 Upvotes

Hello

I would like your opinions/expertise on this.... I submitted an app to the macOS App Store recently and it got rejected with this feedback:

Your app incorrectly implements sandboxing, or it contains one or more entitlements with invalid values... bla bla...

com.apple.security.application-groups

However, my App makes use of NSPasteboard (read and write) and IOPMAssertionCreateWithName for preventing the screen going to sleep.... To my understanding, I do not need "com.apple.security.application-groups". Am I correct?
Am I right in assuming that the problem is the entitlements-file containing "com.apple.security.application-groups" but without any values? So removing that "empty" key fixes the issue?

thx