3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【iOS】デバッグビルドのときだけApplication.presistentDataPathのデータをPCと共有したい

Posted at

Application.persistentDataPath はiOSの場合に、Documentsディレクトリを指すため、Info.plistのUIFileSharingEnabledtrueにしてあげれば良い。

MyPostprocessBuild.cs
using UnityEngine;
using UnityEditor;
using UnityEditor.iOS.Xcode;

// クラス名、ファイル名は適宜変更してください
public class MyPostprocessBuild
{
    [PostProcessBuild]
    public static void OnPostprocessBuild(BuildTarget target, string path)
    {
        if (target == BuildTarget.iOS)
        {
            var plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
            var plist = new PlistDocument();
            plist.ReadFromFile(plistPath);

            // Application supports iTunes file sharing
            plist.root.SetBoolean("UIFileSharingEnabled", Debug.isDebugBuild);

            plist.WriteToFile(plistPath);
        }
    }
}
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?