54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
		
		
			
		
	
	
			54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
| 
								 | 
							
								#if UNITY_IOS
							 | 
						|||
| 
								 | 
							
								using System.IO;
							 | 
						|||
| 
								 | 
							
								using UnityEditor;
							 | 
						|||
| 
								 | 
							
								using UnityEditor.Callbacks;
							 | 
						|||
| 
								 | 
							
								using UnityEditor.iOS.Xcode;
							 | 
						|||
| 
								 | 
							
								using UnityEngine;
							 | 
						|||
| 
								 | 
							
								namespace AmazonInternal.Editor.Postbuild {
							 | 
						|||
| 
								 | 
							
								    public static class AmazonPostBuildiOS {
							 | 
						|||
| 
								 | 
							
								        [PostProcessBuild( 45 )]
							 | 
						|||
| 
								 | 
							
								        public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (buildTarget != BuildTarget.iOS)
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            string pbxProjectPath = PBXProject.GetPBXProjectPath(path);
							 | 
						|||
| 
								 | 
							
								            PBXProject project = new PBXProject();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            project.ReadFromFile(pbxProjectPath);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#if UNITY_2019_3_OR_NEWER
							 | 
						|||
| 
								 | 
							
								            string targetGuid = project.GetUnityFrameworkTargetGuid();
							 | 
						|||
| 
								 | 
							
								#else
							 | 
						|||
| 
								 | 
							
								            string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName());
							 | 
						|||
| 
								 | 
							
								#endif
							 | 
						|||
| 
								 | 
							
								            project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited)");
							 | 
						|||
| 
								 | 
							
								            project.SetBuildProperty(targetGuid, "CLANG_ENABLE_MODULES", "YES");
							 | 
						|||
| 
								 | 
							
								            project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
							 | 
						|||
| 
								 | 
							
								            
							 | 
						|||
| 
								 | 
							
								            project.WriteToFile(pbxProjectPath);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								#if UNITY_2019_3_OR_NEWER
							 | 
						|||
| 
								 | 
							
								            if (buildTarget == BuildTarget.iOS)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                bool iPhoneExist = false;
							 | 
						|||
| 
								 | 
							
								                using (StreamReader sr = new StreamReader(path + "/Podfile"))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    string contents = sr.ReadToEnd();
							 | 
						|||
| 
								 | 
							
								                    if (contents.Contains("Unity-iPhone"))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        iPhoneExist = true;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                if ( !iPhoneExist ){
							 | 
						|||
| 
								 | 
							
								                    using (StreamWriter sw = File.AppendText(path + "/Podfile"))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        sw.WriteLine("\ntarget 'Unity-iPhone' do\nend");
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								#endif
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								#endif
							 |