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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

xCode failing to build in batch mode with Google Analytics

Discussion in 'Editor & General Support' started by InnocentDemonz, Feb 16, 2018.

  1. InnocentDemonz

    InnocentDemonz

    Joined:
    Jun 24, 2015
    Posts:
    2
    Hi,
    I'm currently having issues with Google analytics, I am able to build the project on a MacBook and port it to the iPad through the editor. However, when trying to build the project via xcode-build

    We use SVN for version control and TeamCity to build the projects. TeamCity will check SVN to see if there are any updates if there are then it will get the project, find which platform it needs to build for and in this case, it will get the project and runs xcode-build.

    I have a post-processing script that Adds the correct frameworks into xCode but it fails saying it's missing a Libary from what I gather its "$(SRCROOT)/Libraries/Plugins/iOS" because this gets added to the Library Search Paths when I build through the editor but doesn't when building through batch mode. However, when I add "$(SRCROOT)/Libraries/Plugins/iOS" into the Libary Search Paths is still fails with the same error message.

    Unity Build.log
    Error Message in Xcodebuild.log:
    I have another script in the Editor folder that is called when we are building via batch mode. I will share both post-processing and the command line script below.

    Code (CSharp):
    1. public class CommandLineiOSBuild
    2. {
    3.     static private string[] collectBuildScenes()
    4.     {
    5.         var scenes = new List<string>();
    6.  
    7.         foreach (var scene in EditorBuildSettings.scenes)
    8.         {
    9.             if (scene == null)
    10.                 continue;
    11.             if (scene.enabled)
    12.                 scenes.Add(scene.path);
    13.         }
    14.         return scenes.ToArray();
    15.     }
    16.  
    17.     [MenuItem(@"Build/BuildIOS")]
    18.     static public void build()
    19.     {
    20.         var scenes = collectBuildScenes();
    21.         BuildPipeline.BuildPlayer(scenes, "ios", BuildTarget.iOS, BuildOptions.None);
    22.     }
    23. }
    Code (CSharp):
    1. public class BuildPostProcessor
    2. {
    3.     [PostProcessBuildAttribute(1)]
    4.     public static void OnPostProcessBuild(BuildTarget target, string path)
    5.     {
    6.         if (target == BuildTarget.iOS)
    7.         {
    8.             // Read.
    9.             string projectPath = PBXProject.GetPBXProjectPath(path);
    10.             PBXProject project = new PBXProject();
    11.             project.ReadFromString(File.ReadAllText(projectPath));
    12.             string targetName;
    13.             //targetName = project.GetUnityTargetName();
    14.             targetName = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
    15.             string targetGUID = project.TargetGuidByName(targetName);
    16.  
    17.             AddFrameworks(project, targetGUID);
    18.  
    19.             // Write.
    20.             File.WriteAllText(projectPath, project.WriteToString());
    21.         }
    22.     }
    23.  
    24.     static void AddFrameworks(PBXProject project, string targetGUID)
    25.     {
    26.         // Frameworks (eppz! Photos, Google Analytics).
    27.         project.AddFrameworkToProject(targetGUID, "AdSupport.framework", false);
    28.         project.AddFrameworkToProject(targetGUID, "CoreData.framework", false);
    29.         project.AddFrameworkToProject(targetGUID, "SystemConfiguration.framework", false);
    30.         project.AddFrameworkToProject(targetGUID, "libz.dylib", false);
    31.         project.AddFrameworkToProject(targetGUID, "libsqlite3.tbd", false);
    32.         project.AddFrameworkToProject(targetGUID, "libGoogleAnalyticsServices.a", false);
    33.  
    34.         // Add `-ObjC` to "Other Linker Flags".
    35.         project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC");
    36.     }
    37. }
    I need the libraries and frameworks to be added in automatically.

    I'm very new to iOS development so if this is a simple fix I apologize in advance.
    Any help would be appreciated.

    - Daniel
     
    brefoyo likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is the behavior if you build directly from the Editor without source control or a build system, then open the project directly locally in XCode?
     
  3. InnocentDemonz

    InnocentDemonz

    Joined:
    Jun 24, 2015
    Posts:
    2
    Everything is fine when I build in the editor, no errors.
    Unity builds the xcode project without any issues, xcode opens the project with all the libraries and frameworks and ports it to the iPad all the Google analytics working too.