Skip to content

Instantly share code, notes, and snippets.

@shiena
Created October 14, 2018 17:04
Show Gist options
  • Select an option

  • Save shiena/5ad7c11b940ee7681125a2d0be7806f4 to your computer and use it in GitHub Desktop.

Select an option

Save shiena/5ad7c11b940ee7681125a2d0be7806f4 to your computer and use it in GitHub Desktop.
Unity2018.2+il2cpp+gRPCをAndroid/iOSでビルドする

共通

enumoneofを使っている場合は以下のコードでその型を指定する

using Google.Protobuf.Reflection;

FileDescriptor.ForceReflectionInitialization<T>();

Androidの場合

以下のファイルを配置する

iOS

  • bitcode非対応なのでENABLE_BITCODENOにする
  • libzのリンクがないので追加する

BuildHelper.csを適当なEditorフォルダに配置するとビルド時に自動的に反映される。

#if UNITY_EDITOR_OSX
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public class BuildHelper
{
// Add libresolv.tdb when building for iOS
// Thanks to https://gist.github.com/eppz/1ebbc1cf6a77741f56d63d3803e57ba3
[PostProcessBuildAttribute(1)]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if (target == BuildTarget.iOS)
{
var projectPath = PBXProject.GetPBXProjectPath(path);
var project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath));
var targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName());
project.AddFrameworkToProject(targetGUID, "libz.1.2.11.tbd", false);
project.SetBuildProperty(targetGUID, "ENABLE_BITCODE", "NO");
File.WriteAllText(projectPath, project.WriteToString());
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment