Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

PostExport error: "parameters do not match signature"

Discussion in 'Unity Build Automation' started by Mycroft, Jan 25, 2016.

  1. Mycroft

    Mycroft

    Joined:
    Aug 29, 2012
    Posts:
    160
    I'm running into an issue when attempting to use the PostExport static function of CloudBuild. The logs show an error on my PostExport static function "parameters do not match signature". I've looked at a number of examples and they use
    Code (CSharp):
    1.  [PostProcessBuild]
    2.     public static void PostExport(BuildTarget buildTarget, string path)
    even though the CloudBuild advanced features documents state that it
    and doesn't mention [PostProcessBuild] or [PostProcessBuildAtrribute]

    I'm clearly not understanding what I'm missing from the equation. Any suggestions?





    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. #if UNITY_IOS
    5. using UnityEditor.iOS.Xcode;
    6. using System.IO;
    7. #endif
    8. using UnityEditor.Callbacks;
    9.  
    10.  
    11. public class CloudBuildExport : MonoBehaviour {
    12. #if UNITY_CLOUD_BUILD
    13.     public static void PreExport( UnityEngine.CloudBuild.BuildManifestObject manifest)
    14.     {
    15.         string CommitID = manifest.GetValue<string>("scmCommitId");
    16.         string BuildNumber = manifest.GetValue<string>("buildNumber");
    17.         PlayerSettings.bundleVersion = string.Format("{0}.{1}_{2}", PlayerSettings.bundleVersion, BuildNumber, CommitID);
    18.  
    19.         Debug.Log( string.Format( "New version number <{0}>", PlayerSettings.bundleVersion ) );
    20.  
    21.         CheckCurrentBundleVersion.BundleVersionChecker();
    22.     }
    23. #endif
    24.  
    25.     [PostProcessBuild]
    26.     public static void PostExport(BuildTarget buildTarget, string path)
    27.     {
    28. #if UNITY_IOS
    29.         ModifyBuildProperties(path);
    30.         ModifyXCodePlist(path);
    31. #endif
    32.  
    33.     }
    34.  
    35. #if UNITY_IOS
    36.  
    37.     private static void ModifyBuildProperties(string path )
    38.     {
    39.         string projPath = PBXProject.GetPBXProjectPath(path);
    40.         PBXProject proj = new PBXProject();
    41.         proj.ReadFromString(File.ReadAllText(projPath));
    42.  
    43.         //string target = proj.TargetGuidByName("Unity-iPhone");
    44.         string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
    45.         proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");
    46.  
    47.         string RemoveFileGuid;
    48.         RemoveFileGuid = proj.FindFileGuidByProjectPath("LaunchScreen-iPhoneLandscape.png");
    49.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    50.         RemoveFileGuid = proj.FindFileGuidByProjectPath("LaunchScreen-iPhonePortrait.png");
    51.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    52.         RemoveFileGuid = proj.FindFileGuidByProjectPath("LaunchScreen-iPad.png");
    53.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    54.  
    55.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default-Portrait@3x.png");
    56.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    57.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default-667h@2x.png");
    58.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    59.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default@2x.png");
    60.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    61.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default-Portrait.png");
    62.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    63.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png");
    64.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    65.         RemoveFileGuid = proj.FindFileGuidByProjectPath("Unity-iPhone/Images.xcassets/LaunchImage.launchimage/Default.png");
    66.         proj.RemoveFileFromBuild(target, RemoveFileGuid);
    67.  
    68.  
    69.         File.WriteAllText(projPath, proj.WriteToString());
    70.     }
    71.  
    72.  
    73.     private static void ModifyXCodePlist( string pathToBuiltProject)
    74.     {
    75.         // Get plist
    76.         string plistPath = pathToBuiltProject + "/Info.plist";
    77.         PlistDocument plist = new PlistDocument();
    78.         plist.ReadFromString(File.ReadAllText(plistPath));
    79.  
    80.         // Get root
    81.         PlistElementDict rootDict = plist.root;
    82.  
    83.         PlistElementDict NSAppTransportSecurityDict = rootDict.CreateDict("NSAppTransportSecurity");
    84.         NSAppTransportSecurityDict.SetBoolean("NSAllowArbitraryLoads", true);
    85.  
    86.         File.WriteAllText(plistPath, plist.WriteToString());
    87.     }
    88.  
    89. #endif
    90.  
    91. }
    92.  
    93.  
    94.  
    95.  
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    The "Pre and Post" tab of the advanced settings guide mentions the PostProcessBuildAtrribute in the note at the bottom. If you add a method with the PostProcessBuildAtrribute attribute attached to it, that method will automatically be invoked by Unity during the build process without needing to configure the post-export on the Cloud Build advanced settings. If you configure a post-export method in the Cloud Build advanced settings however, it will be invoked AFTER any PostProcessBuildAtrribute methods and has a different signature than the PostProcessBuildAtrribute methods.

    The signature for a PostProcessBuildAtrribute looks like:
    Code (CSharp):
    1. [PostProcessBuildAttribute]
    2. public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject);
    The signature for the Cloud Build specific post-export method looks like:
    Code (CSharp):
    1. public static void CloudBuildPostExport(string pathToBuiltProject);
     
  3. Mycroft

    Mycroft

    Joined:
    Aug 29, 2012
    Posts:
    160
    That's exactly what I thought, but I got the same error when using

    Code (CSharp):
    1. public static void CloudBuildPostExport(string pathToBuiltProject);
    without any [PostProcess] settings,which is why I was so confused.

    I'll try it that way again.
     
  4. Mycroft

    Mycroft

    Joined:
    Aug 29, 2012
    Posts:
    160
    I adjusted my script


    Code (CSharp):
    1.   public static void PostExport( string path)
    2.     {
    and my build still says
     
    bart_bender likes this.
  5. bart_bender

    bart_bender

    Joined:
    Mar 21, 2015
    Posts:
    20
    I'm having the same problem.

    12785: [Unity] UnityEngine.Debug:Log(Object)
    12786: [Unity] UnityEditor.CloudBuild.BuildLogger:Log(String, Object[])
    12787: [Unity] UnityEditor.CloudBuild.UnityReflector:CallStaticEditorMethod(String, Boolean, Object[])
    12788: [Unity] UnityEditor.CloudBuild.Builder:Build()
    12789: [Unity] ERROR: postExportMethod 'PostprocessBuildPlayer.OnPostprocessBuild' failed, aborting.

    My code

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5. using System.Collections;
    6. using System.IO;
    7. using UnityEditor.iOS.Xcode;
    8.  
    9. public class PostprocessBuildPlayer : MonoBehaviour
    10. {
    11.  
    12.   //[PostProcessBuild]
    13.   //[PostProcessBuild]
    14.   //public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    15.   //{
    16.   //  Debug.Log(pathToBuiltProject);  
    17.   //  addFrameworks(target, pathToBuiltProject);
    18.   //}
    19.  
    20.   public static void OnPostOnPostprocessBuild(string pathToBuiltProject)
    21.   {
    22. #if UNITY_IOS
    23.   addFrameworks(BuildTarget.iOS, pathToBuiltProject);
    24. #endif
    25.   }
    26.  
    27.   public static void addFrameworks(BuildTarget buildTarget, string path)
    28.   {
    29. #if UNITY_IOS
    30.   if (buildTarget == BuildTarget.iOS)
    31.   {
    32.  
    33.   Debug.Log("OnPostprocessBuildiOS");
    34.   string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
    35.  
    36.   PBXProject proj = new PBXProject();
    37.   proj.ReadFromString(File.ReadAllText(projPath));
    38.  
    39.   string target = proj.TargetGuidByName("Unity-iPhone");
    40.  
    41.   // Set a custom link flag
    42.   proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-all_load");
    43.   proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
    44.  
    45.   // add frameworks  
    46.   proj.AddFrameworkToProject(target, "AdSupport.framework", true);
    47.   proj.AddFrameworkToProject(target, "StoreKit.framework", true);
    48.   proj.AddFrameworkToProject(target, "AVFoundation.framework", true);
    49.   File.WriteAllText(projPath, proj.WriteToString());
    50.  
    51.   }
    52. #endif
    53.   }
    54.  
    55.  
    56.  
    57. }
    58.  
    59.  
     
    Last edited: Feb 12, 2016
  6. Mycroft

    Mycroft

    Joined:
    Aug 29, 2012
    Posts:
    160
    postExportMethod 'PostprocessBuildPlayer.OnPostprocessBuild'


    public static void OnPostOnPostprocessBuild

    Your names don't match up.
     
    bart_bender likes this.
  7. bart_bender

    bart_bender

    Joined:
    Mar 21, 2015
    Posts:
    20
    Thanks for your help Mycroft.
    I'm modifying my code and the postexport call.

    i'll write the results of the build process when it finally

    thanks again.

    PD: sorry for my english
     
  8. bart_bender

    bart_bender

    Joined:
    Mar 21, 2015
    Posts:
    20
    The previos error is fixed. But the project not compile.

    13501: [xcode] /BUILD_PATH/jfrgames.robotcycle.default-ios/temp.P5QZDS/Libraries/libiPhone-lib.a(OnDemandResources.o)
    13502: [xcode] ld: 4 duplicate symbols for architecture armv7
    13503: [xcode] clang: error: linker command failed with exit code 1 (use -v to see invocation)
    13504: [xcode] ** BUILD FAILED **
    13505: [xcode] The following build commands failed:
    13506: [xcode] (1 failure)
    13507: ! build of 'default-ios' failed. compile failed
    13508: /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/lib/bvr/project.rb:383:in `publish_build': Could not find .release.yaml in archive path. (RuntimeError)
    13509: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/lib/bvr/thor/tasks/project.rb:256:in `do_publish'
    13510: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/lib/bvr/thor/tasks/project.rb:139:in `rescue in build'
    13511: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/lib/bvr/thor/tasks/project.rb:103:in `build'
    13512: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    13513: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    13514: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    13515: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    13516: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/runner.rb:36:in `method_missing'
    13517: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/lib/bvr/thor/runner.rb:20:in `method_missing'
    13518: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
    13519: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
    13520: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    13521: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    13522: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    13523: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/gems/bvr-1.1.6/bin/bvr:6:in `<top (required)>'
    13524: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/bin/bvr:23:in `load'
    13525: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/bin/bvr:23:in `<main>'
    13526: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
    13527: from /BUILD_PATH/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
    13528: uninstalling iOS credentials for jfrgames/robotcycle - default-ios
    13529: MAC verified OK
    13530: Removing certificate...
    13531: done.
    13532: Build step 'Execute shell' marked build as failure
    13533: postbuildstatus finished successfully.
    13534: Deleting project workspace...
    13535: Finished: FAILURE
     
  9. yeball

    yeball

    Joined:
    Sep 5, 2016
    Posts:
    6
    @Mycroft Hi, Did you resolve problem with PostExport method ?
    I have same problem as u mentioned.


    Thx
     
  10. bart_bender

    bart_bender

    Joined:
    Mar 21, 2015
    Posts:
    20
    Hi, yes i've resolved the problem, the TortoiseSVN was filtering one library *.a, i added the library and works finally
     
  11. SagoRich

    SagoRich

    Joined:
    Jul 21, 2014
    Posts:
    15
    For future reference (since this has happened to us a few times and we always seem to forget), if something else during your post process throws an exception, then it will be caught at this point and reported as this exception. If you look in the CloudBuild Full Log, somewhere just above this exception should be the real one.