0

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)

Wukerplank
  • 4,156
  • 2
  • 28
  • 45
  • Is it because the storyboard architecture gives you a window controller? – matt Nov 15 '18 at 22:09
  • I still don't get it, @matt :-/ I moved all of my code, got rid of the storyboard, the whole project looks like the original one. The only difference is that dropping files on the app icon works now. I've studied the diff of the project file, but I can't find anything obvious. – Wukerplank Nov 15 '18 at 22:58
  • How can we reproduce the issue? I tried this and the project without storyboard works. – Willeke Nov 16 '18 at 00:28
  • @Willeke Exactly as I described above: Create a brand new project, add a document type in the Info.plist and the `application(application:open:)` callback to the `AppDelegate`. But if it works for you right away, there must be something wrong with my setup... – Wukerplank Nov 16 '18 at 16:21
  • I use Xcode 9, maybe the templates of Xcode 10 are different. Are the `CFBundleDocumentTypes` parts of Info.plist identical? Are the `application(_:open:)`s identical? – Willeke Nov 16 '18 at 17:00
  • Yes, the only difference is the template from which I start from. I'm on Xcode 10.1, I'll try 10 when I get to it. Maybe it's an Apple bug after all. – Wukerplank Nov 16 '18 at 17:13

0 Answers0