Skip to content

Instantly share code, notes, and snippets.

@tayl0r
Last active August 29, 2015 14:00
Show Gist options
  • Save tayl0r/11258178 to your computer and use it in GitHub Desktop.
Save tayl0r/11258178 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# Searches for other PostprocessBuildPlayer scripts and executes them. Make sure the other script
# have a name suffix with an underscore "_" like "PostprocessBuildPlayer_AnotherBuild" or whatever.
#
# Based on script by Rob Terrell, [email protected]
#
use File::Glob ':glob';
# Dont run on any builds that are not iPhone builds
if( $ARGV[1] ne "iPhone" )
{
exit;
}
# Grab all the PostprocessBuildPlayer files
@files = bsd_glob( "Assets/Editor/postprocessbuildplayer_*", GLOB_NOCASE );
foreach $file( @files )
{
if( !( $file =~ m/\./ ) )
{
system( "chmod", "755", $file );
print "PostProcessBuildPlayer: calling " . $file . "\n";
system( $file, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6] );
}
}
# now we run the runner.py directly
$installPath = $ARGV[0];
$currDir = `pwd`;
chomp $currDir;
#!/usr/bin/perl
use File::Copy;
my $installPath = $ARGV[0];
#go through the info.plist file line by line until you find this one:
my $findLine = "CFBundleVersion";
my $endOfPlist = "</dict>";
################################################################
# 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 $newLine = 0;
while(<OLDPLIST>)
{
if($newLine == 1)
{
$newLine = $_;
}
if ($_ =~ m/$findLine/)
{
$newLine = 1;
}
################################################################
# Add any key/value pairs you want at the end of Info.plist #
################################################################
if ($_ =~ m/$endOfPlist/)
{
my $keys = "";
$keys .= " <key>CFBundleShortVersionString</key>\n";
$keys .= $newLine;
$_ = $keys . $_;
}
print NEWPLIST $_;
}
close OLDPLIST;
close NEWPLIST;
`mv \'$nplistPath\' \'$oplistPath\'`;
#!/usr/bin/env python
import sys, os.path
import xml.etree.ElementTree as etree
import shutil
install_path = sys.argv[1]
target_platform = sys.argv[2]
if target_platform != "iPhone": sys.exit()
tree = etree.parse('Assets/Pushwoosh/Info.xml')
root = tree.getroot()
appCode = root.find("AppCode").text
path = os.path.join(install_path, 'Info.plist')
file = open(path, 'r')
fileData = file.read()
file.close()
replaceText = '<dict>\n\t<key>Pushwoosh_APPID</key>\n\t<string>' + appCode + '</string>\n'
fileData = fileData.replace('<dict>', replaceText, 1)
file = open(path, "w")
file.write(fileData)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment