Meta and appflyer deeper intregration

This commit is contained in:
Savya Bikram Shah
2026-06-07 14:12:09 +05:45
parent 70b8dd2b95
commit a07f7618ab
200 changed files with 9081 additions and 2300 deletions

View File

@@ -0,0 +1,62 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Facebook.
*
* As with any software that integrates with the Facebook platform, your use of
* this software is subject to the Facebook Developer Principles and Policies
* [http://developers.facebook.com/policy/]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System.IO;
using UnityEngine;
using UnityEditor;
#if UNITY_IOS
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;
#endif
using UnityEditor.Callbacks;
namespace Facebook.Unity.PostProcess
{
    /// <summary>
    /// Automatically disables Bitcode on iOS builds
    /// </summary>
public static class DisableBitcode
{
[PostProcessBuildAttribute(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuildProject)
{
#if UNITY_IOS
if (buildTarget != BuildTarget.iOS) return;
string projectPath = pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);
//Disabling Bitcode on all targets
//Main
string target = pbxProject.GetUnityMainTargetGuid();
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
//Unity Tests
target = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
//Unity Framework
target = pbxProject.GetUnityFrameworkTargetGuid();
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
pbxProject.WriteToFile(projectPath);
#endif
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 201fa01d552b84a74917c9cc8a4c297c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,107 @@
using System.IO;
using UnityEngine;
using UnityEditor;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
#endif
using UnityEditor.Callbacks;
namespace Darkmatter.Editor.PostProcess
{
/// <summary>
/// Embeds the Facebook iOS dynamic frameworks (FBSDKCoreKit, FBAEMKit, ...) into the
/// main app target on every iOS export.
///
/// Why this exists: EDM4U is configured with "Link frameworks statically"
/// (Google.IOSResolver.PodfileStaticLinkFrameworks = 1) — needed for Firebase /
/// AppsFlyer. With static linkage CocoaPods does NOT generate the
/// "[CP] Embed Pods Frameworks" phase, so Facebook's prebuilt *dynamic* xcframeworks
/// get linked but never copied into the app bundle. At launch dyld then fails with:
/// Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit
/// This reproduces the manual "Embed &amp; Sign" step automatically, and leaves the
/// static linkage of every other SDK untouched.
/// </summary>
public static class EmbedFacebookFrameworks
{
// FB pods from Assets/FacebookSDK/Plugins/Editor/Dependencies.xml, plus FBAEMKit
// which CocoaPods pulls in transitively via FBSDKCoreKit.
static readonly string[] Frameworks =
{
"FBAEMKit",
"FBSDKCoreKit",
"FBSDKCoreKit_Basics",
"FBSDKGamingServicesKit",
"FBSDKLoginKit",
"FBSDKShareKit",
};
// Order 100: after EDM4U's pod install (low order) so Pods/ exists, before
// DisableBitcode (999). Exact timing is not critical — paths are project-relative
// and resolved by Xcode at build time.
[PostProcessBuild(100)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
#if UNITY_IOS
if (buildTarget != BuildTarget.iOS) return;
string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
var project = new PBXProject();
project.ReadFromFile(projectPath);
string mainTarget = project.GetUnityMainTargetGuid();
int embedded = 0;
foreach (string fw in Frameworks)
{
string relPath = ResolveFrameworkPath(pathToBuiltProject, fw);
// Idempotent: a fresh project is exported each build, but guard anyway.
if (project.ContainsFileByProjectPath(relPath))
continue;
string fileGuid = project.AddFile(relPath, relPath);
project.AddFileToBuild(mainTarget, fileGuid); // link
project.AddFileToEmbedFrameworks(mainTarget, fileGuid); // Embed & Sign
embedded++;
}
// FB frameworks bundle their own Swift runtime, and the FB SDK ships Swift
// sources compiled into UnityFramework. Embedding the Swift std libs in BOTH
// the app target and UnityFramework triggers duplicate-dylib signing failures
// on archive. Only the main target should embed them. Remove this line if your
// setup reports "Swift runtime not found".
string unityFramework = project.GetUnityFrameworkTargetGuid();
project.SetBuildProperty(unityFramework, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
project.WriteToFile(projectPath);
Debug.Log($"[EmbedFacebookFrameworks] Embedded {embedded}/{Frameworks.Length} Facebook frameworks into the main iOS target.");
#endif
}
#if UNITY_IOS
// Current FB SDK vendors the binary at Pods/<fw>/XCFrameworks/<fw>.xcframework;
// older layouts used Frameworks/. Probe both. If Pods/ isn't installed yet at
// post-process time, fall back to the XCFrameworks path (resolves at build time).
static string ResolveFrameworkPath(string buildRoot, string fw)
{
string name = fw + ".xcframework";
string[] candidates =
{
Path.Combine("Pods", fw, "XCFrameworks", name),
Path.Combine("Pods", fw, "Frameworks", name),
};
foreach (string rel in candidates)
{
if (Directory.Exists(Path.Combine(buildRoot, rel)))
return rel;
}
Debug.LogWarning($"[EmbedFacebookFrameworks] {name} not found under Pods/ yet; " +
$"referencing {candidates[0]} (valid once pod install has run).");
return candidates[0];
}
#endif
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 71252a86bda034fb8aee21f1fc29836a