Skip to content

Instantly share code, notes, and snippets.

@hacha
Created September 15, 2019 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacha/4e9d0b8e12520ada6d34fc92e6d8140f to your computer and use it in GitHub Desktop.
Save hacha/4e9d0b8e12520ada6d34fc92e6d8140f to your computer and use it in GitHub Desktop.
iOSビルド時にAssociatedDomainsを追加するエディタスクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public static class IOSBuildPostProcessor
{
[PostProcessBuild]
public static void OnPostprocessBuild (BuildTarget target, string pathToBuiltProject)
{
if (target == BuildTarget.iOS)
{
OnPostprocessBuildIOS (pathToBuiltProject);
}
}
private static void OnPostprocessBuildIOS (string pathToBuiltProject)
{
//This is the default path to the default pbxproj file. Yours might be different
string projectPath = "/Unity-iPhone.xcodeproj/project.pbxproj";
//Default target name. Yours might be different
string targetName = "Unity-iPhone";
//Set the entitlements file name to what you want but make sure it has this extension
string entitlementsFileName = "my_app.entitlements";
var entitlements = new ProjectCapabilityManager(pathToBuiltProject + projectPath, entitlementsFileName, targetName);
var domain = "ここにDynamic Linksのドメインを";
entitlements.AddAssociatedDomains(new string[] { "applinks:" + domain });
//Apply
entitlements.WriteToFile();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment