0

我想要实现的是将文件放在应用程序的停靠图标上。很好理解如何做到这一点,那里没有问题。我试图让它与我现有的项目一起工作,但图标没有变暗并且AppDelegate不会被调用。

所以我创建了另一个项目,它开箱即用。

我的问题归结为:如果我使用 Storyboards 生成一个新的 macOS 项目,那么它就可以工作。如果我在没有选中 Storyboards 框的情况下生成一个新项目,它不会。

有什么我想念的吗?基本上解决了:我刚刚生成了一个新项目,移动了所有代码和资产 - 完成。但我想了解这个问题:-)

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>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>

唯一的区别当然是

<key>NSMainStoryboardFile</key>
<string>Main</string>

对比

<key>NSMainNibFile</key>
<string>MainMenu</string>

(Xcode 10.1,macOS 莫哈韦)

4

0 回答 0