Skip to content

Commit 5a67623

Browse files
authored
perf: reduce Apple runner build overhead (#898)
1 parent 93d5275 commit 5a67623

9 files changed

Lines changed: 154 additions & 75 deletions

File tree

ios-runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
ALWAYS_SEARCH_USER_PATHS = NO;
207207
AGENT_DEVICE_IOS_RUNNER_APP_BUNDLE_ID = com.callstack.agentdevice.runner;
208208
AGENT_DEVICE_IOS_RUNNER_TEST_BUNDLE_ID = "$(AGENT_DEVICE_IOS_RUNNER_APP_BUNDLE_ID).uitests";
209-
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
209+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
210210
CLANG_ANALYZER_NONNULL = YES;
211211
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
212212
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -273,7 +273,7 @@
273273
ALWAYS_SEARCH_USER_PATHS = NO;
274274
AGENT_DEVICE_IOS_RUNNER_APP_BUNDLE_ID = com.callstack.agentdevice.runner;
275275
AGENT_DEVICE_IOS_RUNNER_TEST_BUNDLE_ID = "$(AGENT_DEVICE_IOS_RUNNER_APP_BUNDLE_ID).uitests";
276-
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
276+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
277277
CLANG_ANALYZER_NONNULL = YES;
278278
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
279279
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -337,7 +337,7 @@
337337
DEVELOPMENT_TEAM = 2S799L9W4M;
338338
ENABLE_PREVIEWS = YES;
339339
GENERATE_INFOPLIST_FILE = YES;
340-
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
340+
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = NO;
341341
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
342342
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
343343
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
@@ -373,7 +373,7 @@
373373
DEVELOPMENT_TEAM = 2S799L9W4M;
374374
ENABLE_PREVIEWS = YES;
375375
GENERATE_INFOPLIST_FILE = YES;
376-
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
376+
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = NO;
377377
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
378378
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
379379
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#import <TargetConditionals.h>
2+
3+
#if TARGET_OS_OSX
4+
#import <Cocoa/Cocoa.h>
5+
6+
@interface AgentDeviceRunnerAppDelegate : NSObject <NSApplicationDelegate>
7+
@property(nonatomic, strong) NSWindow *window;
8+
@end
9+
10+
@implementation AgentDeviceRunnerAppDelegate
11+
12+
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
13+
(void)notification;
14+
15+
NSRect frame = NSMakeRect(0, 0, 360, 220);
16+
self.window = [[NSWindow alloc] initWithContentRect:frame
17+
styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
18+
NSWindowStyleMaskMiniaturizable)
19+
backing:NSBackingStoreBuffered
20+
defer:NO];
21+
self.window.title = @"Agent Device Runner";
22+
23+
NSTextField *label = [NSTextField labelWithString:@"Agent Device Runner"];
24+
label.font = [NSFont systemFontOfSize:20 weight:NSFontWeightSemibold];
25+
label.translatesAutoresizingMaskIntoConstraints = NO;
26+
27+
NSView *contentView = [[NSView alloc] initWithFrame:frame];
28+
[contentView addSubview:label];
29+
self.window.contentView = contentView;
30+
31+
[NSLayoutConstraint activateConstraints:@[
32+
[label.centerXAnchor constraintEqualToAnchor:contentView.centerXAnchor],
33+
[label.centerYAnchor constraintEqualToAnchor:contentView.centerYAnchor],
34+
]];
35+
36+
[self.window center];
37+
[self.window makeKeyAndOrderFront:nil];
38+
}
39+
40+
@end
41+
42+
int main(int argc, const char *argv[]) {
43+
(void)argc;
44+
(void)argv;
45+
46+
@autoreleasepool {
47+
NSApplication *application = [NSApplication sharedApplication];
48+
AgentDeviceRunnerAppDelegate *delegate = [[AgentDeviceRunnerAppDelegate alloc] init];
49+
application.delegate = delegate;
50+
[application setActivationPolicy:NSApplicationActivationPolicyRegular];
51+
[application run];
52+
}
53+
54+
return 0;
55+
}
56+
57+
#else
58+
#import <UIKit/UIKit.h>
59+
60+
@interface AgentDeviceRunnerViewController : UIViewController
61+
@end
62+
63+
@implementation AgentDeviceRunnerViewController
64+
65+
- (void)viewDidLoad {
66+
[super viewDidLoad];
67+
68+
self.view.backgroundColor = UIColor.whiteColor;
69+
70+
UILabel *label = [[UILabel alloc] init];
71+
label.text = @"Agent Device Runner";
72+
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
73+
label.textAlignment = NSTextAlignmentCenter;
74+
label.translatesAutoresizingMaskIntoConstraints = NO;
75+
76+
[self.view addSubview:label];
77+
[NSLayoutConstraint activateConstraints:@[
78+
[label.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
79+
[label.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
80+
]];
81+
}
82+
83+
@end
84+
85+
@interface AgentDeviceRunnerAppDelegate : UIResponder <UIApplicationDelegate>
86+
@property(nonatomic, strong) UIWindow *window;
87+
@end
88+
89+
@implementation AgentDeviceRunnerAppDelegate
90+
91+
- (BOOL)application:(UIApplication *)application
92+
didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
93+
(void)application;
94+
(void)launchOptions;
95+
96+
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
97+
self.window.rootViewController = [[AgentDeviceRunnerViewController alloc] init];
98+
[self.window makeKeyAndVisible];
99+
100+
return YES;
101+
}
102+
103+
@end
104+
105+
int main(int argc, char *argv[]) {
106+
@autoreleasepool {
107+
return UIApplicationMain(argc, argv, nil, NSStringFromClass(AgentDeviceRunnerAppDelegate.class));
108+
}
109+
}
110+
111+
#endif

ios-runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

ios-runner/AgentDeviceRunner/AgentDeviceRunner/ContentView.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ extension RunnerTests {
417417
app: XCUIApplication,
418418
wasVisible: Bool
419419
) -> (wasVisible: Bool, pressed: Bool, visible: Bool) {
420+
#if os(iOS)
420421
let exceptionMessage = RunnerObjCExceptionCatcher.catchException({
421422
element.tap()
422423
element.typeText(XCUIKeyboardKey.return.rawValue)
@@ -430,6 +431,9 @@ extension RunnerTests {
430431
}
431432
sleepFor(0.2)
432433
return (wasVisible: wasVisible, pressed: true, visible: isKeyboardVisible(app: app))
434+
#else
435+
return (wasVisible: wasVisible, pressed: false, visible: false)
436+
#endif
433437
}
434438

435439
private func singleTextEntryElement(app: XCUIApplication) -> XCUIElement? {

scripts/build-xcuitest-apple.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ xcodebuild build-for-testing \
102102
AGENT_DEVICE_IOS_RUNNER_TEST_BUNDLE_ID="$RUNNER_TEST_BUNDLE_ID" \
103103
COMPILER_INDEX_STORE_ENABLE=NO \
104104
ENABLE_CODE_COVERAGE=NO \
105+
ONLY_ACTIVE_ARCH=YES \
106+
ENABLE_PREVIEWS=NO \
107+
ENABLE_DEBUG_DYLIB=NO \
105108
-IDEPackageSupportDisableManifestSandbox=1 \
106109
-IDEPackageSupportDisablePluginExecutionSandbox=1 \
107110
ENABLE_USER_SCRIPT_SANDBOXING=NO \

scripts/write-xcuitest-cache-metadata.mjs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const args = process.argv.slice(2);
88
const [platform, derivedPath, destination] = args;
99

1010
if (!platform || !derivedPath || !destination) {
11-
console.error('Usage: write-xcuitest-cache-metadata.mjs <ios|macos|tvos> <derived> <destination>');
11+
console.error(
12+
'Usage: write-xcuitest-cache-metadata.mjs <ios|macos|tvos> <derived> <destination>',
13+
);
1214
process.exit(1);
1315
}
1416

@@ -145,12 +147,14 @@ function resolveRunnerSdkName() {
145147

146148
function runAppleToolFingerprintCommand(command, args) {
147149
try {
148-
return execFileSync(command, args, {
149-
encoding: 'utf8',
150-
stdio: ['ignore', 'pipe', 'ignore'],
151-
timeout: 5000,
152-
maxBuffer: 128 * 1024,
153-
}).trim() || 'unknown';
150+
return (
151+
execFileSync(command, args, {
152+
encoding: 'utf8',
153+
stdio: ['ignore', 'pipe', 'ignore'],
154+
timeout: 5000,
155+
maxBuffer: 128 * 1024,
156+
}).trim() || 'unknown'
157+
);
154158
} catch {
155159
return 'unknown';
156160
}
@@ -164,19 +168,13 @@ function parseXcodeVersionOutput(output) {
164168
}
165169

166170
function resolveRunnerToolchainFingerprint() {
167-
const xcode = parseXcodeVersionOutput(
168-
runAppleToolFingerprintCommand('xcodebuild', ['-version']),
169-
);
171+
const xcode = parseXcodeVersionOutput(runAppleToolFingerprintCommand('xcodebuild', ['-version']));
170172
const sdkName = resolveRunnerSdkName();
171173
return {
172174
xcodeVersion: xcode.version,
173175
xcodeBuildVersion: xcode.buildVersion,
174176
sdkName,
175-
sdkVersion: runAppleToolFingerprintCommand('xcrun', [
176-
'--sdk',
177-
sdkName,
178-
'--show-sdk-version',
179-
]),
177+
sdkVersion: runAppleToolFingerprintCommand('xcrun', ['--sdk', sdkName, '--show-sdk-version']),
180178
sdkBuildVersion: runAppleToolFingerprintCommand('xcrun', [
181179
'--sdk',
182180
sdkName,
@@ -222,7 +220,13 @@ const metadata = {
222220
`AGENT_DEVICE_IOS_RUNNER_TEST_BUNDLE_ID=${testBundleId}`,
223221
],
224222
runnerSigningBuildSettings: resolveSigningBuildSettings(),
225-
runnerPerformanceBuildSettings: ['COMPILER_INDEX_STORE_ENABLE=NO', 'ENABLE_CODE_COVERAGE=NO'],
223+
runnerPerformanceBuildSettings: [
224+
'COMPILER_INDEX_STORE_ENABLE=NO',
225+
'ENABLE_CODE_COVERAGE=NO',
226+
'ONLY_ACTIVE_ARCH=YES',
227+
'ENABLE_PREVIEWS=NO',
228+
'ENABLE_DEBUG_DYLIB=NO',
229+
],
226230
runnerSandboxBuildArgs: resolveSandboxBuildArgs(),
227231
};
228232

@@ -301,9 +305,8 @@ function scoreXctestrunCandidate(candidatePath) {
301305
? 100
302306
: 0;
303307
} else if (platform === 'macos') {
304-
score += basename.includes('macos') || candidatePath.includes(`${path.sep}macos${path.sep}`)
305-
? 100
306-
: 0;
308+
score +=
309+
basename.includes('macos') || candidatePath.includes(`${path.sep}macos${path.sep}`) ? 100 : 0;
307310
}
308311
return score;
309312
}

src/platforms/ios/__tests__/runner-client.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ test('resolveRunnerPerformanceBuildSettings disables indexing and code coverage'
492492
assert.deepEqual(resolveRunnerPerformanceBuildSettings(), [
493493
'COMPILER_INDEX_STORE_ENABLE=NO',
494494
'ENABLE_CODE_COVERAGE=NO',
495+
'ONLY_ACTIVE_ARCH=YES',
496+
'ENABLE_PREVIEWS=NO',
497+
'ENABLE_DEBUG_DYLIB=NO',
495498
]);
496499
});
497500

src/platforms/ios/runner-xctestrun.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,13 @@ export function resolveRunnerBundleBuildSettings(env: NodeJS.ProcessEnv = proces
14931493
}
14941494

14951495
export function resolveRunnerPerformanceBuildSettings(): string[] {
1496-
return ['COMPILER_INDEX_STORE_ENABLE=NO', 'ENABLE_CODE_COVERAGE=NO'];
1496+
return [
1497+
'COMPILER_INDEX_STORE_ENABLE=NO',
1498+
'ENABLE_CODE_COVERAGE=NO',
1499+
'ONLY_ACTIVE_ARCH=YES',
1500+
'ENABLE_PREVIEWS=NO',
1501+
'ENABLE_DEBUG_DYLIB=NO',
1502+
];
14971503
}
14981504

14991505
export function resolveRunnerSandboxBuildArgs(): string[] {

0 commit comments

Comments
 (0)