根据documentation,CMake应使用MACOSX_BUNDLE_BUNDLE_VERSION
和MACOSX_BUNDLE_SHORT_VERSION_STRING
目标属性的值在生成的{{1中填充CFBundleVersion
和CFBundleShortVersionString
}}。
以下是我有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
已正确替换,而CFBundleExecutable
和CFBundleVersion
未正确替换。我在这里想念什么?
答案 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
因为在您的情况下,它不是常规捆绑包,而是框架(即捆绑包中的库)