Cocoa: font downloaded from the web - cocoa

I'm coding an app that needs a font that is not available on the system. I got the font from the web, but every time I launch the app, I get this message:
http://twitpic.com/3h4nj9
I cannot ship an app with this kind of message. I believe it's some metadata on the font file. Does anyone knows how can I solve that problem?
Thanks!

This is a security feature of the OS. You should not be trying to "solve" it.
I'd suggest obtaining a license for the font and bundling the file as a resource in your app. Or do without.
[EDIT]: I misunderstood. Since it's a file you're including in your bundle, you want to clear the com.apple.quarantine metadata from the file. Use the command
xattr -d com.apple.quarantine my_font_file.otf
You probably also want to get rid of the com.apple.metadata:kMDItemWhereFroms metadata as well.
You can just use
xattr my_font_file.otf
to get a list of all the extended attributes that the OS is keeping on the file. Delete as appropriate (with the -d flag).

Related

Tell macOS that a custom file format without a .png extension is a valid png

I need a custom file format for my application and I thought that I could make a superset of PNG. macOS shows previews of regular PNG files (and APNGs with a .png extension) in Finder. I want macOS to show a preview of my file format even though it doesn't have a .png extension. I need to tell macOS that files with a .px2 extension are valid PNGs that can be decoded by a regular PNG decoder.
I've been reading this page trying to find the right set of keys to use but I'm not having any luck. I thought that NSExportableTypes might be the answer but that doesn't seem to be it.
To test this, I'm changing the extension of an APNG file from .png to .px2. I realise that I could just use the .png but I think that could be a little confusing (both for the user and the OS).
There's a slight chance that what I'm trying to do is impossible!
I think you may be looking at 2 different problems: one is the OS recognizing the file type and linking it to your application, the other is being able to show the preview.
The latter is going to be highly dependent upon the way that the Finder's in-built QuickLook plugin works. You may need to just implement one of those yourself.
Debugging these kinds of issues can be a little tricky, because you need to make sure macOS has assimilated your NSExportableTypes. One quick check is to drop into Terminal and use mdls <file of your type and extension> and see what the kMDItemContentType and kMDItemContentTypeTree are for your file.
If it's not recognizing the extension at all, make sure it's been re-loaded by using lsregister which is hidden away in the LaunchServices Framework of CoreServices.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister to get the man page
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -lint -f <path> to force reload of your application (the -lint) adds more detail on errors while interpreting the entries.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed will reset the daemon and re-seed the data from the default applications and library locations.

Best way to install a firefox extension on the shell

I want to create a new profile with an addon preinstalled.
What works:
run firefox a first time.
add the addon.xpi to profile/extensions/addon.xpi.
edit profile profile/extensions.ini and add Extension0=/full/path/to/extension.xpi.
start firefox again.
What i need:
add the addon to profile/extensions/addon.xpi.
edit extensions.ini or something similiar.
use only relative paths, if possible (seems not to be implemented for extensions.ini)
Finally i want to create a zip file with some firefox preferences/addons, which can be unziped into a profilefolder to create a fresh profile with some preinstalled stuff. For this, it would be important, that everything works with relative paths. If it is definitely not possible, i can add some script to it. But i would prefer some "just unzip" solution.
I think it may be a bit harder, because mozilla wanted to prevent other software from adding toolbars and similiar to firefox by making external addon installation harder. What i already found is the key extensions.autoDisableScopes=0.
What you can do is open firefox with command line options. And pass the file path to your xpi file, so you don't have to mess with all this internals you are over there.
So do this:
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "C:\my.xpi"
and on launch it will open a tab and prompt to install your addon.
In the prefs.js:
pref("extensions.autoDisableScopes", 14); // 0x1 not set
See https://developer.mozilla.org/en-US/Add-ons/Installing_extensions#Disabling_install_locations
Then put the addons into extensions/myaddonid.xpi, making sure the filename is the id given in the install.rdf file inside the addon.xpi (zip-)file as <em:id>addon_id</em:id> tag.
On the next start the addons will be silently installed. Some addons needed one restart to work, at least the toolbar buttons were not added on the first start.
Not sure, if this will still work, when firefox decides to allow only addons signed by addons.mozilla.org. On the other hand, they will allow self-hosting addons, as soon as they are signed by AMO, so preinstalling addons downloaded from there will have a good chance.

Texmaker not updating the PDF viewer

