CMake无法将CFBundleVersion和CFBundleShortVersionString正确插入Info.plist

时间:2018-09-12 15:06:38

标签: cmake info.plist

根据documentation,CMake应使用MACOSX_BUNDLE_BUNDLE_VERSIONMACOSX_BUNDLE_SHORT_VERSION_STRING目标属性的值在生成的{{1中填充CFBundleVersionCFBundleShortVersionString }}。

以下是我有Info.plist的示例:

CMakeLists.txt

这是CMake生成的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" ) 的内容:

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> CFBundleIdentifier已正确替换,而CFBundleExecutableCFBundleVersion未正确替换。我在这里想念什么?

1 个答案:

答案 0 :(得分:2)

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

那是

MACOSX_FRAMEWORK_SHORT_VERSION_STRING
MACOSX_FRAMEWORK_BUNDLE_VERSION

因为在您的情况下,它不是常规捆绑包,而是框架(即捆绑包中的库)