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.
public class CommandLineiOSBuild
{
static private string[] collectBuildScenes()
{
var scenes = new List<string>();
foreach (var scene in EditorBuildSettings.scenes)
{
if (scene == null)
continue;
if (scene.enabled)
scenes.Add(scene.path);
}
return scenes.ToArray();
}
[MenuItem(@"Build/BuildIOS")]
static public void build()
{
var scenes = collectBuildScenes();
BuildPipeline.BuildPlayer(scenes, "ios", BuildTarget.iOS, BuildOptions.None);
}
}
public class BuildPostProcessor
{
[PostProcessBuildAttribute(1)]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if (target == BuildTarget.iOS)
{
// Read.
string projectPath = PBXProject.GetPBXProjectPath(path);
PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath));
string targetName;
//targetName = project.GetUnityTargetName();
targetName = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
string targetGUID = project.TargetGuidByName(targetName);
AddFrameworks(project, targetGUID);
// Write.
File.WriteAllText(projectPath, project.WriteToString());
}
}
static void AddFrameworks(PBXProject project, string targetGUID)
{
// Frameworks (eppz! Photos, Google Analytics).
project.AddFrameworkToProject(targetGUID, "AdSupport.framework", false);
project.AddFrameworkToProject(targetGUID, "CoreData.framework", false);
project.AddFrameworkToProject(targetGUID, "SystemConfiguration.framework", false);
project.AddFrameworkToProject(targetGUID, "libz.dylib", false);
project.AddFrameworkToProject(targetGUID, "libsqlite3.tbd", false);
project.AddFrameworkToProject(targetGUID, "libGoogleAnalyticsServices.a", false);
// Add `-ObjC` to "Other Linker Flags".
project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC");
}
}
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