Skip to content

Commit 0aaefc3

Browse files
committed
fix(cli): fix icon resizing
1 parent 381ce6f commit 0aaefc3

1 file changed

Lines changed: 46 additions & 17 deletions

File tree

src/cli/main.cc

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,7 +2954,7 @@ int main (int argc, char* argv[]) {
29542954
auto compileIconAssets = [&]() {
29552955
auto src = paths.platformSpecificOutputPath;
29562956

2957-
Vector<Tuple<int, int>> types = {};
2957+
Vector<Tuple<double, double>> types = {};
29582958
JSON::Array images;
29592959

29602960
const String prefix = isForDesktop ? "mac" : "ios";
@@ -2971,14 +2971,36 @@ int main (int argc, char* argv[]) {
29712971
const String size = pair[0];
29722972
const String scale = pair[1];
29732973

2974-
images.push(JSON::Object::Entries {
2975-
{ "size", size + "x" + size },
2976-
{ "idiom", isForDesktop ? "mac" : "iphone" },
2977-
{ "filename", "Icon-" + size + "x" + size + "@" + scale + ".png" },
2978-
{ "scale", scale }
2979-
});
2974+
if (size == "1024") {
2975+
images.push(JSON::Object::Entries {
2976+
{ "size", size + "x" + size },
2977+
{ "idiom", isForDesktop ? "mac" : "ios-marketing" },
2978+
{ "filename", "Icon-" + size + "x" + size + "@" + scale + ".png" },
2979+
{ "scale", scale }
2980+
});
2981+
} else if (isForDesktop) {
2982+
images.push(JSON::Object::Entries {
2983+
{ "size", size + "x" + size },
2984+
{ "idiom", "mac" },
2985+
{ "filename", "Icon-" + size + "x" + size + "@" + scale + ".png" },
2986+
{ "scale", scale }
2987+
});
2988+
} else {
2989+
images.push(JSON::Object::Entries {
2990+
{ "size", size + "x" + size },
2991+
{ "idiom", "iphone" },
2992+
{ "filename", "Icon-" + size + "x" + size + "@" + scale + ".png" },
2993+
{ "scale", scale }
2994+
});
2995+
images.push(JSON::Object::Entries {
2996+
{ "size", size + "x" + size },
2997+
{ "idiom", "ipad" },
2998+
{ "filename", "Icon-" + size + "x" + size + "@" + scale + ".png" },
2999+
{ "scale", scale }
3000+
});
3001+
}
29803002

2981-
types.push_back(std::make_tuple(stoi(pair[0]), stoi(pair[1])));
3003+
types.push_back(std::make_tuple(std::stof(pair[0]), std::stof(pair[1])));
29823004
}
29833005

29843006
auto assetsPath = fs::path { src / "Assets.xcassets" };
@@ -3002,9 +3024,9 @@ int main (int argc, char* argv[]) {
30023024
for (const auto& type : types) {
30033025
const auto size = std::get<0>(type);
30043026
const auto scale = std::get<1>(type);
3005-
const auto scaled = std::to_string(size * scale);
3006-
const auto destFileName = "Icon-" + std::to_string(size) + "x" + std::to_string(size) + "@" + std::to_string(scale) + "x.png";
3007-
const auto destFilePath = Path { iconsPath / destFileName };
3027+
const auto scaled = JSON::Number(size * scale).str();
3028+
const auto destFileName = "Icon-" + JSON::Number(size).str() + "x" + JSON::Number(size).str() + "@" + JSON::Number(scale).str() + "x.png";
3029+
const auto destFilePath = iconsPath.string() + "/" + destFileName;
30083030

30093031
const auto src = isForDesktop ? settings["mac_icon"] : settings["ios_icon"];
30103032

@@ -3026,6 +3048,11 @@ int main (int argc, char* argv[]) {
30263048
log(r.output);
30273049
exit(1);
30283050
}
3051+
3052+
if (flagBuildForIOS) {
3053+
const auto resources = paths.platformSpecificOutputPath;
3054+
fs::copy(destFilePath, resources / destFileName, fs::copy_options::overwrite_existing);
3055+
}
30293056
}
30303057

30313058
const auto dest = isForDesktop
@@ -3036,9 +3063,10 @@ int main (int argc, char* argv[]) {
30363063
compileAssetsCommand
30373064
<< "xcrun "
30383065
<< "actool \"" << assetsPath.string() << "\" "
3066+
<< "--include-all-app-icons "
30393067
<< "--compile \"" << dest.string() << "\" "
30403068
<< "--platform " << (targetPlatform == "ios" || targetPlatform == "ios-simulator" ? "iphoneos" : "macosx") << " "
3041-
<< "--minimum-deployment-target 10.15 "
3069+
<< "--minimum-deployment-target " << (targetPlatform == "ios" || targetPlatform == "ios-simulator" ? "15.0" : "10.15") << " "
30423070
<< "--app-icon AppIcon "
30433071
<< "--output-partial-info-plist "
30443072
<< "\""
@@ -4812,6 +4840,10 @@ int main (int argc, char* argv[]) {
48124840
}
48134841

48144842
settings["ios_info_plist_data"] += (
4843+
String(" </array>\n") +
4844+
" <key>BGTaskSchedulerPermittedIdentifiers</key>\n" +
4845+
" <array>\n" +
4846+
" <string>" + settings["meta_bundle_identifier"] + "</string>\n" +
48154847
" </array>\n"
48164848
);
48174849

@@ -5295,11 +5327,8 @@ int main (int argc, char* argv[]) {
52955327
);
52965328
}
52975329

5298-
if (flagDebugMode) {
5299-
entitlementSettings["configured_entitlements"] += (
5300-
" <key>get-task-allow</key>\n"
5301-
" <true/>\n "
5302-
);
5330+
if (flagDebugMode && settings["ios_distribution_method"] == "debugging") {
5331+
entitlementSettings["configured_entitlements"] += (" <key>get-task-allow</key>\n" " <true/>\n ");
53035332
}
53045333

53055334
writeFile(

0 commit comments

Comments
 (0)