CMake没有正确地将CFBundleVersion和CFBundleShortVersionString插入Info.plist

问题描述 投票:2回答:1

根据documentation,CMake应该使用MACOSX_BUNDLE_BUNDLE_VERSIONMACOSX_BUNDLE_SHORT_VERSION_STRING目标属性的值来填充生成的CFBundleVersion中的CFBundleShortVersionStringInfo.plist

这是我有的CMakeLists.txt的例子:

cmake_minimum_required(VERSION 3.12)

project (foo)

set(SOURCES foo.m)
set(HEADERS foo.h)

add_library(foo
    SHARED
    ${SOURCES}
    ${HEADERS}
)

set_target_properties(foo PROPERTIES
    OUTPUT_NAME Foo
    FRAMEWORK TRUE
    FRAMEWORK_VERSION A
    MACOSX_FRAMEWORK_IDENTIFIER test.foo
    MACOSX_BUNDLE_SHORT_VERSION_STRING 1.42.0
    MACOSX_BUNDLE_BUNDLE_VERSION 1.42.0
    MACOSX_RPATH TRUE
    # "current version" in semantic format in Mach-O binary file
    VERSION 1.42.0
    # "compatibility version" in semantic format in Mach-O binary file
    SOVERSION 1.42.0
    PUBLIC_HEADER "${HEADERS}"
    XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
)

以下是CMake生成的Foo.framework/Resources/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>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>Foo</string>
    <key>CFBundleIconFile</key>
    <string></string>
    <key>CFBundleIdentifier</key>
    <string>test.foo</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundlePackageType</key>
    <string>FMWK</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string></string>
    <key>CFBundleShortVersionString</key>
    <string></string>
    <key>CSResourcesFileMapped</key>
    <true/>
</dict>
</plist>

因此,CFBundleIdentifierCFBundleExecutable被正确替换,但CFBundleVersionCFBundleShortVersionString不是。我在这里错过了什么?

cmake info.plist
1个回答
2
投票

您应该使用此处记录的另一组选项:https://cmake.org/cmake/help/v3.0/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.html

那是

MACOSX_FRAMEWORK_SHORT_VERSION_STRING
MACOSX_FRAMEWORK_BUNDLE_VERSION

因为在你的情况下,它不是一个常规的包,它是一个框架(即一个包中的库)

© www.soinside.com 2019 - 2024. All rights reserved.