How can I make macOS realize my app is a web browser? - macos

I'm trying to make an app that can handle http and https URL schemes, so that when you open System Preferences > General, my app will be listed in the dropdown for "Default web browser." Everything I can find seems to say that I just need my Info.plist to include the correct CFBundleURLTypes values to handle the URL schemes I'm interested in.
I believe I'm doing everything right, and I've compared my own Info.plist to other web browsers that show up in that list, but for some reason I can't get my own to appear there. Any idea what I'm doing wrong?
Here's my Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict><key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleIdentifier</key>
<string>com.micahflee.porcupine</string>
<key>CFBundleName</key>
<string>Porcupine</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>LSBackgroundOnly</key>
<string>0</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleDisplayName</key>
<string>Porcupine</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>Web site URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>http</string>
<string>https</string>
</array>
</dict>
</array>
<key>CFBundleShortVersionString</key>
<string>{{VERSION}}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>MacOS/porcupine</string>
</dict>
</plist>

Related

MacOS: Dropping a file on the dock icon – Project with and without storyboard

What I want to achieve is to drop files on the app's dock icon. It's well understood how to do it, no questions there. I tried to make it work with my existing project, but the icon does not get dimmed and the AppDelegate would not get called.
So I created another project and it worked out of the box.
What my question boils down to: If I generate a new macOS project with Storyboards, this just works. If I generate a new project without checking the Storyboards box, it doesn't.
Is there something I miss? It's basically solved: I just generated a new project, moved all of the code and assets - done. But I'd like to understand the issue :-)
The Info.plist looks like this in both cases:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>AllFiles</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Wukerplank. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
The only difference of course is
<key>NSMainStoryboardFile</key>
<string>Main</string>
vs
<key>NSMainNibFile</key>
<string>MainMenu</string>
(Xcode 10.1, macOS Mojave)

Make an app (OSX) be able to be used in "open with" submenu

I made an application with Unity for OSX to open and modify images. Now, I want to be able able to open a file with it by using "open with". I managed to make the app appear in that submenu, but it won't open : I get an error from the os saying my app can't open the file. I really don't know why, I have no background whatsoever in OSX, and I didn't find any help on the web.
My goal is to retrieve the path of that file looking into the command line's arguments.
This is how the info.plist looks like :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>StereoMacBuild</string>
<key>CFBundleGetInfoString</key>
<string>Unity Player version 2017.3.1f1 (fc1d3344e6ea). (c) 2018 Unity Technologies ApS. All rights reserved.</string>
<key>CFBundleIconFile</key>
<string>PlayerIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.Company.ProductName</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>CFBundleName</key>
<string>StereoProto</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>PlayerApplication</string>
<key>UnityBuildNumber</key>
<string>fc1d3344e6ea</string>
<key>LSMinimumSystemVersion</key>
<string>10.9.0</string>
</dict>
</plist>
Thanks to anyone taking some time to help me !

Codesign without xcode - error code object is not signed at all

I have a macOS .app developed in a non-xcode tool. I want to sign it, so users can download from my website.
I have manually created my "info.plist" file which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>mydemo</string>
<key>CFBundleName</key>
<string>md</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.company.mydemo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>md</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleIconFile</key>
<string>mydemo.icns</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeOSTypes</key>
<array>
<string>fold</string>
<string>disk</string>
<string>****</string>
</array>
</dict>
</array>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
I have an Apple developer account and in
https://developer/apple/account/mac/certificate followed instructions for creating a Developer ID application certificate.
I am now doing this
codesign -s "Certificate Developer ID Company Name" mydemo.app
but get error
mydemo.app: code object is not signed at all In subcomponent:
mydemo.app/Contents/info.plist
My .app file does noy contain in additional lib - just executable mydemo.app/Contents/MacOS/mydemo
I would like to successfully sign mydemo.app. I distribute my app in mydemo.zip and my goal is that when people download. unzip and drag it into /Applications it will run more easily
The info.plist filename should be capitalized:
Info.plist
It should codesign without issue after correcting it.

Open existing file in OSX with RCP and register file type

I'm working on installers for a tool written in Java/Ecipse RCP and everything is working except two things I think could be related:
1) Open existing file. For some reason OSX doesn't provide the selected file as an argument like windows and linux does. How do I get osx to pass the path as an argument? or is there another way?
2) File type doesn't register properly. Double clicking an existing file with the extension opens the application as expected, but when I go "Open with" - "Other" the tool is greyed out, how do I make osx understand that the tool can open such files?
Here's the current Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>images/icons/macos.icns</string>
<key>NSHumanReadableCopyright</key>
<string>2016 Company</string>
<key>CFBundleGetInfoString</key>
<string>Tool description</string>
<key>CFBundleShortVersionString</key>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>1.2.0</string>
<key>CFBundleDisplayName</key>
<string>Tool</string>
<key>CFBundleName</key>
<string>com.company.tool</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>tool</string>
<key>CFBundleIdentifier</key>
<string>com.company.tool</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.company.tool.extension</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>ext</string>
</dict>
<key>UTTypeIconFile</key>
<string>images/icons/macos.icns</string>
<key>UTTypeDescription</key>
<string>tool file</string>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<string>images/icons/macos.icns</string>
<key>CFBundleTypeName</key>
<string>tool file</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.company.tool.extension</string>
</array>
</dict>
</array>
</dict>
</plist>

CFBundleTypeIconFile Icon not showing for given file extension

I have the following Info.plist for my application, the problem is files i save with the extension myapp do not seem to pick up on my MyApp icon which i have created from an icon set (application correctly uses icon) so guessing there is something wrong in the plist.
I am assuming if I got this working when running my application at some point documents that I have save will suddenly show with the given icon.
Incase this matters, the document is saved from a set of NSCoder based classes. Clicking these documents also opens my application and loads the file correctly, so confused what I am missing to get Icon to show on the files....
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>myapp</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>MyApp</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>ASWM</string>
</array>
<key>CFBundleTypeName</key>
<string>MyApp project file</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>MyApp</string>
<key>CFBundleIdentifier</key>
<string>com.workmonkeys.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>ASWM</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Me. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
Turns out the system must have cached a old copy of the plist when I initially created my application. All that was needed was to rebuild the launch services database.
I used the lsregister command as documented here...
http://www.tuaw.com/2009/06/11/terminal-tips-rebuild-your-launch-services-database-to-clean-up/
Rerun the application and bingo the documents now have the respective icon associated.

Resources