Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): fix npx expo start --dev-client --ios #18747

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@expo/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### 🐛 Bug fixes

- 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))
- Add web support check to metro web in `expo start`. ([#18428](https://github.com/expo/expo/pull/18428) by [@EvanBacon](https://github.com/EvanBacon))
- 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))
- Speed up native device opening for iOS and Android. ([#18385](https://github.com/expo/expo/pull/18385) by [@EvanBacon](https://github.com/EvanBacon))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { AndroidConfig } from '@expo/config-plugins';

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

const debug = require('debug')(
'expo:start:platforms:android:AndroidAppIdResolver'
) as typeof console.log;

/** Resolves the Android package name from the Expo config or native files. */
export class AndroidAppIdResolver extends AppIdResolver {
constructor(projectRoot: string) {
Expand All @@ -12,7 +16,8 @@ export class AndroidAppIdResolver extends AppIdResolver {
try {
await AndroidConfig.Paths.getProjectPathOrThrowAsync(this.projectRoot);
return true;
} catch {
} catch (error: any) {
debug('Expected error checking for native project:', error);
return false;
}
}
Expand All @@ -33,7 +38,9 @@ export class AndroidAppIdResolver extends AppIdResolver {
if (androidManifest.manifest?.$?.package) {
return androidManifest.manifest.$.package;
}
} catch {}
} catch (error: any) {
debug('Expected error resolving the package name from the AndroidManifest.xml:', error);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import fs from 'fs';

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

const debug = require('debug')('expo:start:platforms:ios:AppleAppIdResolver') as typeof console.log;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the debug type missing here, or is this caused by the require?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by require instead of using import


/** Resolves the iOS bundle identifier from the Expo config or native files. */
export class AppleAppIdResolver extends AppIdResolver {
constructor(projectRoot: string) {
Expand All @@ -12,9 +14,11 @@ export class AppleAppIdResolver extends AppIdResolver {

async hasNativeProjectAsync(): Promise<boolean> {
try {
// Never returns nullish values.
return !!IOSConfig.Paths.getAppDelegateFilePath(this.projectRoot);
} catch {
return true;
} catch (error: any) {
debug('Expected error checking for native project:', error);
return false;
}
}

Expand All @@ -25,7 +29,9 @@ export class AppleAppIdResolver extends AppIdResolver {
if (bundleId) {
return bundleId;
}
} catch {}
} catch (error: any) {
debug('Expected error resolving the bundle identifier from the pbxproj:', error);
}

// Check Info.plist
try {
Expand All @@ -34,7 +40,9 @@ export class AppleAppIdResolver extends AppIdResolver {
if (data.CFBundleIdentifier && !data.CFBundleIdentifier.startsWith('$(')) {
return data.CFBundleIdentifier;
}
} catch {}
} catch (error) {
debug('Expected error resolving the bundle identifier from the project Info.plist:', error);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ jest.mock('@expo/config', () => ({

// Most cases are tested in the superclass.

describe('hasNativeProjectAsync', () => {
it(`returns true when the AppDelegate file exists`, async () => {
const resolver = new AppleAppIdResolver('/');
asMock(IOSConfig.Paths.getAppDelegateFilePath).mockReturnValueOnce('/foo/bar/AppDelegate.m');
expect(await resolver.hasNativeProjectAsync()).toBe(true);
});
it(`returns false when the AppDelegate getter throws`, async () => {
const resolver = new AppleAppIdResolver('/');
asMock(IOSConfig.Paths.getAppDelegateFilePath).mockImplementationOnce(() => {
throw new Error('file missing');
});
expect(await resolver.hasNativeProjectAsync()).toBe(false);
});
});

describe('getAppIdAsync', () => {
it('resolves the app id from native files', async () => {
const resolver = new AppleAppIdResolver('/');
Expand Down