I created bash file which constantly compiles the my latex file, the problem is though that the PDFviewer in texmaker doesn't update, eventhoug the raw PDF file is updated. How come is does the PDFviewer keep showing the old PDF until i use Texmaker to compile the texmaker?... I want the embedded PDFviewer in texmaker to update, the PDF it shows even though i don't use texmaker to compile the .tex file.
The bash file.
#!/bin/bash
while true
do
pdflatex -synctex=1 -interaction=nonstopmode /Users/Johnathan/Documents/Bachelor/Rp/bachelor.tex
sleep 4
done
I know this question is old, but I just had the same problem and found a solution for some Mac Users at least:
The short explanation: since El Capitan, there is no /usr/ directory anymore, but this is where Texmaker looks for latex.
In Texmaker -> Preferences -> Commands, substitute every /usr/ expression with /Library/TeX/, which is where Latex is installed.
This document holds all the details.
https://tug.org/mactex/UpdatingForElCapitan.pdf
Cheers
I think that the problem is not about your script(It works for me), I think is about your PDF viewer.
1)Try using Evince as a PDF reader, it will update your pdf automatically.
It has versions for Windows and Linux, and it is free.
https://wiki.gnome.org/Apps/Evince/Downloads
2)Another way is using your web browser (I have used Mozilla) as a PDF reader, writing in the URL bar:
file:///Users/Johnathan/Documents/Bachelor/Rp/bachelor.pdf
but this second way has the problem that you must refresh your web browser by yourself.
I hope that helps you!
I had the same problem of the PDF viewer not updating. The fix was:
Select: texmaker, preferences, commands, PDF viewer
Select: external viewer
Then pick adobe reader or whatever app you use to view pdf files with.
Then you bypass the pdf viewer in textmaker altogether.
Maks
Visit https://i.stack.imgur.com/np55x.png!
Make sure you choose the Quick Build and View PDF in the toolbar.

Why My DMG is not getting opened without asking security popup

I created a DMG .this has 640 and apache permissions. once i uploaded it to internet some extended attributes are getting added to it. Because of that when customer downloads it they are getting a pop up
"There may be a problem with this disk image. Are you sure you want to open it?
Opening this disk image may make your computer less secure or cause other problems."
I don't want quarantine attribute to be added to it.so what should i do to my dmg before uploading it to internet such that quarantine attribute will not be set.And also why this pop is not coming for other dmg's downloaded from net. I downloaded google chrome.dmg, for that quarantine attribute is not set.can any one help me out with better solution
Did you sign the entire DMG as well as the .app file? I believe this is a new requirement if you have additional files in the DMG besides the signed .app.
(Copied from my answer at Mac DMG oddity - signing and "damaged" applications)
In addition to signing the .app bundle:
codesign -f -s "Developer ID Application: Your Dev ID Here" -v "Your App.app"
you should also sign the created DMG as well:
codesign -f -s "Developer ID Application: Your Dev ID Here" -v YourProgram.dmg
I didn't put quotation marks around the dmg file path because it's less likely that you have spaces in the dmg name. If you do, don't forget to escape them on the command line, or wrap your file path in quotes.
I don't want quarantine attribute to be added to it.so what should i do to my dmg before uploading it to internet such that quarantine attribute will not be set.
Distribute it through the App Store or sign it with your Apple developer account.
And also why this pop is not coming for other dmg's downloaded from net.
The other DMGs are probably distributed through the App Store or signed it with an Apple developer account.
Here's the settings of interest:
The best you can do is distribute through the App Store (in Apple's opinion).
I settle on the App Store and Identified Developers. There's no difference between the two in my opinion - in both cases, I rely upon Apple to check the developer and binary. Where it comes from (App Store vs Internet) does not matter to me.
However, I trust some developers more than Apple's assertion. For example, I have more trust for the Wireshark folks than anything Apple has to say about an unknown developer. I would install Wireshark even if it was not signed (xattr -r -d "com.apple.quarantine" <app> to the rescue).
I don't think this is related to the extended attributes or quarantine at all. That error message indicates that the filesystem in the disk image is corrupt, probably because the image was damaged during uploading/downloading (see this previous SU question). Can you checksum the image before and after uploading & downloading it to see if it's been changed somewhere along the path? Also, using Disk Utility to verify the volume would be useful.
As far as quarantine is concerned: the quarantine attribute is added when the image (or any other file) is downloaded; there is nothing you can do to prevent this. If there were a way to avoid this, the bad guys would be using it on their malware to evade the quarantine security checks -- and Apple would consider this a bug, and fix it. Your customer can remove the quarantine after downloading the image, but this should not be necessary. (Although you may want to sign some/all of the files inside the image to comply with gatekeeper's restrictions.)

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 ?

Resources