Skip to content

Commit 3181b94

Browse files
committed
fix(metagen): emit current iOS SDK types
1 parent db5f4eb commit 3181b94

2 files changed

Lines changed: 59 additions & 5 deletions

File tree

scripts/metagen.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ function getSDKPath(platform) {
6565
return output.stdout.trim();
6666
}
6767

68+
const sdkVersionCache = new Map();
69+
70+
function getSDKVersion(platform) {
71+
const cached = sdkVersionCache.get(platform);
72+
if (cached) {
73+
return cached;
74+
}
75+
76+
const output = spawnSync("xcrun", ["--sdk", platform, "--show-sdk-version"], {
77+
stdio: ["ignore", "pipe", "inherit"],
78+
encoding: "utf8",
79+
});
80+
81+
if (output.status !== 0) {
82+
throw new Error(`Failed to get SDK version for ${platform}`);
83+
}
84+
85+
const version = output.stdout.trim();
86+
sdkVersionCache.set(platform, version);
87+
return version;
88+
}
89+
6890
function sleep(ms) {
6991
return new Promise((resolve) => setTimeout(resolve, ms));
7092
}
@@ -263,25 +285,25 @@ const sdks = {
263285
path: getSDKPath("iphoneos"),
264286
frameworks: [...COMMON_FRAMEWORKS, ...IOS_FRAMEWORKS],
265287
targets: {
266-
arm64: "arm64-apple-ios13.0",
288+
arm64: `arm64-apple-ios${getSDKVersion("iphoneos")}`,
267289
},
268290
tnsTarget: "ios-arm64",
269291
},
270292
"ios-sim": {
271293
path: getSDKPath("iphonesimulator"),
272294
frameworks: [...COMMON_FRAMEWORKS, ...IOS_FRAMEWORKS],
273295
targets: {
274-
x86_64: "x86_64-apple-ios13.0-simulator",
275-
arm64: "arm64-apple-ios13.0-simulator",
296+
x86_64: `x86_64-apple-ios${getSDKVersion("iphonesimulator")}-simulator`,
297+
arm64: `arm64-apple-ios${getSDKVersion("iphonesimulator")}-simulator`,
276298
},
277299
tnsTarget: "ios-arm64_x86_64-simulator",
278300
},
279301
catalyst: {
280302
path: getSDKPath("iphoneos"),
281303
frameworks: [...COMMON_FRAMEWORKS, ...MACOS_FRAMEWORKS, ...IOS_FRAMEWORKS],
282304
targets: {
283-
x86_64: "x86_64-apple-ios13.0-macabi",
284-
arm64: "arm64-apple-ios13.0-macabi",
305+
x86_64: `x86_64-apple-ios${getSDKVersion("iphoneos")}-macabi`,
306+
arm64: `arm64-apple-ios${getSDKVersion("iphoneos")}-macabi`,
285307
},
286308
tnsTarget: "ios-arm64_x86_64-maccatalyst",
287309
},

test/react-native/ffi-compat/App.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,38 @@ function buildReactNativeIntegrationTests(): TestCase[] {
12251225
});
12261226
},
12271227
},
1228+
{
1229+
name: 'exposes current UIKit SDK tab accessory APIs when available',
1230+
async run() {
1231+
if (!NativeScript.isClassAvailable('UITabAccessory')) {
1232+
return;
1233+
}
1234+
await NativeScript.runOnUI(() => {
1235+
const contentView = g('UIView').new();
1236+
const accessory = g('UITabAccessory')
1237+
.alloc()
1238+
.initWithContentView(contentView);
1239+
assert(
1240+
accessory.contentView.isEqual(contentView),
1241+
'UITabAccessory contentView should round-trip',
1242+
);
1243+
1244+
const controller = g('UITabBarController').new();
1245+
controller.bottomAccessory = accessory;
1246+
assert(
1247+
controller.bottomAccessory.isEqual(accessory),
1248+
'UITabBarController.bottomAccessory should round-trip',
1249+
);
1250+
1251+
controller.setBottomAccessoryAnimated(null, false);
1252+
assertEqual(
1253+
controller.bottomAccessory,
1254+
null,
1255+
'UITabBarController bottom accessory should clear',
1256+
);
1257+
});
1258+
},
1259+
},
12281260
{
12291261
name: 'retains, releases, and disposes native helper lifetimes explicitly',
12301262
run() {

0 commit comments

Comments
 (0)