Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Never ignore Asset meta data
!/[Aa]ssets/**/*.meta
# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/
Expand Down Expand Up @@ -53,8 +57,45 @@ sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

/automation/
/build/
/download_artifacts_test_output/
/test_output/
/gradle.properties
/.vscode/
.vsconfig

.gradle/

/plugin/Assembly-CSharp-Editor.csproj
/plugin/Assets/PlayServicesResolver/Editor/JarResolverLib.dll
/plugin/Assets/Plugins/
/plugin/Assets/Plugins.meta
/plugin/Assets/StyleCop.Cache
/plugin/Assets/StyleCop.Cache.meta
/plugin/Library/
/plugin/ProjectSettings/
/plugin/Temp/
/plugin/obj/
/plugin/plugin.sln
/plugin/plugin.userprefs
/source/ExportUnityPackage/__pycache__/

/source/.idea/
/unity_dlls/

.DS_Store
161 changes: 130 additions & 31 deletions Assets/Editor/PostBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,149 @@
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using UnityEditor.iOS.Xcode;
using System.IO;
using System;

public class PostBuildProcessor : MonoBehaviour {
namespace TapResearch {

#if UNITY_CLOUD_BUILD
public static void OnPostprocessBuildiOS (string exportPath) {
PostprocessBuild (BuildTarget.iPhone, exportPath);
}
#endif
public class PostProcessIOS : MonoBehaviour {

//---------------------------------------------------------------------------------------------
[PostProcessBuildAttribute(45)]
private static void OnPostProcessBuildiOS_45(BuildTarget target, string buildPath) {

[PostProcessBuild]
public static void OnPostprocessBuild (BuildTarget buildTarget, string path) {
if (buildTarget != BuildTarget.iOS) {
Debug.LogWarning ("Build target is not iOS. Postprocess build will not run.");
return;
if (target == BuildTarget.iOS) {
//Debug.Log("(45) runtime version: " + Application.unityVersion);

#if !UNITY_CLOUD_BUILD
string podFileName = buildPath + "/Podfile";
PostprocessBuild(target, buildPath);
#endif
}
}

#if !UNITY_CLOUD_BUILD
PostprocessBuild (buildTarget, path);
#endif

}
//---------------------------------------------------------------------------------------------
// This is called after the Cocoapod has been "installed"
[PostProcessBuildAttribute(9999)]
private static void OnPostProcessBuildiOS_9999(BuildTarget target, string buildPath) {

if (target == BuildTarget.iOS) {
//Debug.Log("(9999) runtime version: " + Application.unityVersion);

#if !UNITY_CLOUD_BUILD
string podFileName = buildPath + "/Podfile";
AddFrameworkToProjectEmbeddedList(target, buildPath);
#endif
}
}

private const string XCFRAMEWORK_ORIGIN_PATH = "Pods/TapResearch";
private const string XCFRAMEWORK_NAME = "TapResearchSDK.xcframework";

private const string FRAMEWORK_TARGET_PATH = "Frameworks";

private const string FRAMEWORK_ORIGIN_PATH = "Pods/TapResearch";
private const string FRAMEWORK_NAME = "TapResearchSDK.framework";

//---------------------------------------------------------------------------------------------
private static void AddFrameworkToProjectEmbeddedList(BuildTarget buildTarget, string path) {

//Debug.Log("AddFrameworkToProjectEmbeddedList -----------------------------------------------------------");
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath));

private static void PostprocessBuild (BuildTarget buildTarget, string path) {
Debug.Log ("PostprocessBuild");
#if (UNITY_2019_3_OR_NEWER)
string target = project.GetUnityMainTargetGuid();
#else
string target = project.TargetGuidByName("Unity-iPhone");
#endif

string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject project = new PBXProject ();
project.ReadFromString (File.ReadAllText (projectPath));
// add the framework to the project and enable 'Embed & Sign' for it
string sourcePath;
string destPath;
if (Application.unityVersion.Contains("2018")) {
sourcePath = path + "/" + FRAMEWORK_ORIGIN_PATH + "/" + XCFRAMEWORK_NAME + "/ios-arm64_armv7/" + FRAMEWORK_NAME;
destPath = path + "/" + FRAMEWORK_TARGET_PATH + "/" + FRAMEWORK_NAME;
}
else {
sourcePath = path + "/" + XCFRAMEWORK_ORIGIN_PATH + "/" + XCFRAMEWORK_NAME;
destPath = path + "/" + FRAMEWORK_TARGET_PATH + "/" + XCFRAMEWORK_NAME;
}

string target = project.TargetGuidByName ("Unity-iPhone");
Debug.Log(" starting copy from " + sourcePath + " to " + destPath);
CopyDirectory(sourcePath, destPath);
string fileGuid = project.AddFile(destPath, destPath);
Debug.Log("FILE GUID = " + fileGuid);
UnityEditor.iOS.Xcode.Extensions.PBXProjectExtensions.AddFileToEmbedFrameworks(project, target, fileGuid);

// Required Frameworks
project.AddFrameworkToProject (target, "SystemConfiguration.framework", false);
project.AddFrameworkToProject (target, "Security.framework", false);
project.AddFrameworkToProject (target, "AdSupport.framework", false);
project.AddFrameworkToProject (target, "MobileCoreServices.framework", false);
File.WriteAllText(projectPath, project.WriteToString());
}

//---------------------------------------------------------------------------------------------
private static void PostprocessBuild(BuildTarget buildTarget, string path) {

//Debug.Log("PostprocessBuild -----------------------------------------------------------");
//Debug.Log("buildPath = " + path);

string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath));

#if (UNITY_2019_3_OR_NEWER)
string target = project.GetUnityMainTargetGuid();
#else
string target = project.TargetGuidByName("Unity-iPhone");
#endif

// Required Frameworks
project.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
project.AddFrameworkToProject(target, "Security.framework", false);
project.AddFrameworkToProject(target, "AdSupport.framework", false);
project.AddFrameworkToProject(target, "CoreServices.framework", false);

// Required Linker Flags
project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
// Required Linker Flags
project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
project.AddBuildProperty(target, "SWIFT_COMPILATION_MODE", "wholemodule");

//Debug.Log("Getting SWIFT_VERSION");
string swiftVersion = project.GetBuildPropertyForAnyConfig(target, "SWIFT_VERSION");
//Debug.Log("SWIFT_VERSION = " + swiftVersion);
if (swiftVersion == null || swiftVersion.Length == 0) {
//Debug.Log("Adding SWIFT_VERSION = 5");
project.AddBuildProperty(target, "SWIFT_VERSION", "5");
}
else {
//Debug.Log("Setting SWIFT_VERSION = 5");
project.SetBuildProperty(target, "SWIFT_VERSION", "5");
}

File.WriteAllText(projectPath, project.WriteToString());
}

//---------------------------------------------------------------------------------------------
private static void CopyDirectory(string sourcePath, string destPath) {

//Debug.Log("copy from " + sourcePath + " to " + destPath);
if (!Directory.Exists(destPath)) {
Directory.CreateDirectory(destPath);
}

foreach (string file in Directory.GetFiles(sourcePath)) {
if (!file.Contains(".meta")) {
File.Copy(file, Path.Combine(destPath, Path.GetFileName(file)));
}
}
foreach (string dir in Directory.GetDirectories(sourcePath)) {
CopyDirectory(dir, Path.Combine(destPath, Path.GetFileName(dir)));
}
}

}

File.WriteAllText (projectPath, project.WriteToString ());
}
}
#endif
21 changes: 21 additions & 0 deletions Assets/Editor/TapResearchDependencies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<dependencies>

<androidPackages>
<repositories>
<repository>https://artifactory.tools.tapresearch.io/artifactory/tapresearch-android-sdk</repository>
<repository>https://maven.google.com</repository>
</repositories>
<androidPackage spec="com.tapr:tapresearch:2.4.1"></androidPackage>
<androidPackage spec="com.tapr.unitybridge:tapresearch:2.4.1"></androidPackage>
</androidPackages>


<iosPods>
<iosPod name="TapResearch" version="2.4.1" minTargetSdk="10.0" useFrameworks="true">
<sources>
<source>https://github.com/CocoaPods/Specs.git</source>
</sources>
</iosPod>
</iosPods>

</dependencies>
7 changes: 7 additions & 0 deletions Assets/Editor/TapResearchDependencies.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/ExternalDependencyManager.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/ExternalDependencyManager/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading