Skip to content

Commit

Permalink
Add package name / bundle ID to bundle URL in development
Browse files Browse the repository at this point in the history
Summary:
Adds the package name (Android) / bundle ID (iOS) as a new URL parameter named `app` in the bundle URL. This currently has no effect on Metro, which will ignore it for bundling / caching purposes.

Changelog: [General] - Add package name / bundle ID to bundle URL in development

Reviewed By: cpojer

Differential Revision: D21429764

fbshipit-source-id: 394fe50dba72219f7594ebeac9486a8264a836a6
  • Loading branch information
motiz88 authored and facebook-github-bot committed May 12, 2020
1 parent 63099c4 commit 9b53591
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions RNTester/RNTesterUnitTests/RCTBundleURLProviderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

static NSURL *localhostBundleURL()
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false", testFile]];
return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false&app=com.apple.dt.xctest.tool", testFile]];
}

static NSURL *ipBundleURL()
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false", testFile]];
return [NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false&app=com.apple.dt.xctest.tool", testFile]];
}

@implementation NSBundle (RCTBundleURLProviderTests)
Expand Down
4 changes: 4 additions & 0 deletions React/Base/RCTBundleURLProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
NSString *query = [NSString stringWithFormat:@"platform=ios&dev=%@&minify=%@",
enableDev ? @"true" : @"false",
enableMinification ? @"true" : @"false"];
NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey];
if (bundleID) {
query = [NSString stringWithFormat:@"%@&app=%@", query, bundleID];
}
return [[self class] resourceURLForResourcePath:path packagerHost:packagerHost query:query];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,13 @@ private boolean getJSMinifyMode() {
private String createBundleURL(String mainModuleID, BundleType type, String host) {
return String.format(
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&minify=%s",
"http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s",
host,
mainModuleID,
type.typeID(),
getDevMode(),
getJSMinifyMode());
getJSMinifyMode(),
mPackageName);
}

private String createBundleURL(String mainModuleID, BundleType type) {
Expand Down

0 comments on commit 9b53591

Please sign in to comment.