Repository navigation
Expand file tree
/
Copy pathtypings-gen.sh
More file actions
executable file
·97 lines (71 loc) · 3.65 KB
/
Copy pathtypings-gen.sh
File metadata and controls
executable file
·97 lines (71 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -e -o pipefail
IOS_RUNTIME_VERSION=$1
METADATA_GENERATOR_PATH=$2
if [ -z "$1" ]
then
printf "Usage:\n"
printf "./typings-gen.sh <tns-ios-npm-version> [<objc-metadata-generator-binary>]\n"
printf "\n\nExample:\n"
printf "./typings-gen.sh rc ~/work/ios-runtime/cmake-build/metadataGenerator/bin/objc-metadata-generator\n\n"
exit -1
fi
if [ -n "$METADATA_GENERATOR_PATH" -a ! -f "$METADATA_GENERATOR_PATH" ]
then
echo "error: Specified metadata generator binary \"$METADATA_GENERATOR_PATH\" does not exist!"
exit -2
fi
echo "Creating typings project with @nativescript/ios@$IOS_RUNTIME_VERSION..."
rm -rf ios-typings-prj
ns create --template @nativescript/template-blank@latest ios-typings-prj
ns platform add ios@$IOS_RUNTIME_VERSION --path ios-typings-prj/
# For iOS 26
echo "FRAMEWORK_SEARCH_PATHS = \$(inherited) \$(SDKDIR)/System/Library/SubFrameworks" >> ios-typings-prj/App_Resources/iOS/build.xcconfig
if [ -n "$METADATA_GENERATOR_PATH" ]
then
echo "Replacing metadata generator binary with: $METADATA_GENERATOR_PATH"
rm ios-typings-prj/platforms/ios/internal/metadata-generator/bin/objc-metadata-generator
cp $METADATA_GENERATOR_PATH ios-typings-prj/platforms/ios/internal/metadata-generator/bin/objc-metadata-generator
fi
echo "Building project and generating typings..."
TNS_TYPESCRIPT_DECLARATIONS_PATH=$(pwd)/ios-typings-prj/typings ns build ios --debug --path ios-typings-prj/
echo "Deleting old ios typings (ios/objc-x86_64)..."
rm -f packages/types-ios/src/lib/ios/objc-x86_64/*
# echo "Deleting Material Components typings..."
# rm ios-typings-prj/typings/x86_64/objc\!MaterialComponents.d.ts
# Remove methods attached to other modules via extensions (UIKit, QuartzCore)
# perl -pi -e 's/.*\s(mdc_|MDCFontTextStyle|MDCAnimationTimingFunction).*\s*//g' ios-typings-prj/typings/x86_64/*.d.ts
echo "Moving generated typings to ios/objc-x86_64..."
mv ios-typings-prj/typings/x86_64/* packages/types-ios/src/lib/ios/objc-x86_64/
pushd packages/types-ios/src/lib/ios/objc-x86_64
echo "Pruning C shim typings nothing else references..."
# Keep XPC, os_object, os_workgroup and the _DarwinFoundation set: framework
# typings take their types (OS_xpc_object, OS_object, FILE, timeval, ...) as parameters.
rm -f 'objc!libunwind.d.ts' 'objc!libxml2.d.ts' 'objc!rpc.d.ts' 'objc!_Builtin_intrinsics.d.ts' 'objc!_Builtin_stdatomic.d.ts' 'objc!libkern.d.ts' 'objc!unwind.d.ts' 'objc!xlocale.d.ts'
# <time.h>'s `extern long timezone` shadows the `struct timezone` handle that
# Darwin's settimeofday() takes, and nothing references the global.
perl -0pi -e 's/\ndeclare var timezone: number;\n//' 'objc!_DarwinFoundation2.d.ts'
popd
echo "Emitting (ios/ios.d.ts)..."
pushd packages/types-ios/src/lib/ios
rm ios.d.ts
echo '/// <reference path="runtime.d.ts" />' > ios.d.ts
for i in `ls objc-x86_64/*.d.ts`; do
echo "/// <reference path=\"$i\" />" >> ios.d.ts
done
popd
echo "Checking the default reference set (ios/common.d.ts)..."
pushd packages/types-ios/src/lib/ios
# UIKit's declarations use types the iOS 26 SDK moved into UIUtilities (UIAxis,
# UIRectEdge, UICoordinateSpace), so the default set has to carry it next to UIKit.
if [ -f 'objc-x86_64/objc!UIUtilities.d.ts' ] && ! grep -q 'objc!UIUtilities.d.ts' common.d.ts; then
perl -pi -e 's|^(/// <reference path="objc-x86_64/objc!UIKit.d.ts" />)$|$1\n/// <reference path="objc-x86_64/objc!UIUtilities.d.ts" />|' common.d.ts
fi
# Every file the default set references must exist in this generation.
for ref in $(grep -o 'objc-x86_64/[^"]*' common.d.ts); do
if [ ! -f "$ref" ]; then
echo "error: common.d.ts references $ref, which was not generated"
exit 3
fi
done
popd