PostprocessBuildPlayer not working in 3.5, after upgrading from 3.4

My PostprocessBuildPlayer failed to work in 3.5 after upgrading from 3.4. It used to be working fine. I tried putting in obvious syntax errors and there is nothing in the editor log. I assume something should show up there if it goes wrong. It’s not adding in my custom include path, and appears to do the linking part wrong as well. Did anything change with the post build process.

Attached is the the script I’m testing with, in case anyone’s interested:

#!/usr/bin/python

# ============================================================================
#            Copyright (c) 2011 QUALCOMM Austria Research Center GmbH.
#            All Rights Reserved.
#            Qualcomm Confidential and Proprietary
# ============================================================================


# Purpose of this post build script is to post process the project.pbxproj file
# generated by Unity to add any additional Libraries, Frameworks or build paths
# needed to build a QCAR app then add calls to the QCAR library into the Unity
# generated C code


import sys
import os

# Constants
FRAMEWORK_NAME = 0
FRAMEWORK_ID = 1
FRAMEWORK_FILEREFID = 2

RESFILE_NAME = 0
RESFILE_ID = 1
RESFILE_FILEREFID = 2
RESFILE_LASTKNOWNTYPE = 3

# These ids have been generated by creating a project using Xcode then
# extracting the values from the generated project.pbxproj.  The format of this
# file is not documented by Apple so the correct algorithm for generating these
# ids is unknown

AVFOUNDATION_ID = 'CCE8C2AB135C7CDD000D8035'
AVFOUNDATION_FILEREFID = 'CCE8C2AA135C7CDD000D8035'

COREVIDEO_ID = 'CC375CE01316C2C5004F0FDD'
COREVIDEO_FILEREFID = 'CC375CDF1316C2C5004F0FDD'

COREMEDIA_ID = 'CC375CE51316C2D3004F0FDD'
COREMEDIA_FILEREFID = 'CC375CE41316C2D3004F0FDD'

SECURITY_ID = 'CCE8C2BA135C7EA3000D8035'
SECURITY_FILEREFID = 'CCE8C2B9135C7EA3000D8035'

CONFIGXML_ID = 'CC21B941135C674400DFE0FD'
CONFIGXML_FILEREFID = 'CC21B93F135C674400DFE0FD'

QCARRESOURCES_ID = 'CC21B942135C674400DFE0FD'
QCARRESOURCES_FILEREFID = 'CC21B940135C674400DFE0FD'




# List of all the frameworks to be added to the project
frameworks = [["AVFoundation.framework", AVFOUNDATION_ID, AVFOUNDATION_FILEREFID], \
              ["CoreMedia.framework", COREMEDIA_ID, COREMEDIA_FILEREFID], \
              ["CoreVideo.framework", COREVIDEO_ID, COREVIDEO_FILEREFID], \
              ["Security.framework", SECURITY_ID, SECURITY_FILEREFID]]

# List of data files to be added to the app bundle
#resfiles = [["config.xml", CONFIGXML_ID, CONFIGXML_FILEREFID, 'text.xml'], \
#             ["qcar-resources.dat", QCARRESOURCES_ID, QCARRESOURCES_FILEREFID, 'file']]
resfiles = []


# Adds a line into the PBXBuildFile section
def add_build_file(pbxproj, id, name, fileref):
    subsection = 'Resources'
    if name[-9:] == 'framework':
        subsection = 'Frameworks'
    print "Adding build file " + name + '


pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ in ’ + subsection + ’ / = {isa = PBXBuildFile; fileRef = ’ + fileref + ’ / ’ + name + ’ */; };
')

#Adds a line to the PBXFileReference to add a resource file
def add_res_file_reference(pbxproj, id, name, last_known_file_type):
    print "Adding data file reference " + name + "

"
pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = ’ + last_known_file_type + '; name = ’ + name + ‘; path = Data/Raw/QCAR/’ + name + '; sourceTree = ""; };
')

# Adds a line into the PBXFileReference section to add a framework
def add_framework_file_reference(pbxproj, id, name):
    print "Adding framework file reference " + name + '


pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ’ + name + ‘; path = System/Library/Frameworks/’ + name + '; sourceTree = SDKROOT; };
')

# Adds a line into the PBXFrameworksBuildPhase section
def add_frameworks_build_phase(pbxproj, id, name):
    print "Adding build phase " + name + '


pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ in Frameworks */,
')

