fix(tvos): sync version

This commit is contained in:
edde746
2026-06-07 08:51:02 +02:00
parent cda4c1e78a
commit 83899a38f3
3 changed files with 60 additions and 10 deletions
+15
View File
@@ -287,6 +287,7 @@
B1C48839AB6C24EF099DDFA3 /* Sources */,
43E2EE359822E384AD7E8A2E /* Frameworks */,
64CEA7DE6B9394CE88783302 /* Resources */,
E2B5A6D75C9F4D1B9E8C7A63 /* Sync Version */,
);
buildRules = (
);
@@ -436,6 +437,20 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
E2B5A6D75C9F4D1B9E8C7A63 /* Sync Version */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Sync Version";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/bash \"$SOURCE_ROOT/scripts/xcode_appletv.sh\" sync_version\n";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
+17
View File
@@ -51,6 +51,17 @@ def ensure_framework(target, file_ref)
phase.add_file_reference(file_ref, true)
end
def ensure_shell_script(target, name, script)
phase = target.shell_script_build_phases.find { |p| p.name == name }
unless phase
phase = target.new_shell_script_build_phase(name)
end
phase.shell_path = '/bin/sh'
phase.shell_script = script
phase
end
system_shelf_ref = ensure_file(runner_group, 'SystemShelfPlugin.swift')
ensure_source(runner, system_shelf_ref)
ensure_file(runner_group, 'Runner.entitlements')
@@ -141,5 +152,11 @@ extension_target.build_configurations.each do |config|
settings['TVOS_DEPLOYMENT_TARGET'] = '14.0'
end
ensure_shell_script(
extension_target,
'Sync Version',
'/bin/bash "$SOURCE_ROOT/scripts/xcode_appletv.sh" sync_version' + "\n"
)
project.save
puts 'Saved Top Shelf wiring'
+28 -10
View File
@@ -21,11 +21,8 @@ else
fi
ReadPubspecVersion() {
if [[ -n "${FLUTTER_BUILD_NAME:-}" && -n "${FLUTTER_BUILD_NUMBER:-}" ]]; then
export FLUTTER_BUILD_NAME
export FLUTTER_BUILD_NUMBER
return 0
fi
local fallback_build_name="${FLUTTER_BUILD_NAME:-}"
local fallback_build_number="${FLUTTER_BUILD_NUMBER:-}"
local app_path="${FLUTTER_APPLICATION_PATH:-}"
if [[ -z "$app_path" ]]; then
@@ -65,8 +62,8 @@ ReadPubspecVersion() {
FLUTTER_BUILD_NUMBER="1"
fi
else
FLUTTER_BUILD_NAME="${FLUTTER_BUILD_NAME:-1.0.0}"
FLUTTER_BUILD_NUMBER="${FLUTTER_BUILD_NUMBER:-1}"
FLUTTER_BUILD_NAME="${fallback_build_name:-1.0.0}"
FLUTTER_BUILD_NUMBER="${fallback_build_number:-1}"
fi
export FLUTTER_BUILD_NAME
@@ -78,13 +75,31 @@ SetPlistString() {
local key="$2"
local value="$3"
if /usr/libexec/PlistBuddy -c "Print :$key" "$plist" >/dev/null 2>&1; then
/usr/libexec/PlistBuddy -c "Set :$key $value" "$plist"
local current=""
if current="$(/usr/libexec/PlistBuddy -c "Print :$key" "$plist" 2>/dev/null)"; then
if [[ "$current" != "$value" ]]; then
/usr/libexec/PlistBuddy -c "Set :$key $value" "$plist"
fi
else
/usr/libexec/PlistBuddy -c "Add :$key string $value" "$plist"
fi
}
ValidatePlistVersion() {
local plist="$1"
local label="$2"
local build_name=""
local build_number=""
build_name="$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$plist" 2>/dev/null || true)"
build_number="$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$plist" 2>/dev/null || true)"
if [[ "$build_name" != "$FLUTTER_BUILD_NAME" || "$build_number" != "$FLUTTER_BUILD_NUMBER" ]]; then
echo " └─ERROR: $label Info.plist version is $build_name ($build_number), expected $FLUTTER_BUILD_NAME ($FLUTTER_BUILD_NUMBER)"
return 1
fi
}
SyncRunnerVersion() {
ReadPubspecVersion
@@ -101,15 +116,18 @@ SyncRunnerVersion() {
return 1
fi
echo " └─Syncing Runner version $FLUTTER_BUILD_NAME ($FLUTTER_BUILD_NUMBER)"
local bundle_label="${TARGET_NAME:-Runner}"
echo " └─Syncing $bundle_label version $FLUTTER_BUILD_NAME ($FLUTTER_BUILD_NUMBER)"
SetPlistString "$plist" CFBundleShortVersionString "$FLUTTER_BUILD_NAME"
SetPlistString "$plist" CFBundleVersion "$FLUTTER_BUILD_NUMBER"
ValidatePlistVersion "$plist" "$bundle_label"
local top_shelf_plist="$TARGET_BUILD_DIR/$WRAPPER_NAME/PlugIns/TopShelfExtension.appex/Info.plist"
if [[ -f "$top_shelf_plist" ]]; then
echo " └─Syncing TopShelfExtension version $FLUTTER_BUILD_NAME ($FLUTTER_BUILD_NUMBER)"
SetPlistString "$top_shelf_plist" CFBundleShortVersionString "$FLUTTER_BUILD_NAME"
SetPlistString "$top_shelf_plist" CFBundleVersion "$FLUTTER_BUILD_NUMBER"
ValidatePlistVersion "$top_shelf_plist" "TopShelfExtension"
fi
}