Skip to content

Commit 912bb15

Browse files
committed
Sanitize App ID and Group IDs for Apple servers
Fix #102
1 parent 21b3539 commit 912bb15

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

source/sideload/bundle.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Bundle {
3535
} else {
3636
_frameworks = [];
3737
}
38-
_libraries = file.dirEntries(bundleDir, file.SpanMode.breadth).filter!((f) => f.isFile && f.name[$ - 6..$] == ".dylib").map!((f) => f.name[bundleDir.length + 1..$]).array;
38+
_libraries = file.dirEntries(bundleDir, file.SpanMode.breadth).filter!((f) => f.isFile && f.name[$ - ".dylib".length..$] == ".dylib").map!((f) => f.name[bundleDir.length + 1..$]).array;
3939
}
4040

4141
void bundleIdentifier(string id) => appInfo["CFBundleIdentifier"] = id.pl;

source/sideload/package.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import std.algorithm.iteration;
44
import std.algorithm.searching;
55
import std.array;
66
import std.concurrency;
7+
import std.conv;
78
import std.datetime;
89
import file = std.file;
910
import std.format;
1011
import std.path;
12+
import std.uni;
1113

1214
import slf4d;
1315

@@ -93,8 +95,13 @@ void sideloadFull(
9395
}
9496

9597
foreach (bundle; appIdsToRegister) {
96-
log.infoF!"Creating App ID `%s`..."(bundle.bundleIdentifier);
97-
developer.addAppId!iOS(team, bundle.bundleIdentifier, bundle.bundleName).unwrap();
98+
auto appIdName = bundle.bundleName.filter!((dchar c) => c.isAlphaNum).array().to!string();
99+
if (appIdName.length == 0) {
100+
appIdName = bundle.bundleIdentifier;
101+
}
102+
log.infoF!"Creating App ID `%s` for the bundle `%s`..."(appIdName, bundle.bundleIdentifier);
103+
developer.addAppId!iOS(team, bundle.bundleIdentifier, appIdName).unwrap();
104+
log.info("OK.");
98105
}
99106
listAppIdResponse = developer.listAppIds!iOS(team).unwrap();
100107
auto appIds = listAppIdResponse.appIds.filter!((appId) => bundlesWithAppID.canFind!((bundle) => appId.identifier == bundle.bundleIdentifier())).array();
@@ -110,6 +117,7 @@ void sideloadFull(
110117
// create an app group for it if needed
111118
progressCallback(5 / STEP_COUNT, "Creating an application group");
112119
auto groupIdentifier = "group." ~ mainAppIdStr;
120+
auto groupName = "app group for " ~ mainAppId.name;
113121

114122
if (isSideStore) {
115123
app.appInfo["ALTAppGroups"] = [groupIdentifier.pl].pl;
@@ -119,7 +127,7 @@ void sideloadFull(
119127
auto matchingAppGroups = appGroups.find!((appGroup) => appGroup.identifier == groupIdentifier).array();
120128
ApplicationGroup appGroup;
121129
if (matchingAppGroups.empty) {
122-
appGroup = developer.addApplicationGroup!iOS(team, groupIdentifier, mainAppName).unwrap();
130+
appGroup = developer.addApplicationGroup!iOS(team, groupIdentifier, groupName).unwrap();
123131
} else {
124132
appGroup = matchingAppGroups[0];
125133
}

0 commit comments

Comments
 (0)