# Adds a line into the PBXResourcesBuildPhase section
def add_resources_build_phase(pbxproj, id, name):
    print "Adding build phase " + name + '


pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ in Resources */,
')

# Adds a line into the PBXGroup section
def add_group(pbxproj, id, name):
    print "Add group " + name + '


pbxproj.write(’ ’ + id + ’ /* ’ + name + ’ */,
')

# Processes the given xcode project to add or change the supplied parameters
#   xcodeproj_filename - filename of the Xcode project to change
#   frameworks - list of Apple standard frameworks to add to the project
#   resfiles - list resource files added to the project
def process_pbxproj(xcodeproj_filename, frameworks, resfiles):

    # Open up the file generated by Unity and read into memory as
    # a list of lines for processing
    pbxproj_filename = xcodeproj_filename + '/project.pbxproj'
    pbxproj = open(pbxproj_filename, 'r')
    lines = pbxproj.readlines()
    pbxproj.close()

    # Check if file has already been processed and only proceed if it hasn't,
    # we'll do this by looping through the build files and see if avfoundation.framework
    # is there
    i = 0
    found = False
    while (not found) and (lines*[3:6] != 'End'):*

found = lines*.find(‘AVFoundation.framework’) > 0*
i = i+1

if found:
print “Found QCAR has already been added to XCode project”
else:
# Work out which of the resfiles exist and remove them if they don’t, this
# is because if using frame markers there may not be a qcar-resources.dat
resfiles = [x for x in resfiles if os.path.exists(xcodeproj_filename + ‘/…/Data/Raw/QCAR/’ + x[RESFILE_NAME])]

# Next open up an empty project.pbxproj for writing and iterate over the old
# file copying the original file and inserting anything extra we need
pbxproj = open(pbxproj_filename, ‘w’)

# As we iterate through the list we’ll record which section of the
# project.pbxproj we are currently in
section = ‘’

# We use these booleans to decide whether we have already added the list of
# build files to the link line. This is needed because there could be multiple
# build targets and they are not named in the project.pbxproj
frameworks_build_added = False
res_build_added = False

i = 0
for i in range(0, len(lines)):
line = lines
if line.startswith(" GCC_ENABLE_CPP_EXCEPTIONS") or line.startswith(" GCC_ENABLE_CPP_RTTI") or line.startswith(" GCC_ENABLE_OBJC_EXCEPTIONS"):
continue
pbxproj.write(line)

# Each section starts with a comment such as
# /* Begin PBXBuildFile section */'
if line[3:8] == ‘Begin’:
section = line.split(’ ')[2]
if section == ‘PBXBuildFile’:
for framework in frameworks:
add_build_file(pbxproj, framework[FRAMEWORK_ID], framework[FRAMEWORK_NAME], framework[FRAMEWORK_FILEREFID])
for resfile in resfiles:
add_build_file(pbxproj, resfile[RESFILE_ID], resfile[RESFILE_NAME], resfile[RESFILE_FILEREFID])

if section == ‘PBXFileReference’:
for framework in frameworks:
add_framework_file_reference(pbxproj, framework[FRAMEWORK_FILEREFID], framework[FRAMEWORK_NAME])
for resfile in resfiles:
add_res_file_reference(pbxproj, resfile[RESFILE_FILEREFID], resfile[RESFILE_NAME], resfile[RESFILE_LASTKNOWNTYPE])

if line[3:6] == ‘End’:
section = ‘’

if section == ‘PBXFrameworksBuildPhase’:
if line.strip()[0:5] == ‘files’:
if not frameworks_build_added:
for framework in frameworks:
add_frameworks_build_phase(pbxproj, framework[FRAMEWORK_ID], framework[FRAMEWORK_NAME])
frameworks_build_added = True

# The PBXResourcesBuildPhase section is what appears in XCode as 'Link
# Binary With Libraries’. As with the frameworks we make the assumption the
# first target is always ‘Unity-iPhone’ as the name of the target itself is
# not listed in project.pbxproj
if section == ‘PBXResourcesBuildPhase’:
if line.strip()[0:5] == ‘files’:
if not res_build_added:
for resfile in resfiles:
add_resources_build_phase(pbxproj,resfile[RESFILE_ID], resfile[RESFILE_NAME])
res_build_added = True

# The PBXGroup is the section that appears in XCode as ‘Copy Bundle Resources’.
if section == ‘PBXGroup’:
if (line.strip()[0:8] == ‘children’) and (lines[i-2].strip().split(’ ')[2] == ‘CustomTemplate’):
for resfile in resfiles:
add_group(pbxproj, resfile[RESFILE_FILEREFID], resfile[RESFILE_NAME])
for framework in frameworks:
add_group(pbxproj, framework[FRAMEWORK_FILEREFID], framework[FRAMEWORK_NAME])

if section == ‘XCBuildConfiguration’:
if line.strip().startswith(’ buildSettings’):
stlRoot = “/Users/zeyangl/ShortTailLab”
pbxproj.write(’ HEADER_SEARCH_PATHS = (
')

pbxproj.write(’ "$(SRCROOT)/Libraries",
')

pbxproj.write(’ “’ + stlRoot + '/Core”,
')

pbxproj.write(’ “’ + stlRoot + '/3rdparty/include”,
')

pbxproj.write(’ );
')

pbxproj.close()

# Processes a Unity generated AppController.mm to add calls to QCARUnityPlayer
# appcontroller_filename - full path to AppController.mm to be modified
def process_appcontroller(appcontroller_filename):
found_CreateSurface = False

appcontroller = open(appcontroller_filename, ‘r’)
lines = appcontroller.readlines()
appcontroller.close()

# Check to see if file looks like it has alread been processed and
# only process if it has not
if lines[0] != '#include "QCARUnityPlayer.h"
':

appcontroller = open(appcontroller_filename, ‘w’)

skip = False

appcontroller.write('#include “QCARUnityPlayer.h”
');

for i in range(0, len(lines)):
line = lines
# Look for CreateSurface and add calls to the end of the function
if line[0:19] == ‘bool CreateSurface(’:
found_CreateSurface = True
if found_CreateSurface and (line.strip() == ‘return true;’):
appcontroller.write(’ QCARUnityPlayer::getInstance().QCARLoadTracker();
')

appcontroller.write(’ QCARUnityPlayer::getInstance().QCARNotifyCreated((int)surface->w, (int)surface->h);
')

found_CreateSurface = False

# Add QCAR lifecycle calls next to the Unity equivalents
if line.strip()[0:18] == ‘UnityPause(false);’:
appcontroller.write(’ QCARUnityPlayer::getInstance().QCARPause(false);
')

if line.strip()[0:17] == ‘UnityPause(true);’:
appcontroller.write(’ QCARUnityPlayer::getInstance().QCARPause(true);
')

appcontroller.write(’ UnityPause(true);
')

appcontroller.write(’ PresentSurface(&_surface);
')

skip = True

if line.strip()[0:30] == ‘[self startUnity:application];’:
_appcontroller.write(’ NSString* orientation = [[[NSBundle mainBundle] infoDictionary] objectForKey:@“UIInterfaceOrientation”];

');
appcontroller.write(’ QCARUnityPlayer::getInstance().QCARInit([orientation UTF8String]);
');
_

if line.strip()[0:15] == ‘UnityCleanup();’:
appcontroller.write(’ QCARUnityPlayer::getInstance().destroy();
');

# Disable display link since this seriously reduces performance and
# enable the event pump based loop since this gives best performance
if line == '#define USE_DISPLAY_LINK_IF_AVAILABLE 1
':

appcontroller.write('#define USE_DISPLAY_LINK_IF_AVAILABLE 0
');

skip = True

if line == '//#define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP
':

appcontroller.write('#define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP
');

skip = True

if line == '#define FALLBACK_LOOP_TYPE EVENT_PUMP_BASED_LOOP
':

appcontroller.write('//#define FALLBACK_LOOP_TYPE EVENT_PUMP_BASED_LOOP
');

skip = True

# write out original line of code if it has not been replaced
if not skip:
appcontroller.write(line)
skip = False

appcontroller.close()

# Script start
print “Starting PostProcessBuildPlayer with the following arguments…”

i = 0
for args in sys.argv:
print str(i) +': ’ + args
i += 1

# Check this is an iOS build before running
if sys.argv[2] == “iPhone”:

xcodeproj_full_path_name = sys.argv[1] + ‘/Unity-iPhone.xcodeproj’
process_pbxproj(xcodeproj_full_path_name, frameworks, resfiles)

# appcontroller_full_path_name = sys.argv[1] + ‘/Classes/AppController.mm’
# process_appcontroller(appcontroller_full_path_name)

what is the exact name of the PostprocessBuildPlayer file you