• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hohohmm · Feb 23, 2012 at 11:17 PM · 3.5

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 + '\n'
     pbxproj.write('\t\t' + id + ' /* ' + name  + ' in ' + subsection + ' */ = {isa = PBXBuildFile; fileRef = ' + fileref +  ' /* ' + name + ' */; };\n')
 
 #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 + "\n"
     pbxproj.write('\t\t' + id + ' /* ' + name + ' */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = ' + last_known_file_type + '; name = ' + name + '; path = Data/Raw/QCAR/' + name + '; sourceTree = \"<group>\"; };\n')
 
 # 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 + '\n'
     pbxproj.write('\t\t' + id + ' /* ' + name + ' */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ' + name + '; path = System/Library/Frameworks/' + name + '; sourceTree = SDKROOT; };\n')
 
 # Adds a line into the PBXFrameworksBuildPhase section
 def add_frameworks_build_phase(pbxproj, id, name):
     print "Adding build phase " + name + '\n'
     pbxproj.write('\t\t\t\t' + id + ' /* ' + name + ' in Frameworks */,\n')
 
 # Adds a line into the PBXResourcesBuildPhase section
 def add_resources_build_phase(pbxproj, id, name):
     print "Adding build phase " + name + '\n'
     pbxproj.write('\t\t\t\t' + id + ' /* ' + name + ' in Resources */,\n')
 
 # Adds a line into the PBXGroup section
 def add_group(pbxproj, id, name):
     print "Add group " + name + '\n'
     pbxproj.write('\t\t\t\t' + id + ' /* ' + name + ' */,\n')
 
 
 # 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[i][3:6] != 'End'):
         found = lines[i].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[i]
             if line.startswith("\t\t\t\tGCC_ENABLE_CPP_EXCEPTIONS") or line.startswith("\t\t\t\tGCC_ENABLE_CPP_RTTI") or line.startswith("\t\t\t\tGCC_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('\t\t\tbuildSettings'):
                     stlRoot = "/Users/zeyangl/ShortTailLab"
                     pbxproj.write('\t\t\t\tHEADER_SEARCH_PATHS = (\n')
                     pbxproj.write('\t\t\t\t\t\"$(SRCROOT)/Libraries\",\n')
                     pbxproj.write('\t\t\t\t\t"' + stlRoot + '/Core",\n')
                     pbxproj.write('\t\t\t\t\t"' + stlRoot + '/3rdparty/include",\n')
                     pbxproj.write('\t\t\t\t);\n')
 
         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\"\n':
  
         appcontroller = open(appcontroller_filename, 'w')
 
         skip = False
 
         appcontroller.write('#include "QCARUnityPlayer.h"\n');
         for i in range(0, len(lines)):
             line = lines[i]
             # 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('\tQCARUnityPlayer::getInstance().QCARLoadTracker();\n')
                 appcontroller.write('\tQCARUnityPlayer::getInstance().QCARNotifyCreated((int)surface->w, (int)surface->h);\n')
                 found_CreateSurface = False
 
             # Add QCAR lifecycle calls next to the Unity equivalents 
             if line.strip()[0:18] == 'UnityPause(false);':
                 appcontroller.write('\t\tQCARUnityPlayer::getInstance().QCARPause(false);\n')
 
             if line.strip()[0:17] == 'UnityPause(true);':
                 appcontroller.write('\tQCARUnityPlayer::getInstance().QCARPause(true);\n')
                 appcontroller.write('\tUnityPause(true);\n')
                 appcontroller.write('\tPresentSurface(&_surface);\n')
                 skip = True
 
             if line.strip()[0:30] == '[self startUnity:application];':
                 appcontroller.write('\tNSString* orientation = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UIInterfaceOrientation"];\n\n');
                 appcontroller.write('\tQCARUnityPlayer::getInstance().QCARInit([orientation UTF8String]);\n');
 
             if line.strip()[0:15] == 'UnityCleanup();':
                 appcontroller.write('\tQCARUnityPlayer::getInstance().destroy();\n');
 
             # 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\n':
                 appcontroller.write('#define USE_DISPLAY_LINK_IF_AVAILABLE 0\n');
                 skip = True
 
             if line == '//#define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP\n':
                 appcontroller.write('#define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP\n');
                 skip = True
 
             if line == '#define FALLBACK_LOOP_TYPE EVENT_PUMP_BASED_LOOP\n':
                 appcontroller.write('//#define FALLBACK_LOOP_TYPE EVENT_PUMP_BASED_LOOP\n');
                 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)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ikriz · Mar 20, 2012 at 10:44 AM 0
Share

are you using Windows or $$anonymous$$ac? It's never worked on windows to my knowledge, it's possible that bug report caused some action which has now also broken $$anonymous$$ac?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mono_Sapiens · Apr 23, 2012 at 05:20 PM

what is the exact name of the PostprocessBuildPlayer file you

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

PostprocessBuildPlayer script not functioning.. Will there be a fix? 2 Answers

Asset Server vs. Subversion + meta files 1 Answer

NavMeshAgents not avoiding one another (obstacleAvoidanceType bug?) 0 Answers

.NET code in Flash export (3.5 beta) 1 Answer

3.5 Flash Export - Compiles fine, but no resources 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges