Skip to content

CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息

chore: 完善构建归档与签名验证

Bob244867827785
diff --git a/CodexBar.xcodeproj/project.pbxproj b/CodexBar.xcodeproj/project.pbxproj
index 949c824..59ffc9b 100644
--- a/CodexBar.xcodeproj/project.pbxproj
+++ b/CodexBar.xcodeproj/project.pbxproj
@@ -7,12 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
- B10000000000000000000001 /* CodexBarHelperXPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10000000000000000000011 /* CodexBarHelperXPC.swift */; };
- B10000000000000000000002 /* CodexBarHelperXPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10000000000000000000011 /* CodexBarHelperXPC.swift */; };
- B10000000000000000000003 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10000000000000000000012 /* main.swift */; };
- B10000000000000000000004 /* app.zabrian.codexbar.helper.plist in Copy LaunchDaemons */ = {isa = PBXBuildFile; fileRef = B10000000000000000000013 /* app.zabrian.codexbar.helper.plist */; };
B10000000000000000000005 /* CodexBarHelper in Embed CodexBar Helper */ = {isa = PBXBuildFile; fileRef = B10000000000000000000014 /* CodexBarHelper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
- B10000000000000000000006 /* app.zabrian.codexbar.debug.helper.plist in Copy LaunchDaemons */ = {isa = PBXBuildFile; fileRef = B10000000000000000000015 /* app.zabrian.codexbar.debug.helper.plist */; };
C42A52F12FDACDEC004A2B53 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = C42A52F02FDACDEC004A2B53 /* Sparkle */; };
/* End PBXBuildFile section */
@@ -41,19 +36,14 @@
dstPath = Contents/Library/LaunchDaemons;
dstSubfolder = Wrapper;
files = (
- B10000000000000000000004 /* app.zabrian.codexbar.helper.plist in Copy LaunchDaemons */,
- B10000000000000000000006 /* app.zabrian.codexbar.debug.helper.plist in Copy LaunchDaemons */,
);
name = "Copy LaunchDaemons";
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
- B10000000000000000000011 /* CodexBarHelperXPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodexBarHelperXPC.swift; sourceTree = "<group>"; };
- B10000000000000000000012 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
- B10000000000000000000013 /* app.zabrian.codexbar.helper.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = app.zabrian.codexbar.helper.plist; sourceTree = "<group>"; };
B10000000000000000000014 /* CodexBarHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CodexBarHelper; sourceTree = BUILT_PRODUCTS_DIR; };
- B10000000000000000000015 /* app.zabrian.codexbar.debug.helper.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = app.zabrian.codexbar.debug.helper.plist; sourceTree = "<group>"; };
+ C449FB5030203E0000ED2123 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
C4A0FD952FD9302E000263A7 /* CodexBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CodexBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -67,6 +57,17 @@
};
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
+/* Begin PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */
+ C449FB4C302038A300ED2123 /* Exceptions for "CodexBarHelper" folder in "Copy LaunchDaemons" phase from "CodexBar" target */ = {
+ isa = PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet;
+ buildPhase = B10000000000000000000024 /* Copy LaunchDaemons */;
+ membershipExceptions = (
+ app.zabrian.codexbar.debug.helper.plist,
+ app.zabrian.codexbar.helper.plist,
+ );
+ };
+/* End PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */
+
/* Begin PBXFileSystemSynchronizedRootGroup section */
9E664A4C2FDD47530016B96E /* CodexBar */ = {
isa = PBXFileSystemSynchronizedRootGroup;
@@ -76,6 +77,19 @@
path = CodexBar;
sourceTree = "<group>";
};
+ C449FB3A3020367500ED2123 /* CodexBarHelper */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ exceptions = (
+ C449FB4C302038A300ED2123 /* Exceptions for "CodexBarHelper" folder in "Copy LaunchDaemons" phase from "CodexBar" target */,
+ );
+ path = CodexBarHelper;
+ sourceTree = "<group>";
+ };
+ C449FB4E30203A1100ED2123 /* Shared */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ path = Shared;
+ sourceTree = "<group>";
+ };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
@@ -93,30 +107,21 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
- B10000000000000000000041 /* Shared */ = {
- isa = PBXGroup;
- children = (
- B10000000000000000000011 /* CodexBarHelperXPC.swift */,
- );
- path = Shared;
- sourceTree = "<group>";
- };
- B10000000000000000000042 /* CodexBarHelper */ = {
+ C449FB5130203E0000ED2123 /* Config */ = {
isa = PBXGroup;
children = (
- B10000000000000000000012 /* main.swift */,
- B10000000000000000000015 /* app.zabrian.codexbar.debug.helper.plist */,
- B10000000000000000000013 /* app.zabrian.codexbar.helper.plist */,
+ C449FB5030203E0000ED2123 /* Version.xcconfig */,
);
- path = CodexBarHelper;
+ path = Config;
sourceTree = "<group>";
};
C4A0FD8C2FD9302E000263A7 = {
isa = PBXGroup;
children = (
9E664A4C2FDD47530016B96E /* CodexBar */,
- B10000000000000000000041 /* Shared */,
- B10000000000000000000042 /* CodexBarHelper */,
+ C449FB4E30203A1100ED2123 /* Shared */,
+ C449FB3A3020367500ED2123 /* CodexBarHelper */,
+ C449FB5130203E0000ED2123 /* Config */,
C4A0FD962FD9302E000263A7 /* Products */,
);
sourceTree = "<group>";
@@ -142,6 +147,10 @@
);
buildRules = (
);
+ fileSystemSynchronizedGroups = (
+ C449FB3A3020367500ED2123 /* CodexBarHelper */,
+ C449FB4E30203A1100ED2123 /* Shared */,
+ );
name = CodexBarHelper;
productName = CodexBarHelper;
productReference = B10000000000000000000014 /* CodexBarHelper */;
@@ -164,6 +173,7 @@
);
fileSystemSynchronizedGroups = (
9E664A4C2FDD47530016B96E /* CodexBar */,
+ C449FB4E30203A1100ED2123 /* Shared */,
);
name = CodexBar;
packageProductDependencies = (
@@ -226,14 +236,11 @@
B10000000000000000000021 /* Sources */ = {
isa = PBXSourcesBuildPhase;
files = (
- B10000000000000000000002 /* CodexBarHelperXPC.swift in Sources */,
- B10000000000000000000003 /* main.swift in Sources */,
);
};
C4A0FD912FD9302E000263A7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
files = (
- B10000000000000000000001 /* CodexBarHelperXPC.swift in Sources */,
);
};
/* End PBXSourcesBuildPhase section */
@@ -253,7 +260,6 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
- CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 4KJ362VJW5;
ENABLE_APP_SANDBOX = NO;
@@ -274,7 +280,6 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
- CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 4KJ362VJW5;
ENABLE_APP_SANDBOX = NO;
@@ -291,6 +296,7 @@
};
C4A0FD9E2FD9302E000263A7 /* Debug configuration for PBXProject "CodexBar" */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = C449FB5030203E0000ED2123 /* Version.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
@@ -358,6 +364,7 @@
};
C4A0FD9F2FD9302E000263A7 /* Release configuration for PBXProject "CodexBar" */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = C449FB5030203E0000ED2123 /* Version.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
@@ -389,6 +396,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -424,7 +432,6 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
- CURRENT_PROJECT_VERSION = 64;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 4KJ362VJW5;
ENABLE_APP_INTENTS_METADATA_GENERATION = NO;
@@ -441,7 +448,6 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
- MARKETING_VERSION = 3.5.10;
PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar.debug;
PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES;
@@ -461,10 +467,8 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = CodexBar/Resources/CodexBar.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
- "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
- CURRENT_PROJECT_VERSION = 64;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 4KJ362VJW5;
ENABLE_APP_INTENTS_METADATA_GENERATION = NO;
@@ -481,7 +485,6 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
- MARKETING_VERSION = 3.5.10;
PRODUCT_BUNDLE_IDENTIFIER = app.zabrian.codexbar;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
diff --git a/CodexBarHelper/app.zabrian.codexbar.debug.helper.plist b/CodexBarHelper/app.zabrian.codexbar.debug.helper.plist
index 2559151..fd19b4d 100644
--- a/CodexBarHelper/app.zabrian.codexbar.debug.helper.plist
+++ b/CodexBarHelper/app.zabrian.codexbar.debug.helper.plist
@@ -1,25 +1,25 @@
<?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>AssociatedBundleIdentifiers</key>
- <array>
- <string>app.zabrian.codexbar.debug</string>
- </array>
- <key>BundleProgram</key>
- <string>Contents/Resources/CodexBarHelper</string>
- <key>KeepAlive</key>
- <true/>
- <key>Label</key>
- <string>app.zabrian.codexbar.debug.helper</string>
- <key>MachServices</key>
<dict>
- <key>app.zabrian.codexbar.debug.helper</key>
+ <key>AssociatedBundleIdentifiers</key>
+ <array>
+ <string>app.zabrian.codexbar.debug</string>
+ </array>
+ <key>BundleProgram</key>
+ <string>Contents/Resources/CodexBarHelper</string>
+ <key>KeepAlive</key>
+ <true/>
+ <key>Label</key>
+ <string>app.zabrian.codexbar.debug.helper</string>
+ <key>MachServices</key>
+ <dict>
+ <key>app.zabrian.codexbar.debug.helper</key>
+ <true/>
+ </dict>
+ <key>ProcessType</key>
+ <string>Background</string>
+ <key>RunAtLoad</key>
<true/>
</dict>
- <key>ProcessType</key>
- <string>Background</string>
- <key>RunAtLoad</key>
- <true/>
-</dict>
</plist>
diff --git a/CodexBarHelper/app.zabrian.codexbar.helper.plist b/CodexBarHelper/app.zabrian.codexbar.helper.plist
index d82b022..0eb2aa5 100644
--- a/CodexBarHelper/app.zabrian.codexbar.helper.plist
+++ b/CodexBarHelper/app.zabrian.codexbar.helper.plist
@@ -1,25 +1,25 @@
<?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>AssociatedBundleIdentifiers</key>
- <array>
- <string>app.zabrian.codexbar</string>
- </array>
- <key>BundleProgram</key>
- <string>Contents/Resources/CodexBarHelper</string>
- <key>KeepAlive</key>
- <true/>
- <key>Label</key>
- <string>app.zabrian.codexbar.helper</string>
- <key>MachServices</key>
<dict>
- <key>app.zabrian.codexbar.helper</key>
+ <key>AssociatedBundleIdentifiers</key>
+ <array>
+ <string>app.zabrian.codexbar</string>
+ </array>
+ <key>BundleProgram</key>
+ <string>Contents/Resources/CodexBarHelper</string>
+ <key>KeepAlive</key>
+ <true/>
+ <key>Label</key>
+ <string>app.zabrian.codexbar.helper</string>
+ <key>MachServices</key>
+ <dict>
+ <key>app.zabrian.codexbar.helper</key>
+ <true/>
+ </dict>
+ <key>ProcessType</key>
+ <string>Background</string>
+ <key>RunAtLoad</key>
<true/>
</dict>
- <key>ProcessType</key>
- <string>Background</string>
- <key>RunAtLoad</key>
- <true/>
-</dict>
</plist>
diff --git a/Config/Version.xcconfig b/Config/Version.xcconfig
new file mode 100644
index 0000000..65b6e5c
--- /dev/null
+++ b/Config/Version.xcconfig
@@ -0,0 +1,2 @@
+MARKETING_VERSION = 3.5.10
+CURRENT_PROJECT_VERSION = 64
diff --git a/Scripts/CodexBar.provisionprofile b/Scripts/CodexBar.provisionprofile
new file mode 100644
index 0000000..80186e0
Binary files /dev/null and b/Scripts/CodexBar.provisionprofile differ
diff --git a/Scripts/DeveloperID.plist b/Scripts/DeveloperID.plist
new file mode 100644
index 0000000..d60f8ba
--- /dev/null
+++ b/Scripts/DeveloperID.plist
@@ -0,0 +1,29 @@
+<?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>method</key>
+ <string>developer-id</string>
+
+ <key>signingStyle</key>
+ <string>manual</string>
+
+ <key>signingCertificate</key>
+ <string>47D8800DC4EF9812EC701D25D53C849DE0FE923C</string>
+
+ <key>teamID</key>
+ <string>4KJ362VJW5</string>
+
+ <key>iCloudContainerEnvironment</key>
+ <string>Production</string>
+
+ <key>provisioningProfiles</key>
+ <dict>
+ <key>app.zabrian.codexbar</key>
+ <string>75a955c2-1c78-4e49-a0f0-a07f3d5c50c4</string>
+ </dict>
+
+ <key>stripSwiftSymbols</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/Scripts/build.sh b/Scripts/build.sh
index 7264232..1c9fe26 100755
--- a/Scripts/build.sh
+++ b/Scripts/build.sh
@@ -28,7 +28,7 @@ usage() {
usage: Scripts/build.sh [options] [Output.app]
Builds a Release archive, exports a Developer ID app, submits it to Apple
-notarization, staples the ticket, and writes the final app to build/.
+notarization, staples the ticket, validates the result, and writes the final app to build/.
After a successful build, build/ keeps only the final .app.
Options:
@@ -53,8 +53,8 @@ Options:
-h, --help Show this help.
Recommended credential setup:
- xcrun notarytool store-credentials "codexbar-notary" --apple-id "<Apple ID>" --team-id "<Team ID>"
- Scripts/build.sh --notary-profile codexbar-notary
+ xcrun notarytool store-credentials "codexbar-notary" --apple-id "<Apple ID>" --team-id "<Team ID>" --sync
+ Scripts/build.sh --export-options Scripts/DeveloperID.plist --no-provisioning-updates --notary-profile codexbar-notary
USAGE
}
@@ -368,6 +368,514 @@ read_build_setting() {
'
}
+read_plist_value() {
+ local plist_path="$1"
+ local key_path="$2"
+
+ /usr/libexec/PlistBuddy -c "Print :${key_path}" "${plist_path}" 2>/dev/null || true
+}
+
+certificate_sha1() {
+ local certificate_path="$1"
+
+ shasum -a 1 "${certificate_path}" | awk '{print toupper($1)}'
+}
+
+print_indented() {
+ sed 's/^/ /'
+}
+
+supports_color() {
+ [[ -t "$1" && -z "${NO_COLOR:-}" && "${TERM:-}" != "dumb" ]]
+}
+
+validation_pass() {
+ if supports_color 1; then
+ printf ' \033[32m✓\033[0m %s\n' "$1"
+ else
+ printf ' ✓ %s\n' "$1"
+ fi
+}
+
+validation_fail() {
+ local check="$1"
+ local reason="$2"
+ local details="${3:-}"
+
+ if supports_color 2; then
+ printf ' \033[31m✗\033[0m %s\n' "${check}" >&2
+ else
+ printf ' ✗ %s\n' "${check}" >&2
+ fi
+ printf ' Reason: %s\n' "${reason}" >&2
+ if [[ -n "${details}" ]]; then
+ printf '%s\n' "${details}" | sed 's/^/ /' >&2
+ fi
+}
+
+validation_skip() {
+ printf ' - %s: skipped\n' "$1"
+}
+
+validate_final_app() {
+ local app_path="$1"
+ local contents_path="${app_path}/Contents"
+ local info_plist="${contents_path}/Info.plist"
+ local executable_path="${contents_path}/MacOS/${PRODUCT_NAME}"
+ local helper_path="${contents_path}/Resources/CodexBarHelper"
+ local launch_daemons_path="${contents_path}/Library/LaunchDaemons"
+ local embedded_profile="${contents_path}/embedded.provisionprofile"
+ local validation_dir="${TEMP_ROOT}/validation"
+ local main_entitlements="${validation_dir}/main-entitlements.plist"
+ local helper_entitlements="${validation_dir}/helper-entitlements.plist"
+ local profile_plist="${validation_dir}/embedded-profile.plist"
+ local profile_decode_error="${validation_dir}/profile-decode-error.log"
+ local profile_entitlements="${validation_dir}/profile-entitlements.plist"
+ local signing_certificate_prefix="${validation_dir}/signing-certificate"
+ local signing_certificate="${signing_certificate_prefix}0"
+ local helper_signing_certificate_prefix="${validation_dir}/helper-signing-certificate"
+ local helper_signing_certificate="${helper_signing_certificate_prefix}0"
+ local bundle_identifier=""
+ local display_name=""
+ local short_version=""
+ local build_version=""
+ local minimum_system_version=""
+ local ui_element=""
+ local architectures=""
+ local helper_architectures=""
+ local architecture=""
+ local command_output=""
+ local signature_details=""
+ local helper_signature_details=""
+ local signature_identifier=""
+ local helper_signature_identifier=""
+ local signing_authority=""
+ local signing_timestamp=""
+ local signing_team=""
+ local helper_signing_team=""
+ local signing_cdhash=""
+ local signing_certificate_sha1=""
+ local helper_signing_certificate_sha1=""
+ local expected_signing_certificate=""
+ local normalized_expected_certificate=""
+ local main_application_identifier=""
+ local helper_application_identifier=""
+ local debugger_entitlement=""
+ local helper_debugger_entitlement=""
+ local icloud_containers=""
+ local launch_daemon_count="0"
+ local launch_daemon_plist=""
+ local launch_daemon_label=""
+ local launch_daemon_bundle_identifier=""
+ local launch_daemon_program=""
+ local profile_name=""
+ local profile_uuid=""
+ local profile_team=""
+ local profile_application_identifier=""
+ local profile_expiration=""
+ local profile_certificate_count="0"
+ local profile_certificate_index="0"
+ local profile_certificate_path=""
+ local profile_certificate_sha1=""
+ local profile_certificate_match_count="0"
+ local expected_profile=""
+ local gatekeeper_source=""
+
+ echo "==> Validating final app"
+
+ if [[ ! -d "${app_path}" || ! -f "${info_plist}" || ! -x "${executable_path}" ]]; then
+ validation_fail "App bundle structure" "Missing app directory, Info.plist, or executable at ${app_path}"
+ return 1
+ fi
+ validation_pass "App bundle structure"
+
+ if [[ ! -x "${helper_path}" ]]; then
+ validation_fail "Embedded helper" "Executable helper not found at ${helper_path}"
+ return 1
+ fi
+ validation_pass "Embedded helper"
+
+ mkdir -p "${validation_dir}"
+
+ bundle_identifier="$(read_plist_value "${info_plist}" CFBundleIdentifier)"
+ display_name="$(read_plist_value "${info_plist}" CFBundleDisplayName)"
+ short_version="$(read_plist_value "${info_plist}" CFBundleShortVersionString)"
+ build_version="$(read_plist_value "${info_plist}" CFBundleVersion)"
+ minimum_system_version="$(read_plist_value "${info_plist}" LSMinimumSystemVersion)"
+ ui_element="$(read_plist_value "${info_plist}" LSUIElement)"
+
+ if [[ -z "${bundle_identifier}" || -z "${short_version}" || -z "${build_version}" ]]; then
+ validation_fail "Required bundle metadata" "CFBundleIdentifier, CFBundleShortVersionString, or CFBundleVersion is missing"
+ return 1
+ fi
+ validation_pass "Required bundle metadata"
+
+ if ! architectures="$(lipo -archs "${executable_path}" 2>&1)"; then
+ validation_fail "App architectures" "lipo could not inspect the main executable" "${architectures}"
+ return 1
+ fi
+ validation_pass "App architectures: ${architectures}"
+
+ if ! helper_architectures="$(lipo -archs "${helper_path}" 2>&1)"; then
+ validation_fail "Helper architectures" "lipo could not inspect the helper executable" "${helper_architectures}"
+ return 1
+ fi
+ validation_pass "Helper architectures: ${helper_architectures}"
+
+ echo " Bundle"
+ printf ' Path: %s\n' "${app_path}"
+ printf ' Display name: %s\n' "${display_name}"
+ printf ' Bundle identifier: %s\n' "${bundle_identifier}"
+ printf ' Version: %s (%s)\n' "${short_version}" "${build_version}"
+ printf ' Minimum macOS: %s\n' "${minimum_system_version}"
+ printf ' LSUIElement: %s\n' "${ui_element}"
+ printf ' Architectures: %s\n' "${architectures}"
+
+ if ! command_output="$(codesign --verify --deep --strict --verbose=4 "${app_path}" 2>&1)"; then
+ validation_fail "Deep strict app signature" "codesign rejected the app bundle" "${command_output}"
+ return 1
+ fi
+ echo " Code signature"
+ validation_pass "Deep strict app signature"
+
+ for architecture in ${architectures}; do
+ if ! command_output="$(codesign --verify --strict --verbose=4 --arch "${architecture}" "${app_path}" 2>&1)"; then
+ validation_fail "App ${architecture} signature" "codesign rejected the ${architecture} slice" "${command_output}"
+ return 1
+ fi
+ validation_pass "App ${architecture} signature"
+ done
+
+ if ! command_output="$(codesign --verify --strict --verbose=4 "${helper_path}" 2>&1)"; then
+ validation_fail "Helper signature" "codesign rejected the helper executable" "${command_output}"
+ return 1
+ fi
+ printf ' Helper architectures: %s\n' "${helper_architectures}"
+ validation_pass "Helper signature"
+
+ for architecture in ${helper_architectures}; do
+ if ! command_output="$(codesign --verify --strict --verbose=4 --arch "${architecture}" "${helper_path}" 2>&1)"; then
+ validation_fail "Helper ${architecture} signature" "codesign rejected the helper ${architecture} slice" "${command_output}"
+ return 1
+ fi
+ validation_pass "Helper ${architecture} signature"
+ done
+
+ if ! signature_details="$(codesign -d --verbose=4 "${app_path}" 2>&1)"; then
+ validation_fail "App signature metadata" "codesign could not read the app signature" "${signature_details}"
+ return 1
+ fi
+
+ if ! helper_signature_details="$(codesign -d --verbose=4 "${helper_path}" 2>&1)"; then
+ validation_fail "Helper signature metadata" "codesign could not read the helper signature" "${helper_signature_details}"
+ return 1
+ fi
+
+ signature_identifier="$(printf '%s\n' "${signature_details}" | awk -F= '/^Identifier=/ {print $2; exit}')"
+ helper_signature_identifier="$(printf '%s\n' "${helper_signature_details}" | awk -F= '/^Identifier=/ {print $2; exit}')"
+ signing_authority="$(printf '%s\n' "${signature_details}" | awk -F= '/^Authority=/ {print substr($0, index($0, "=") + 1); exit}')"
+ signing_timestamp="$(printf '%s\n' "${signature_details}" | awk -F= '/^Timestamp=/ {print substr($0, index($0, "=") + 1); exit}')"
+ signing_team="$(printf '%s\n' "${signature_details}" | awk -F= '/^TeamIdentifier=/ {print $2; exit}')"
+ helper_signing_team="$(printf '%s\n' "${helper_signature_details}" | awk -F= '/^TeamIdentifier=/ {print $2; exit}')"
+ signing_cdhash="$(printf '%s\n' "${signature_details}" | awk -F= '/^CDHash=/ {print $2; exit}')"
+
+ if [[ "${signature_identifier}" != "${bundle_identifier}" ||
+ "${helper_signature_identifier}" != "${bundle_identifier}.helper" ||
+ -z "${signing_team}" || "${helper_signing_team}" != "${signing_team}" ]]; then
+ validation_fail \
+ "Code signature identifiers" \
+ "Expected app ${bundle_identifier}, helper ${bundle_identifier}.helper, and one shared team; got app ${signature_identifier}, helper ${helper_signature_identifier}, teams ${signing_team:-none}/${helper_signing_team:-none}"
+ return 1
+ fi
+ validation_pass "Code signature identifiers"
+
+ if ! printf '%s\n' "${signature_details}" | grep -Eq '^CodeDirectory .*flags=.*\(runtime\)'; then
+ validation_fail "App Hardened Runtime" "The app CodeDirectory does not contain the runtime flag"
+ return 1
+ fi
+ validation_pass "App Hardened Runtime"
+
+ if ! printf '%s\n' "${helper_signature_details}" | grep -Eq '^CodeDirectory .*flags=.*\(runtime\)'; then
+ validation_fail "Helper Hardened Runtime" "The helper CodeDirectory does not contain the runtime flag"
+ return 1
+ fi
+ validation_pass "Helper Hardened Runtime"
+
+ if ! codesign --display --extract-certificates="${signing_certificate_prefix}" "${app_path}" >/dev/null 2>&1 || [[ ! -f "${signing_certificate}" ]]; then
+ validation_fail "App signing certificate" "codesign could not extract the app leaf certificate"
+ return 1
+ fi
+
+ if ! codesign --display --extract-certificates="${helper_signing_certificate_prefix}" "${helper_path}" >/dev/null 2>&1 || [[ ! -f "${helper_signing_certificate}" ]]; then
+ validation_fail "Helper signing certificate" "codesign could not extract the helper leaf certificate"
+ return 1
+ fi
+
+ if ! signing_certificate_sha1="$(certificate_sha1 "${signing_certificate}")"; then
+ validation_fail "App signing certificate" "Unable to calculate the app certificate SHA-1"
+ return 1
+ fi
+
+ if ! helper_signing_certificate_sha1="$(certificate_sha1 "${helper_signing_certificate}")"; then
+ validation_fail "Helper signing certificate" "Unable to calculate the helper certificate SHA-1"
+ return 1
+ fi
+
+ if [[ "${helper_signing_certificate_sha1}" != "${signing_certificate_sha1}" ]]; then
+ validation_fail \
+ "App and helper certificate match" \
+ "App uses ${signing_certificate_sha1}, helper uses ${helper_signing_certificate_sha1}"
+ return 1
+ fi
+ validation_pass "App and helper certificate match"
+
+ printf ' Identifier: %s\n' "${signature_identifier}"
+ printf ' Helper identifier: %s\n' "${helper_signature_identifier}"
+ printf ' Authority: %s\n' "${signing_authority}"
+ printf ' Team identifier: %s\n' "${signing_team}"
+ printf ' Certificate SHA-1: %s\n' "${signing_certificate_sha1}"
+ printf ' Helper certificate SHA-1: %s\n' "${helper_signing_certificate_sha1}"
+ printf ' Timestamp: %s\n' "${signing_timestamp:-none}"
+ printf ' CDHash: %s\n' "${signing_cdhash}"
+
+ expected_signing_certificate="$(read_plist_value "${EXPORT_OPTIONS_PLIST}" signingCertificate)"
+ normalized_expected_certificate="$(printf '%s' "${expected_signing_certificate}" | tr -d ':' | tr '[:lower:]' '[:upper:]')"
+ if [[ "${normalized_expected_certificate}" =~ ^[0-9A-F]{40}$ ]]; then
+ if [[ "${signing_certificate_sha1}" != "${normalized_expected_certificate}" ]]; then
+ validation_fail \
+ "Export certificate match" \
+ "ExportOptions requires ${normalized_expected_certificate}, app uses ${signing_certificate_sha1}"
+ return 1
+ fi
+ validation_pass "Export certificate match"
+ elif [[ -n "${expected_signing_certificate}" ]]; then
+ printf ' Export certificate selector: %s\n' "${expected_signing_certificate}"
+ fi
+
+ if ! codesign --display --entitlements="${main_entitlements}" --xml "${app_path}" >/dev/null 2>&1 || [[ ! -s "${main_entitlements}" ]]; then
+ validation_fail "App entitlements" "codesign did not return an app entitlements plist"
+ return 1
+ fi
+ validation_pass "App entitlements extracted"
+
+ if ! codesign --display --entitlements="${helper_entitlements}" --xml "${helper_path}" >/dev/null 2>&1 || [[ ! -s "${helper_entitlements}" ]]; then
+ validation_fail "Helper entitlements" "codesign did not return a helper entitlements plist"
+ return 1
+ fi
+ validation_pass "Helper entitlements extracted"
+
+ main_application_identifier="$(read_plist_value "${main_entitlements}" com.apple.application-identifier)"
+ helper_application_identifier="$(read_plist_value "${helper_entitlements}" com.apple.application-identifier)"
+ debugger_entitlement="$(read_plist_value "${main_entitlements}" com.apple.security.get-task-allow)"
+ helper_debugger_entitlement="$(read_plist_value "${helper_entitlements}" com.apple.security.get-task-allow)"
+ icloud_containers="$(read_plist_value "${main_entitlements}" com.apple.developer.icloud-container-identifiers)"
+
+ if [[ "${main_application_identifier}" != "${signing_team}.${bundle_identifier}" ||
+ "${helper_application_identifier}" != "${signing_team}.${bundle_identifier}.helper" ]]; then
+ validation_fail \
+ "Entitlement application identifiers" \
+ "Expected ${signing_team}.${bundle_identifier} and ${signing_team}.${bundle_identifier}.helper; got ${main_application_identifier:-none} and ${helper_application_identifier:-none}"
+ return 1
+ fi
+ validation_pass "Entitlement application identifiers"
+
+ if [[ "${CONFIGURATION}" == "Release" &&
+ ("${debugger_entitlement}" == "true" || "${debugger_entitlement}" == "1" ||
+ "${helper_debugger_entitlement}" == "true" || "${helper_debugger_entitlement}" == "1") ]]; then
+ validation_fail \
+ "Release debugger attachment" \
+ "get-task-allow is enabled for app=${debugger_entitlement:-false}, helper=${helper_debugger_entitlement:-false}"
+ return 1
+ fi
+
+ echo " App entitlements"
+ if ! command_output="$(plutil -p "${main_entitlements}" 2>&1)"; then
+ validation_fail "App entitlements" "Unable to display app entitlements" "${command_output}"
+ return 1
+ fi
+ printf '%s\n' "${command_output}" | print_indented
+ if [[ "${debugger_entitlement}" == "true" || "${debugger_entitlement}" == "1" ]]; then
+ validation_pass "App debugger attachment: allowed"
+ else
+ validation_pass "App debugger attachment: disabled"
+ fi
+
+ echo " Helper entitlements"
+ if ! command_output="$(plutil -p "${helper_entitlements}" 2>&1)"; then
+ validation_fail "Helper entitlements" "Unable to display helper entitlements" "${command_output}"
+ return 1
+ fi
+ printf '%s\n' "${command_output}" | print_indented
+ if [[ "${helper_debugger_entitlement}" == "true" || "${helper_debugger_entitlement}" == "1" ]]; then
+ validation_pass "Helper debugger attachment: allowed"
+ else
+ validation_pass "Helper debugger attachment: disabled"
+ fi
+
+ if [[ ! -d "${launch_daemons_path}" ]]; then
+ validation_fail "LaunchDaemon directory" "Missing ${launch_daemons_path}"
+ return 1
+ fi
+
+ if ! command_output="$(find "${launch_daemons_path}" -maxdepth 1 -type f -name '*.plist' 2>&1)"; then
+ validation_fail "LaunchDaemon plist discovery" "Unable to read ${launch_daemons_path}" "${command_output}"
+ return 1
+ fi
+ launch_daemon_count="$(printf '%s\n' "${command_output}" | awk 'NF {count++} END {print count + 0}')"
+ launch_daemon_plist="$(printf '%s\n' "${command_output}" | sort | sed -n '1p')"
+ if [[ "${launch_daemon_count}" -ne 1 || -z "${launch_daemon_plist}" ]]; then
+ validation_fail "LaunchDaemon plist count" "Expected exactly 1 plist, found ${launch_daemon_count}"
+ return 1
+ fi
+
+ launch_daemon_label="$(read_plist_value "${launch_daemon_plist}" Label)"
+ launch_daemon_bundle_identifier="$(read_plist_value "${launch_daemon_plist}" AssociatedBundleIdentifiers:0)"
+ launch_daemon_program="$(read_plist_value "${launch_daemon_plist}" BundleProgram)"
+ if [[ "${launch_daemon_label}" != "${bundle_identifier}.helper" ||
+ "${launch_daemon_bundle_identifier}" != "${bundle_identifier}" ||
+ "${launch_daemon_program}" != "Contents/Resources/CodexBarHelper" ]]; then
+ validation_fail \
+ "LaunchDaemon configuration" \
+ "Expected label ${bundle_identifier}.helper, bundle ${bundle_identifier}, and program Contents/Resources/CodexBarHelper; got ${launch_daemon_label:-none}, ${launch_daemon_bundle_identifier:-none}, ${launch_daemon_program:-none}"
+ return 1
+ fi
+ validation_pass "LaunchDaemon configuration"
+
+ echo " LaunchDaemon"
+ printf ' File: %s\n' "$(basename "${launch_daemon_plist}")"
+ printf ' Label: %s\n' "${launch_daemon_label}"
+ printf ' Associated bundle: %s\n' "${launch_daemon_bundle_identifier}"
+ printf ' Program: %s\n' "${launch_daemon_program}"
+
+ if [[ -f "${embedded_profile}" ]]; then
+ if ! security cms -D -i "${embedded_profile}" > "${profile_plist}" 2> "${profile_decode_error}"; then
+ validation_fail \
+ "Embedded provisioning profile" \
+ "security cms could not decode embedded.provisionprofile" \
+ "$(< "${profile_decode_error}")"
+ return 1
+ fi
+ validation_pass "Embedded provisioning profile decoded"
+
+ profile_name="$(read_plist_value "${profile_plist}" Name)"
+ profile_uuid="$(read_plist_value "${profile_plist}" UUID)"
+ profile_team="$(read_plist_value "${profile_plist}" TeamIdentifier:0)"
+ profile_application_identifier="$(read_plist_value "${profile_plist}" Entitlements:com.apple.application-identifier)"
+ profile_expiration="$(read_plist_value "${profile_plist}" ExpirationDate)"
+ if ! profile_certificate_count="$(
+ plutil -extract DeveloperCertificates xml1 -o - "${profile_plist}" |
+ awk '{line = $0; while (match(line, /<data>/)) {count++; line = substr(line, RSTART + RLENGTH)}} END {print count + 0}'
+ )"; then
+ validation_fail "Profile certificates" "DeveloperCertificates is missing or malformed"
+ return 1
+ fi
+
+ if [[ "${profile_application_identifier}" != "${main_application_identifier}" || "${profile_team}" != "${signing_team}" ]]; then
+ validation_fail \
+ "Profile signature identity" \
+ "Expected application ${main_application_identifier} and team ${signing_team}; got ${profile_application_identifier:-none} and ${profile_team:-none}"
+ return 1
+ fi
+ validation_pass "Profile signature identity"
+
+ if [[ "${profile_certificate_count}" -lt 1 ]]; then
+ validation_fail "Profile certificates" "DeveloperCertificates contains no signing certificates"
+ return 1
+ fi
+
+ echo " Provisioning profile"
+ printf ' Name: %s\n' "${profile_name}"
+ printf ' UUID: %s\n' "${profile_uuid}"
+ printf ' Team identifier: %s\n' "${profile_team}"
+ printf ' Application identifier: %s\n' "${profile_application_identifier}"
+ printf ' Expiration: %s\n' "${profile_expiration}"
+ printf ' Authorized certificates: %s\n' "${profile_certificate_count}"
+
+ for ((profile_certificate_index = 0; profile_certificate_index < profile_certificate_count; profile_certificate_index++)); do
+ profile_certificate_path="${validation_dir}/profile-certificate-${profile_certificate_index}.der"
+ if ! plutil -extract "DeveloperCertificates.${profile_certificate_index}" raw -o - "${profile_plist}" |
+ base64 -D > "${profile_certificate_path}"; then
+ validation_fail \
+ "Profile certificate $((profile_certificate_index + 1))" \
+ "Unable to decode the certificate from DeveloperCertificates"
+ return 1
+ fi
+ if ! profile_certificate_sha1="$(certificate_sha1 "${profile_certificate_path}")"; then
+ validation_fail \
+ "Profile certificate $((profile_certificate_index + 1))" \
+ "Unable to calculate the certificate SHA-1"
+ return 1
+ fi
+ printf ' Certificate %s SHA-1: %s\n' "$((profile_certificate_index + 1))" "${profile_certificate_sha1}"
+ if [[ "${profile_certificate_sha1}" == "${signing_certificate_sha1}" ]]; then
+ profile_certificate_match_count=$((profile_certificate_match_count + 1))
+ fi
+ done
+ validation_pass "Profile certificates decoded"
+
+ if [[ "${profile_certificate_match_count}" -lt 1 ]]; then
+ validation_fail \
+ "App certificate authorization" \
+ "App certificate ${signing_certificate_sha1} is not listed in the embedded profile"
+ return 1
+ fi
+ validation_pass "App certificate authorization"
+
+ expected_profile="$(read_plist_value "${EXPORT_OPTIONS_PLIST}" "provisioningProfiles:${bundle_identifier}")"
+ if [[ -n "${expected_profile}" ]]; then
+ if [[ "${expected_profile}" != "${profile_uuid}" && "${expected_profile}" != "${profile_name}" ]]; then
+ validation_fail \
+ "Export profile match" \
+ "ExportOptions requires ${expected_profile}, embedded profile is ${profile_name} (${profile_uuid})"
+ return 1
+ fi
+ validation_pass "Export profile match"
+ fi
+
+ if ! command_output="$(plutil -extract Entitlements xml1 -o "${profile_entitlements}" "${profile_plist}" 2>&1)"; then
+ validation_fail "Profile entitlements" "Unable to extract authorized entitlements" "${command_output}"
+ return 1
+ fi
+ echo " Authorized entitlements"
+ if ! command_output="$(plutil -p "${profile_entitlements}" 2>&1)"; then
+ validation_fail "Profile entitlements" "Unable to display authorized entitlements" "${command_output}"
+ return 1
+ fi
+ printf '%s\n' "${command_output}" | print_indented
+ validation_pass "Profile entitlements"
+ elif [[ -n "${icloud_containers}" ]]; then
+ validation_fail "Embedded provisioning profile" "CloudKit entitlements require embedded.provisionprofile"
+ return 1
+ else
+ validation_pass "Provisioning profile not required"
+ fi
+
+ if [[ "${SKIP_NOTARIZATION}" == "1" ]]; then
+ validation_skip "Notarization ticket"
+ validation_skip "Gatekeeper assessment"
+ else
+ if ! command_output="$(xcrun stapler validate "${app_path}" 2>&1)"; then
+ validation_fail "Notarization ticket" "stapler could not validate the ticket" "${command_output}"
+ return 1
+ fi
+ validation_pass "Notarization ticket"
+
+ if [[ "${SPCTL_ASSESS}" == "1" ]]; then
+ if ! command_output="$(spctl --assess --type execute --verbose=4 "${app_path}" 2>&1)"; then
+ validation_fail "Gatekeeper assessment" "spctl rejected the app" "${command_output}"
+ return 1
+ fi
+ gatekeeper_source="$(printf '%s\n' "${command_output}" | awk -F= '/^source=/ {print substr($0, index($0, "=") + 1); exit}')"
+ validation_pass "Gatekeeper assessment"
+ printf ' Gatekeeper source: %s\n' "${gatekeeper_source}"
+ else
+ validation_skip "Gatekeeper assessment"
+ fi
+ fi
+
+ validation_pass "Final app validation passed"
+}
+
safe_remove_path() {
local path="$1"
local parent=""
@@ -509,9 +1017,17 @@ fi
require_command xcodebuild
require_command ditto
require_command codesign
+require_command lipo
+require_command plutil
+require_command security
+require_command shasum
+require_command base64
if [[ "${SKIP_NOTARIZATION}" != "1" ]]; then
require_command xcrun
+ if [[ "${SPCTL_ASSESS}" == "1" ]]; then
+ require_command spctl
+ fi
fi
mkdir -p "${BUILD_DIR}" "$(dirname "${ARCHIVE_PATH}")" "${DERIVED_DATA_PATH}"
@@ -611,7 +1127,7 @@ xcodebuild \
-destination "generic/platform=macOS" \
-derivedDataPath "${DERIVED_DATA_PATH}" \
-archivePath "${ARCHIVE_PATH}" \
- "${PROVISIONING_FLAGS[@]}" \
+ "${PROVISIONING_FLAGS[@]+"${PROVISIONING_FLAGS[@]}"}" \
archive
mkdir -p "${EXPORT_DIR}"
@@ -622,7 +1138,7 @@ xcodebuild \
-archivePath "${ARCHIVE_PATH}" \
-exportPath "${EXPORT_DIR}" \
-exportOptionsPlist "${EXPORT_OPTIONS_PLIST}" \
- "${PROVISIONING_FLAGS[@]}"
+ "${PROVISIONING_FLAGS[@]+"${PROVISIONING_FLAGS[@]}"}"
EXPORTED_APP_PATH="${EXPORT_DIR}/${FULL_PRODUCT_NAME}"
if [[ ! -d "${EXPORTED_APP_PATH}" ]]; then
@@ -663,13 +1179,7 @@ echo "==> Copying app to ${OUTPUT_APP_PATH}"
mkdir -p "$(dirname "${OUTPUT_APP_PATH}")"
ditto "${EXPORTED_APP_PATH}" "${OUTPUT_APP_PATH}"
-echo "==> Verifying final app signature"
-codesign --verify --deep --strict --verbose=2 "${OUTPUT_APP_PATH}"
-
-if [[ "${SKIP_NOTARIZATION}" != "1" && "${SPCTL_ASSESS}" == "1" ]]; then
- echo "==> Assessing final app with Gatekeeper"
- spctl --assess --type execute --verbose=4 "${OUTPUT_APP_PATH}"
-fi
+validate_final_app "${OUTPUT_APP_PATH}"
clean_intermediate_build_artifacts