Files
amnezia-client/client/cmake/branding/macos.cmake
T
NickVs2015andvkamn b1a37b3779 feat: add brandings (#2839)
* feat: move amnezia hardcode from sources to cmake

* feat: move amnezia hardcode from sources to cmake

* refactor: remove prem v1 migration

* chore: move more branding

* fix: use host-matching architecture for iOS simulator builds

x86_64 was hardcoded; Apple Silicon Macs run arm64 simulators and Xcode 26
has no Rosetta simulator destinations, so simulators showed as unsupported.

* fix: mark the branded media assets catalog as a bundle resource

MACOSX_PACKAGE_LOCATION was set on the upstream Media.xcassets path while
target_sources uses CLIENT_IOS_MEDIA_ASSETS_PATH, so a branded catalog was
never compiled by actool and the app got a blank icon.

* fix: parametrize the Swift app-group identifier used by Log.swift

Log.swift hardcoded Amnezia's own app-group instead of the branded one,
since Swift -D flags can't carry the string value like the ObjC++ side
does. Generate a small Swift constants file instead, same pattern as
version.h.in, wired into all four targets that compile Log.swift.

* fix: use APPLICATION_NAME instead of hardcoded Amnezia in log line format

Every log line printed "Amnezia" regardless of branding; the log file name
two lines above this already used APPLICATION_NAME correctly.

* fix: restore branding fixes dropped by rebase, rename swiftInterop to swiftBridge

* fix: move more branding variables to cmake

* feat: move macOS branding from sources to cmake

- macos/app/Info.plist.in: app group, camera usage text, UTI ids and
  descriptions now come from CLIENT_APPLICATION_NAME / BUILD_* variables,
  mirroring ios/app/Info.plist.in
- macos/networkextension/Info.plist.in: bundle names and app group ids are
  templated; the plist is configured by CMake into the binary dir because
  Xcode only expands its own $(...) settings
- new knobs: CLIENT_MACOS_MEDIA_ASSETS_PATH, CLIENT_MACOS_APP_ICNS_PATH,
  CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER(_DEBUG),
  CLIENT_MACOS_NE_PROVISIONING_PROFILE_SPECIFIER(_DEBUG)

* fix: resolve macOS pf template paths relative to the client source dir

CMAKE_SOURCE_DIR points at the wrapper project when the client is built as a
subproject, so the pf template lookup failed there.

* chore: separate brandings defaults

---------

Co-authored-by: vkamn <vk@amnezia.org>
2026-08-18 20:41:45 +08:00

38 lines
2.2 KiB
CMake

if(NOT CLIENT_MACOS_NE_TARGET_NAME)
set(CLIENT_MACOS_NE_TARGET_NAME "${CLIENT_NETWORK_EXTENSION_NAME}" CACHE STRING "macOS network extension build target name")
endif()
if(NOT CLIENT_MACOS_NE_ENTITLEMENTS_FILE)
set(CLIENT_MACOS_NE_ENTITLEMENTS_FILE "AmneziaVPNNetworkExtension.entitlements" CACHE STRING "macOS network extension entitlements filename")
endif()
if(NOT CLIENT_MACOS_APP_ENTITLEMENTS_PATH)
set(CLIENT_MACOS_APP_ENTITLEMENTS_PATH "${_CLIENT_SRC_DIR}/macos/app/app.entitlements" CACHE FILEPATH "macOS app entitlements file path")
endif()
if(NOT CLIENT_MACOS_NE_ENTITLEMENTS_PATH)
set(CLIENT_MACOS_NE_ENTITLEMENTS_PATH "${_CLIENT_SRC_DIR}/macos/networkextension/${CLIENT_MACOS_NE_ENTITLEMENTS_FILE}" CACHE FILEPATH "macOS network extension entitlements file path")
endif()
if(NOT CLIENT_MACOS_MEDIA_ASSETS_PATH)
set(CLIENT_MACOS_MEDIA_ASSETS_PATH "${_CLIENT_SRC_DIR}/macos/app/Images.xcassets" CACHE FILEPATH "macOS app Images.xcassets path")
endif()
if(NOT CLIENT_MACOS_APP_ICNS_PATH)
set(CLIENT_MACOS_APP_ICNS_PATH "${_CLIENT_SRC_DIR}/images/app.icns" CACHE FILEPATH "macOS app icon (.icns) used by non-App Store builds")
endif()
if(NOT CLIENT_MACOS_EXTRA_PLIST_ENTRIES)
set(CLIENT_MACOS_EXTRA_PLIST_ENTRIES "" CACHE STRING "Extra macOS Info.plist entries appended verbatim (e.g. appearance pinning)")
endif()
# -- signing
if(NOT CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER)
set(CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER "distr macos.org.amnezia.AmneziaVPN" CACHE STRING "macOS app provisioning profile specifier for release")
endif()
if(NOT CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG)
set(CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev macos.org.amnezia.AmneziaVPN" CACHE STRING "macOS app provisioning profile specifier for debug")
endif()
if(NOT CLIENT_MACOS_NE_PROVISIONING_PROFILE_SPECIFIER)
set(CLIENT_MACOS_NE_PROVISIONING_PROFILE_SPECIFIER "distr macos.org.amnezia.amneziaVPN.NE" CACHE STRING "macOS network extension provisioning profile specifier for release")
endif()
if(NOT CLIENT_MACOS_NE_PROVISIONING_PROFILE_SPECIFIER_DEBUG)
set(CLIENT_MACOS_NE_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev macos.org.amnezia.amneziaVPN.NE" CACHE STRING "macOS network extension provisioning profile specifier for debug")
endif()