Skip to content

Commit 60392ac

Browse files
EvanBaconexpo-bot
andauthored
fix(cli): fix npx expo start --dev-client --ios (expo#18747)
* fix(cli): resolve bundle identifier from `app.json` correctly when using `npx expo start --dev-client --ios` with no local `ios` directory * Update packages/@expo/cli/CHANGELOG.md Co-authored-by: Expo Bot <[email protected]> Co-authored-by: Expo Bot <[email protected]>
1 parent 8a0bed1 commit 60392ac

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

packages/@expo/cli/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
### 🐛 Bug fixes
1414

15+
- Resolve bundle identifier from `app.json` correctly when using `npx expo start --dev-client --ios` with no local `ios` directory. ([#18747](https://github.com/expo/expo/pull/18747) by [@EvanBacon](https://github.com/EvanBacon))
1516
- Add web support check to metro web in `expo start`. ([#18428](https://github.com/expo/expo/pull/18428) by [@EvanBacon](https://github.com/EvanBacon))
1617
- Prevent development session bad gateway from ending long running `expo start` processes. ([#18451](https://github.com/expo/expo/pull/18451) by [@EvanBacon](https://github.com/EvanBacon))
1718
- Speed up native device opening for iOS and Android. ([#18385](https://github.com/expo/expo/pull/18385) by [@EvanBacon](https://github.com/EvanBacon))

packages/@expo/cli/src/start/platforms/android/AndroidAppIdResolver.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { AndroidConfig } from '@expo/config-plugins';
22

33
import { AppIdResolver } from '../AppIdResolver';
44

5+
const debug = require('debug')(
6+
'expo:start:platforms:android:AndroidAppIdResolver'
7+
) as typeof console.log;
8+
59
/** Resolves the Android package name from the Expo config or native files. */
610
export class AndroidAppIdResolver extends AppIdResolver {
711
constructor(projectRoot: string) {
@@ -12,7 +16,8 @@ export class AndroidAppIdResolver extends AppIdResolver {
1216
try {
1317
await AndroidConfig.Paths.getProjectPathOrThrowAsync(this.projectRoot);
1418
return true;
15-
} catch {
19+
} catch (error: any) {
20+
debug('Expected error checking for native project:', error);
1621
return false;
1722
}
1823
}
@@ -33,7 +38,9 @@ export class AndroidAppIdResolver extends AppIdResolver {
3338
if (androidManifest.manifest?.$?.package) {
3439
return androidManifest.manifest.$.package;
3540
}
36-
} catch {}
41+
} catch (error: any) {
42+
debug('Expected error resolving the package name from the AndroidManifest.xml:', error);
43+
}
3744

3845
return null;
3946
}

packages/@expo/cli/src/start/platforms/ios/AppleAppIdResolver.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import fs from 'fs';
44

55
import { AppIdResolver } from '../AppIdResolver';
66

7+
const debug = require('debug')('expo:start:platforms:ios:AppleAppIdResolver') as typeof console.log;
8+
79
/** Resolves the iOS bundle identifier from the Expo config or native files. */
810
export class AppleAppIdResolver extends AppIdResolver {
911
constructor(projectRoot: string) {
@@ -12,9 +14,11 @@ export class AppleAppIdResolver extends AppIdResolver {
1214

1315
async hasNativeProjectAsync(): Promise<boolean> {
1416
try {
17+
// Never returns nullish values.
1518
return !!IOSConfig.Paths.getAppDelegateFilePath(this.projectRoot);
16-
} catch {
17-
return true;
19+
} catch (error: any) {
20+
debug('Expected error checking for native project:', error);
21+
return false;
1822
}
1923
}
2024

@@ -25,7 +29,9 @@ export class AppleAppIdResolver extends AppIdResolver {
2529
if (bundleId) {
2630
return bundleId;
2731
}
28-
} catch {}
32+
} catch (error: any) {
33+
debug('Expected error resolving the bundle identifier from the pbxproj:', error);
34+
}
2935

3036
// Check Info.plist
3137
try {
@@ -34,7 +40,9 @@ export class AppleAppIdResolver extends AppIdResolver {
3440
if (data.CFBundleIdentifier && !data.CFBundleIdentifier.startsWith('$(')) {
3541
return data.CFBundleIdentifier;
3642
}
37-
} catch {}
43+
} catch (error) {
44+
debug('Expected error resolving the bundle identifier from the project Info.plist:', error);
45+
}
3846

3947
return null;
4048
}

packages/@expo/cli/src/start/platforms/ios/__tests__/AppleAppIdResolver-test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ jest.mock('@expo/config', () => ({
2828

2929
// Most cases are tested in the superclass.
3030

31+
describe('hasNativeProjectAsync', () => {
32+
it(`returns true when the AppDelegate file exists`, async () => {
33+
const resolver = new AppleAppIdResolver('/');
34+
asMock(IOSConfig.Paths.getAppDelegateFilePath).mockReturnValueOnce('/foo/bar/AppDelegate.m');
35+
expect(await resolver.hasNativeProjectAsync()).toBe(true);
36+
});
37+
it(`returns false when the AppDelegate getter throws`, async () => {
38+
const resolver = new AppleAppIdResolver('/');
39+
asMock(IOSConfig.Paths.getAppDelegateFilePath).mockImplementationOnce(() => {
40+
throw new Error('file missing');
41+
});
42+
expect(await resolver.hasNativeProjectAsync()).toBe(false);
43+
});
44+
});
45+
3146
describe('getAppIdAsync', () => {
3247
it('resolves the app id from native files', async () => {
3348
const resolver = new AppleAppIdResolver('/');

0 commit comments

Comments
 (0)