#!/usr/bin/perl use File::Copy; print ("\n*** Starting PostprocessBuildPlayer ***\n"); my $installPath = $ARGV[0]; #values to watch for already existing my $requiredDeviceCapsString = "UIRequiredDeviceCapabilities"; my $backgroundModesString = "UIBackgroundModes"; my $bluetoothLEString = "bluetooth-le"; #go through the info.plist file line by line until you find this one: my $endOfPlist = ""; # 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"); ################################################################ # This modifies info.plist to add the external accessory # # entries # ################################################################ #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; my $requiredDeviceCapsFound = 0; my $backgroundModesFound = 0; while() { if ($nextLine == 1) { if ($_ =~ m/$bluetoothLEString/) { } else { $_ =~ s||\n\tbluetooth-le| } $nextLine = 0; } ################################################################ # Check for required device caps string already exists # ################################################################ if ($_ =~ m/$requiredDeviceCapsString/ ) { $nextLine = 1; } ################################################################ # Check for background modes string already exists # ################################################################ if ($_ =~ m/$backgroundModesString/ ) { $backgroundModesFound = 1; } ################################################################ # Add any key/value pairs you want at the end of Info.plist # ################################################################ if ($_ =~ m/$endOfPlist/ && $backgrounModesFound == 0) { my $keys = ""; $keys .= " UIBackgroundModes\n"; $keys .= " \n"; $keys .= " bluetooth-central\n"; $keys .= " bluetooth-peripheral\n"; $keys .= " \n"; $_ = $keys . $_; } print NEWPLIST $_; } close OLDPLIST; close NEWPLIST; `mv \'$nplistPath\' \'$oplistPath\'`;