Copy an app via terminal and not just the content - terminal

I am trying to copy an app from a source (which can be anything, like a DMG mounted on my desktop, or a folder, or just the app on a usb pen drive), using terminal.
I used cp -fr since most OSX apps are in fact directories; but when I inspect the file, it does not have the original app icon, and it does not seem to work. I checked the content of the package and seems that everything is there; but for some reasons, OSX does not like it when I run the app.
If I just drag and drop the app via Finder, it works fine; if I copy it via cp -fr the app does not have its icon and does not work correctly.
Should I use something else instead of cp?

Found the solution. For such cases, ditto seems to work much better.
the main advantage of ditto is that it preserves ownership attributes and permissions, on top of file resource forks and file and folder metadata. This ensure that everything is copied 1:1.
For OSX apps, it does copy the folder and content exactly as is, and this guarantee that the app will be working correctly.

Related

Creating Dropbox like DMG package

Does anyone suggest a freeware tool/script/manual_way of creating Dropbox like DMG -
Need to ask couple of questions --
I want double clicking the Folder-Icon should copy the folder(which would contain installer and uninstaller .app files of my application) into the system's /Applications folder.
Solution -- This has been solved using Applescript and changing icon of that applescript file to the folder-icon(i.e double clicking that script will move our folder(which would be present in a hidden folder) to /Applications.Any suggestions for second and third part?
Is it possible to show hyperlink of actual dropbox.com to actually open it's website?
And how we can customize volume's/Drive icon?
You can find a way to do it by reading this: Packaging a Mac OS X Application Using a DMG ยป asmaloney.com
I believe you can also use the trick of naming a shellscript file something.command in order to make it double clickable, (but maybe it will open the terminal, -I haven't tried it).

Where does getExternalFilesDir() point to in an app running in Chrome?

I've successfully got my app running in Chrome using arc welder. And having managed to identify which files hold the sqlite database and shared preferences, I've been able to copy those across to nicely replicate how the app works on my 'phone.
On the 'phone, my app can take photographs, which it stores in the path found using getExternalFilesDir(null) and it would be nice to be able to copy those over so they can be seen when using the app through Chrome. But searching around, I've been unable to work out where this is.
I can save a file (using the app's database exporter and file-chooser) to somewhere which appears as an SD card, but no file or directory under my app's directory in ~/.config/google-chrome/Default/Storage/ext which gets changed when I do the export seems to fit.
I can see the exported file's name in def/File System/primary/p/Paths/000004.log, though as that's a data file it's not giving me any clues.
Anybody know where the virtual SD card (and so externalFilesDir) might be held?
By default ARC stores the external storage files to the Chrome HTML5 filesystem. Each app gets its own instance of the filesystem.
To put files into it, you can either:
(On a PC only) start your app, visit "chrome://inspect/#apps" for your app, and type plugin.shell('adbd') into the javascript console for it. Then you can use the Android ADB command adb push ... to transfer the data.
Or you can also add {"enableExternalDirectory": true} to your application's metadata. Enabling this option means that ARC will prompt you for the directory to use for for the external directory, and you can pick a real directory on your system to use.

How do I link directly to an alias through afp?

I'm working on an intranet web application with a file sharing server set up using AFP.
My goal is to create a link on the page that will open up Finder to a specific folder on the share network, but it has to go through an alias. I think it'd be easier to explain with an example.
For this share, there is a folder called Objects that contains a bunch of folders with unpredictable names, and a folder called Alias that contains a bunch of aliases to folders in Objects. So a link to afp://server/share/Alias/obj1 should open the folder at afp://server/share/Objects/unpredictableName, where obj1 is an alias pointing to unpredicableName.
On OSX 10.8 this works as expected, however on 10.9 and later that link opens the Finder at the Alias folder, instead of actually going into unpredictableName. What changed, and is there any way to restore the previous behavior? Thanks.

Remove Sandboxing

I have another question dealing with app sandboxing. So I need access to the users' home directory and at the same time the app should be able to shut down the Mac. This requires to not using sandboxing.
My problem is that I don't know how to remove sandboxing and being able to submit the app to the Mac App Store. I think that the archives are sandboxed because I had turned it on once..
How to remove sandboxing from the archives properly?
Thanks for your help!
On Xcode 11, you can turn off Sandboxing by removing it from the Signing & Capabilities tab:
If I understand what you are asking correctly, you'll need to remove the entitlements.plist from your project and make sure that the Summary view of your target in Xcode has sandboxing turned off:
As Derek Wade pointed out, you can make an App like GarageBand X (which behaves obnoxiously with third party plugins like Amplitube due to Sandboxing) NOT run in a sandbox by editing the binary itself with a HEX editor like HexFiend. Look for:
<key>com.apple.security.app-sandbox</key>
Immediately following that bit you'll see the true tag, which as suggested I switched to 'fals' (no extra bytes) and now GarageBand will happily interact with third party VST plugins. Huzzah.
I found if you go into the .app package, under Contents/MacOS, there should be a binary file that matches the name of your app. Copy that file to your desktop. Edit the desktop copy of the file with TextEdit. You should find within the file, the text representation (xml) of the Entitlements for the app. Find the Sandbox entitlement flag (usually set to <true/>) and change it to <false/>. You will have to unlock the file when editing. Save the file (located on the desktop). Rename the original file in the .app package (i.e. append .old to the filename). Copy the desktop file back to the .app Package location (you may have to authorize it). This should remove the sandboxing.
You cannot remove Sandbox if the user ran you application via Sandbox.
That's the whole point - don't you think ?

Creating a dual Mac/Win Autorun CD

How do I create a CD that opens a "Drag this icon to the Application folder to install" on the Mac and autoruns an installer on Windows?
Jordan Brough has a really good write-up on his blog about this:
http://jordan.broughs.net/archives/2008/03/creating-cross-platform-windows-and-mac-installer-cds
For what it's worth, this was the first result returned from a fairly simple google search...
You can use hdiutil
eg.
hdiutil makehybrid -o [output-file] [input-folder] -iso -hfs -hide-iso [mac-only-file] -hide-hfs [windows-only-files]
What you will want to do is hide the windows specific files from the HFS partition and hide the Mac only files from the ISO.
Then you would use an autorun file as your normally would on Windows.
On the Mac side there are many applications you can buy for creating a Finder window that looks a certain way but all these changes can be made within finder. You then will need to copy the DS_Store file to the CD and finder will automatically apply any changes that you have made.
Also using -hfs-openfolder will cause it to open automatically when inserted on the mac.

Resources