Skip to content

Commit

Permalink
Fix and update iOS and tvOS SDK creation shell scripts (#68)
Browse files Browse the repository at this point in the history
* Script modifications

* Whoops

* Revert create_patched_sdk.py changes

* Support new device support dir names

* tvOS or TVOS where appropriate

* Add arm64e to iOS ARCHS

* Add support for new directory names for tvOS

* re-order tvOS tbd call to match iOS

---------

Co-authored-by: Lightmann <lightmanns11@gmail.com>
  • Loading branch information
leptos-null and L1ghtmann authored Dec 27, 2023
1 parent 146e41f commit ff2f93a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 45 deletions.
19 changes: 7 additions & 12 deletions create_patched_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi
# tbd info
version="v3"

archs_option=("--replace-archs" armv7 armv7s arm64)
archs_option=("--replace-archs" armv7 armv7s arm64 arm64e)
tbd_options=("--ignore-clients" "--ignore-undefineds" "--allow-private-objc-symbols" "--ignore-missing-exports")
write_options=("--preserve-subdirs" "--replace-path-extension")

Expand All @@ -61,14 +61,12 @@ if [[ $# -lt 5 ]] || ignored $tbd_tool; then
else
tbd_exists=$(command -v "$tbd_tool")
if [[ -z $tbd_exists ]]; then
printf "Provided tbd-tool (%s) doesn't exist\n" "$tbd_tool"
printf "Provided tbd-tool (%s) doesn't exist or isn't executable\n" "$tbd_tool"
exit 1
fi
fi

use_simulator="$1"
device_support_dir="$HOME/Library/Developer/Xcode/iOS DeviceSupport/"

if [[ $# -lt 1 ]]; then
use_simulator="-"
fi
Expand All @@ -91,11 +89,10 @@ if ! [[ -d $xcode_sim_runtime_path ]]; then
fi
xcode_default_sdk_path="$xcode_developer_path/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"

xcode_sdk_paths="$xcode_developer_path/Platforms/iPhoneOS.platform/Developer/SDKs/*"
preferred_xcode_sdk_path=""

for xcode_sdk_path in "$xcode_sdk_paths"; do
xcode_sdk_real=$(realpath $xcode_sdk_path)
for xcode_sdk_path in "$xcode_developer_path/Platforms/iPhoneOS.platform/Developer/SDKs/"*; do
xcode_sdk_real=$(realpath "$xcode_sdk_path")

if [[ $xcode_sdk_real == $xcode_default_sdk_path ]]; then
preferred_xcode_sdk_path=$xcode_sdk_path
Expand All @@ -114,16 +111,14 @@ xcode_sdk_ios_version=${xcode_sdk_ios_version%????} # Remove '.sdk' at back of s

sdks_output_path_single_sdk_path=""

if [[ -d $device_support_dir]] && ignored $use_simulator; then
device_support_dir="$HOME/Library/Developer/Xcode/iOS DeviceSupport/"
if [[ -d $device_support_dir ]] && ignored $use_simulator; then
for symbols_path in "$device_support_dir"*; do
if ! [[ -d $symbols_path ]]; then
continue
fi

symbols_path_basename=$(basename "$symbols_path")
symbols_path_basename_array=($symbols_path_basename)

ios_version=${symbols_path_basename_array[0]}
ios_version="$(basename "$symbols_path" | grep -o "\d\+\(\.\d\+\)\{1,2\}")"
sdk_name=$(printf "iPhoneOS%s.sdk" $ios_version)

symbols_actual_path="$symbols_path/Symbols/System"
Expand Down
54 changes: 21 additions & 33 deletions create_patched_sdk_tvos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ if [[ $# -lt 5 ]] || ignored $tbd_tool; then
else
tbd_exists=$(command -v "$tbd_tool")
if [[ -z $tbd_exists ]]; then
printf "Provided tbd-tool (%s) doesn't exist\n" "$tbd_tool"
printf "Provided tbd-tool (%s) doesn't exist or isn't executable\n" "$tbd_tool"
exit 1
fi
fi

use_simulator="$1"
device_support_dir="$HOME/Library/Developer/Xcode/tvOS DeviceSupport/"

if [[ $# -lt 1 ]]; then
use_simulator="-"
fi
Expand All @@ -89,14 +87,12 @@ if [[ -z $xcode_developer_path ]]; then
exit 1
fi

xcode_sim_runtime_path="$xcode_developer_path/Platforms/AppleTVOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot"
xcode_sim_runtime_path="$xcode_developer_path/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot"
xcode_default_sdk_path="$xcode_developer_path/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk"

xcode_sdk_paths="$xcode_developer_path/Platforms/AppleTVOS.platform/Developer/SDKs/*"

preferred_xcode_sdk_path=""
for xcode_sdk_path in "$xcode_sdk_paths"; do
xcode_sdk_real=$(realpath $xcode_sdk_path)
for xcode_sdk_path in "$xcode_developer_path/Platforms/AppleTVOS.platform/Developer/SDKs/"*; do
xcode_sdk_real=$(realpath "$xcode_sdk_path")

if [[ $xcode_sdk_real == $xcode_default_sdk_path ]]; then
preferred_xcode_sdk_path=$xcode_sdk_path
Expand All @@ -110,56 +106,48 @@ fi

preferred_xcode_sdk_name=$(basename $preferred_xcode_sdk_path)

xcode_sdk_ios_version=${preferred_xcode_sdk_name:8} # Remove 'iPhoneOS' in front of sdk name
xcode_sdk_ios_version=${xcode_sdk_ios_version%????} # Remove '.sdk' at back of sdk name
xcode_sdk_tvos_version=${preferred_xcode_sdk_name:9} # Remove 'AppleTVOS' in front of sdk name
xcode_sdk_tvos_version=${xcode_sdk_tvos_version%????} # Remove '.sdk' at back of sdk name

sdks_output_path_single_sdk_path=""

device_support_dir="$HOME/Library/Developer/Xcode/tvOS DeviceSupport/"
if [[ -d $device_support_dir ]] && ignored $use_simulator; then
for symbols_path in "$device_support_dir"*; do
if ! [[ -d $symbols_path ]]; then
continue
fi

symbols_path_basename=$(basename "$symbols_path")
symbols_path_basename_array=($symbols_path_basename)

ios_version=${symbols_path_basename_array[0]}
sdk_name=$(printf "AppleTVOS%s.sdk" $ios_version)
tvos_version="$(basename "$symbols_path" | grep -o "\d\+\(\.\d\+\)\{1,2\}")"
sdk_name=$(printf "AppleTVOS%s.sdk" $tvos_version)

symbols_actual_path="$symbols_path/Symbols/System"
if ! [[ -d $symbols_actual_path ]]; then
printf "Symbols for iOS %s don't exist\n" "$ios_version"
printf "Symbols for tvOS %s don't exist\n" "$tvos_version"
continue
fi

sdks_output_path_single_sdk_path="$sdks_output_path/$sdk_name"
if [[ -d $sdks_output_path_single_sdk_path ]]; then
printf 'SDK for iOS %s already exists\n' "$ios_version"
printf 'SDK for tvOS %s already exists\n' "$tvos_version"
continue
fi

printf 'Creating SDK for iOS %s ...\n' "$ios_version"
printf 'Creating SDK for tvOS %s ...\n' "$tvos_version"

if [[ $xcode_sdk_ios_version != $ios_version ]]; then
printf "Warning: Xcode SDK for iOS %s will be used as a base for sdk for iOS %s\n" $xcode_sdk_ios_version "$ios_version"
if [[ $xcode_sdk_tvos_version != $tvos_version ]]; then
printf "Warning: Xcode SDK for tvOS %s will be used as a base for sdk for tvOS %s\n" $xcode_sdk_tvos_version "$tvos_version"
fi

mkdir -p "$sdks_output_path_single_sdk_path"
cp -R "$xcode_default_sdk_path/"* "$sdks_output_path_single_sdk_path"

science="$tbd_tool -p -r all $symbols_actual_path \
-o ${write_options[@]} $no_overwrite $sdks_output_path_single_sdk_path/System \
$no_warnings ${tbd_options[@]} ${archs_option[@]} -v $version"

#echo $science

"$tbd_tool" -p -r all "$symbols_actual_path" \
-o "${write_options[@]}" $no_overwrite "$sdks_output_path_single_sdk_path/System" \
$no_warnings "${tbd_options[@]}" "${archs_option[@]}" -v $version
"$tbd_tool" \
-p $no_warnings "${tbd_options[@]}" "${archs_option[@]}" -v $version -r all "$symbols_actual_path" \
-o "${write_options[@]}" $no_overwrite "$sdks_output_path_single_sdk_path/System"

if [[ $? -ne 0 ]]; then
printf 'Failed to create tbds from Symbols directory for iOS %s\n' $ios_version
printf 'Failed to create tbds from Symbols directory for tvOS %s\n' $tvos_version
fi
done
else
Expand All @@ -169,11 +157,11 @@ else

sdks_output_path_single_sdk_path="$sdks_output_path/$preferred_xcode_sdk_name"
if [[ -d $sdks_output_path_single_sdk_path ]]; then
printf 'SDK for iOS %s already exists\n' $xcode_sdk_ios_version
printf 'SDK for tvOS %s already exists\n' $xcode_sdk_tvos_version
exit 1
fi

printf 'Creating sdk for iOS %s ...\n' "$xcode_sdk_ios_version"
printf 'Creating sdk for tvOS %s ...\n' "$xcode_sdk_tvos_version"

mkdir -p "$sdks_output_path_single_sdk_path"
cp -R "$xcode_default_sdk_path/"* "$sdks_output_path_single_sdk_path"
Expand All @@ -189,6 +177,6 @@ else
"$tbd_tool" "${parse_paths[@]}" "${write_paths[@]}" $no_warnings "${tbd_options[@]}" "${archs_option[@]}" -v $version

if [[ $? -ne 0 ]]; then
printf 'Failed to create tbds from iPhoneSimulator runtime for iOS %s\n' $xcode_sdk_ios_version
printf 'Failed to create tbds from AppleTVSimulator runtime for tvOS %s\n' $xcode_sdk_tvos_version
fi
fi

0 comments on commit ff2f93a

Please sign in to comment.