Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Problem building iOS app with cloud build using google analytics

Discussion in 'Unity Cloud Build' started by Bruder, Mar 10, 2016.

  1. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    53
    Hi All,

    Im trying to build my code with unity cloud build for iOS and im using google analytics V4 (the newest) .
    My unity version is 5.3.2.

    Looking at the log, i get these errors:

    4728: [xcode] "_sqlite3_errmsg", referenced from:
    4729: [xcode] -[GAISqlStore errorMessage] in libGoogleAnalyticsServices.a(GAISqlStore.o)

    4799: [xcode] "_NSSQLiteErrorDomain", referenced from:
    4800: [xcode] -[GAIDataStore performBlockAndWait:withError:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
    4801: [xcode] "_sqlite3_reset", referenced from:
    4802: [xcode] -[GAIAnalyticsPropertiesStore upsertPropertyRecord:] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4803: [xcode] -[GAIAnalyticsPropertiesStore clearPropertiesTable] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4804: [xcode] -[GAIAnalyticsPropertiesStore propertyRecordForTrackingId:] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4805: [xcode] -[GAIAnalyticsPropertiesStore selectStmtWithTrackingId:] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4806: [xcode] -[GAISqlStore rowCountForTableWithName:] in libGoogleAnalyticsServices.a(GAISqlStore.o)
    4807: [xcode] -[GAISqlStore tableExists:] in libGoogleAnalyticsServices.a(GAISqlStore.o)
    4808: [xcode] -[GAISqlStore dropTableWithName:] in libGoogleAnalyticsServices.a(GAISqlStore.o)
    4809: [xcode] ...
    4810: [xcode] "_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
    4811: [xcode] objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
    4812: [xcode] "_sqlite3_column_int64", referenced from:
    4813: [xcode] -[GAIAnalyticsPropertiesStore propertyRecordForTrackingId:] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4814: [xcode] "_sqlite3_bind_int64", referenced from:
    4815: [xcode] -[GAIAnalyticsPropertiesStore bindRecord:toUpsertStatement:] in libGoogleAnalyticsServices.a(GAIAnalyticsPropertiesStore.o)
    4816: [xcode] ld: symbol(s) not found for architecture armv7
    4817: [xcode] clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Any help will be appreciated!
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    766
    Those errors mean the xcode project is missing some frameworks / libs. Looking at the GA plugin their PostprocessBuildPlayer scripts look pretty unreliable. My suggestion would be to use the Xcode Manipulation API (which is part of Unity since 5.x) to add the libraries and frameworks mentioned in their iOS setup docs rather than rely on their scripts.
     
  3. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    53
    Hi Danny,

    Thanks for your answer.

    I'm really not an iOS person, can you explain of maybe have a step-by-step reference of what i need to do in order to make this work with the cloud build?
     
  4. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
  5. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    53
    Hi Chris,

    Yes, this is the version i'm using, i'm using the "with bitcode support" package.

    Thanks for your help, i'll be glad to get a script that handles it (And instructions how to use it :) )
     
  6. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
    Hey there,

    The following script will automatically add the frameworks required by Google Analytics as described in the iOS section of the developer guide. It has been configured to behave the same way during local builds, as well as those Unity Cloud Build is generating. For anyone reading this in the future, keep in mind that these instructions reference the latest version of the plugin (v4) and modifications to the script could be necessary in the future. I am using the XCode Manipulation API that Danny linked to above, which is now integrated into the Editor. You can review a class reference here.

    1) Add Assets/Editor/PostBuildProcessor.cs to your project. It contains two methods of executing itself post-export:
    * During a local build, by using the PostProcessBuild attribute
    * During a Cloud Build by setting Post-Export method for your iOS target (see #2)
    Note: For the non-bitcode version of the plugin, lines [84-85] should be uncommented so that ENABLE_BITCODE flag is set to NO.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. #if UNITY_IOS
    7. using UnityEditor.iOS.Xcode;
    8. #endif
    9. using System.IO;
    10. using System.Linq;
    11.  
    12. public class PostBuildProcessor : MonoBehaviour
    13. {
    14.     /**
    15.      * Runs when Post-Export method has been set to
    16.      * 'PostBuildProcessor.OnPostprocessBuildiOS' in your Unity Cloud Build
    17.      * target settings.
    18.      */
    19.     #if UNITY_CLOUD_BUILD
    20.     // This method is added in the Advanced Features Settings on UCB
    21.     // PostBuildProcessor.OnPostprocessBuildiOS
    22.     public static void OnPostprocessBuildiOS (string exportPath)
    23.     {
    24.         Debug.Log("[UCB Demos] OnPostprocessBuildiOS");
    25.         ProcessPostBuild(BuildTarget.iOS,exportPath);
    26.     }
    27.     #endif
    28.  
    29.     /**
    30.      * Runs after successful build of an iOS-targetted Unity project
    31.      * via the editor Build dialog.
    32.      */
    33.     [PostProcessBuild]
    34.     public static void OnPostprocessBuild (BuildTarget buildTarget, string path)
    35.     {
    36.         #if !UNITY_CLOUD_BUILD
    37.         Debug.Log ("[UNITY_CLOUD_BUILD] OnPostprocessBuild");
    38.         ProcessPostBuild (buildTarget, path);
    39.         #endif
    40.     }
    41.  
    42.     /**
    43.      * This ProcessPostBuild method will run via Unity Cloud Build, as well as
    44.      * locally when build target is iOS. Using the Xcode Manipulation API, it is
    45.      * possible to modify build settings values and also perform other actions
    46.      * such as adding custom frameworks. Link below is the reference documentation
    47.      * for the Xcode Manipulation API:
    48.      *
    49.      * http://docs.unity3d.com/ScriptReference/iOS.Xcode.PBXProject.html
    50.      */
    51.     private static void ProcessPostBuild (BuildTarget buildTarget, string path)
    52.     {
    53.         // Only perform these steps for iOS builds
    54.         #if UNITY_IOS
    55.  
    56.         Debug.Log ("[UNITY_IOS] ProcessPostBuild - Adding Google Analytics frameworks.");
    57.  
    58.         // Go get pbxproj file
    59.         string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
    60.  
    61.         // PBXProject class represents a project build settings file,
    62.         // here is how to read that in.
    63.         PBXProject proj = new PBXProject ();
    64.         proj.ReadFromFile (projPath);
    65.  
    66.         // This is the Xcode target in the generated project
    67.         string target = proj.TargetGuidByName("Unity-iPhone");
    68.  
    69.         // List of frameworks that will be added to project
    70.         List<string> frameworks = new List<string>() {
    71.             "AdSupport.framework",
    72.             "CoreData.framework",
    73.             "SystemConfiguration.framework",
    74.             "libz.dylib",
    75.             "libsqlite3.dylib"
    76.         };
    77.  
    78.         // Add each by name
    79.         frameworks.ForEach((framework) => {
    80.             proj.AddFrameworkToProject(target, framework, false);
    81.         });
    82.  
    83.         // If building with the non-bitcode version of the plugin, these lines should be uncommented.
    84.         // Debug.Log("[UNITY_IOS] ProcessPostBuild - Setting build property: ENABLE_BITCODE = NO");
    85.         // proj.AddBuildProperty(target, "ENABLE_BITCODE", "NO");
    86.  
    87.         // Write PBXProject object back to the file
    88.         proj.WriteToFile (projPath);
    89.  
    90.         #endif
    91.     }
    92. }
    93.  
    2) Create an iOS target in Cloud Build or modify existing, and make sure to set the Post-Export Method to 'PostBuildProcessor.OnPostprocessBuildiOS'.
    3) Start a new build and it should complete.

    The XCode Manipulation API will let you manipulate various aspects of your generated build that are expected by some plugins. This script serves as a straightforward example of how to modify your XCode project post-build, and maintain consistency between your local and cloud builds. Let me know if you run into any issues getting this to work, I've tested successfully with bitcode/non-bitcode plugins and the builds installed from the Cloud Build site are reporting properly to GA.
     
    squarelover, yuliyF, anarh80 and 3 others like this.
  7. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    53
    Hi Chris, i added the script and not it is working!
    I also added the "libGoogleAnalyticsServices.a" to the build.

    Thanks a lot!
     
  8. mwk888

    mwk888

    Joined:
    Jan 26, 2014
    Posts:
    16
    Thanks Chris, very helpful. I had to change the loop syntax to:

    Code (CSharp):
    1.         // Add each by name
    2.         foreach (var framework in frameworks) {
    3.             proj.AddFrameworkToProject(target, framework, false);
    4.         };

    Note for people doing the Unity iOS build on Windows: UnityEditor.iOS.Xcode does not seem to exist in the Windows editor even when the iOS platform target is selected. The script runs fine when invoked during the Xcode build, so just ignore the errors while editing.
     
  9. sillyplayground

    sillyplayground

    Joined:
    Aug 27, 2014
    Posts:
    20
    I used the script attached by Chris above, but it doesn't build for 5.6 on UCB.
    The only error message I see is:
    28474: [Unity] ERROR: postExportMethod 'PostBuildProcessor.OnPostprocessBuildiOS' failed, aborting.

    How do I debug this?
     
  10. squarelover

    squarelover

    Joined:
    Nov 14, 2012
    Posts:
    21
    2019
    string target = proj.GetUnityMainTargetGuid();
     
  11. agtdigital

    agtdigital

    Joined:
    Jun 26, 2019
    Posts:
    1
    Hi

    I'm having the same type of issue.
    My configuration :
    - Unity 2020.1.3
    - XCode 11.7
    - Google Analytics SDK V3 with bitcode (Also tried V4, and I can't use GA SDK without bitcode because XCode return error)

    I link all libraries and framework as it is asked in Google Analytics SDK but no way..
    I tried to use TBD files instead of DYLIB files, but same result...
    Can you see any things I should do or an error ?

    I use : proj.GetUnityMainTargetGuid();

    You can see on screenshot the different errors and the libraries configuration
    The library libsqlite seams to be not linked but I don't understand why..
     

    Attached Files:

unityunity