(后面就是代码了,我就不翻译了。)
#!/usr/bin/perl
use File::Copy;
my $installPath = $ARGV[0];
#the name that displays on the iPhone
my $bundleDisplayName = "New App";
# prerendered icons don't have the glossy effect applied over them.
my $prerenderedIcon = 1;
# determines orientation of OS popups (text messages, volume controls)
my $landscapeOrientation = 0;
# these three are values defined in AppController.m
my $fpsRate = "60.0";
my $accelerometerRate = "60.0";
my $profilerOn = "0";
#go through the info.plist file line by line until you find this one:
my $findLine = "CFBundleDisplayName";
my $endOfPlist = "</dict>";
#copy Default.png and Icon.png from Asset to installPath
my $iconFilename = "Icon.png";
my $defaultFilename = "Default.png";
# The type of player built:
# "dashboard", "standaloneWin32", "standaloneOSXIntel", "standaloneOSXPPC", "standaloneOSXUniversal", "webplayer", "iPhone"
my $target = $ARGV[1];
print ("\n*** PostprocessBuildPlayer - Building at '$installPath' with target: $target ***\n");
my $dst = $installPath . "/" . $iconFilename;
print ("Copying Icon.png [$iconFilename -> $dst]\n");
copy($iconFilename, $dst) or die "Icon file can not be copied ";
my $dst = $installPath . "/" . $defaultFilename;
print ("Copying Default.png [$defaultFilename -> $dst]\n");
copy($defaultFilename, $dst) or die "Default file can not be copied ";
################################################################
# This modifies info.plist so you don't have to #
# set BundleDisplayName manually #
################################################################
#open this file
$oplistPath = $installPath."/Info.plist";
$nplistPath = $installPath."/Info.plist.tmp";
open OLDPLIST, "<", $oplistPath or die("Cannot open Info.plist");
open NEWPLIST, ">", $nplistPath or die("Cannot create new Info.plist");
my $nextLine = 0;
while(<OLDPLIST>)
{
if ($nextLine == 1)
{
$_ =~ s/\${PRODUCT_NAME}/$bundleDisplayName/; #swap the product name for display name
$nextLine = 0;
}
if ($_ =~ m/$findLine/)
{
$nextLine = 1;
}
################################################################
# Add any key/value pairs you want at the end of Info.plist #
################################################################
if ($_ =~ m/$endOfPlist/)
{
my $keys = "";
if ($prerenderedIcon)
{
$keys .= " <key>UIPrerenderedIcon</key>\n";
$keys .= " <true/>\n";
}
if ($landscapeOrientation)
{
$keys .= " <key>UIInterfaceOrientation</key>\n";
$keys .= " <string>UIInterfaceOrientationLandscapeRight</string>\n";
}
$_ = $keys . $_;
}
print NEWPLIST $_;
}
close OLDPLIST;
close NEWPLIST;
`mv \'$nplistPath\' \'$oplistPath\'`;
################################################################
# Change default Profiler & kFPS rates #
################################################################
$oacmPath = $installPath."/Classes/AppController.mm";
$nacmPath = $installPath."/Classes/AppController.mm.tmp";
open OLDACM, "<", $oacmPath or die("Cannot open AppController.mm");
open NEWACM, ">", $nacmPath or die("Cannot create new AppController.mm");
while(<OLDACM>)
{
if ($_ =~ m/ENABLE_INTERNAL_PROFILER/)
{
$_ =~ s/0/$profilerOn/;
}
if ($_ =~ m/kFPS/)
{
$_ =~ s/60.0/$fpsRate/;
}
if ($_ =~ m/kAccelerometerFrequency/)
{
$_ =~ s/60.0/$accelerometerRate/;
}
print NEWACM $_;
}
close OLDACM;
close NEWACM;
`mv \'$nacmPath\' \'$oacmPath\'`;