2019.3.0b3/0b4 "Calling TargetGuidByNameWithName="Unity-iPhone" is deprecated. (Wont build)

Hi guys,

I tried with both 2019.3.0b3 and 0b4 on a nearly empty project and I’m getting the error:
“Exception: Calling TargetGuidByName with name=‘Unity-iPhone’ is deprecated. There are two targets now, call GetUnityMainTargetGuid() - for app or GetUnityFrameworkTargetGuid() - for source/plugins to get Guid instead.”

I’m not sure if this is a bug or a setting somewhere. Googling around led to a patch back in June, but it didn’t appear to fix anything for anyone and I was posting here for advice. The project will not build right now because of this.

An empty project works just fine, but one upgraded from a previous version does not.

The log his here and it appears to be coming from an ad framework even though I have no ads in my project:
Exception: Calling TargetGuidByName with name=‘Unity-iPhone’ is deprecated. There are two targets now, call GetUnityMainTargetGuid() - for app or GetUnityFrameworkTargetGuid() - for source/plugins to get Guid instead.
UnityEditor.iOS.Xcode.PBXProject.TargetGuidByName (System.String name) (at /Users/builduser/buildslave/unity/build/External/XcodeAPI/Xcode/PBXProject.cs:168)
UnityEditorInternal.Advertisements.UnityAdsPostprocessor.EditXcodeProject (System.String buildFolder) (at /home/builduser/buildslave/com.unity.ads/package/Source/UnityAdsEditor/UnityAdsPostprocessor.cs:101)
UnityEditorInternal.Advertisements.UnityAdsPostprocessor.PostProcessBuild_iOS (UnityEditor.BuildTarget target, System.String path) (at /home/builduser/buildslave/com.unity.ads/package/Source/UnityAdsEditor/UnityAdsPostprocessor.cs:92)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:177)
UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass17_0.b__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:433)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List1[T] oneInterfaces, System.Action1[T] invocationOne, System.Collections.Generic.List1[T] twoInterfaces, System.Action1[T] invocationTwo, System.Boolean exitOnFailure) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:391)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

1 Like

Hi,

Remove ads package unless you need it. If you need it, upgrade your ads package to version 3.

5 Likes

Go to File / Build Setting
in build setting run in Xcode choose the Xcode version that installed on your apple device

1 Like

In my case, the problem persisted after removing the ads package. It turned out that one of my plugins was using this outdated function. I did a global code search for TargetGuidByName that led me to the culprit line so that I could update it.

3 Likes

Updating ads worked for me. :slight_smile:

If you’re having difficulty figuring out how to update ads (like me, who never even turned them on)…

How to update:
Go to Window > Package Manager
Find a tab called ‘Ads’ or ‘Advertisement’
Select 3.2.0 from the ‘Ads’ dropdown menu
Click ‘Update to 3.2.0’

(stolen from some other post that I forget the link to)

2 Likes

How did you update the lines?

Replace
TargetGuidByName("Unity-iPhone")
with
GetUnityMainTargetGuid()

7 Likes

This function currently updates all references in the target but not the project for the build. Upon compiling, you still need to manually copy over the post build processes to the main project. Still trying to see if Unity made another way to reference the project as a Guid as PBXProject.ProjectGuid currently causes a compile error when used in place of PBXProject.GetUnityMainTargetGuid.

In which file exactly?

In my case it was NativeToolKit that was doing this and so I changed in in PostProcessor.cs which was under Assets->NativeToolKit->Editor

2 Likes

That was the solution! Thanks a lot!!

2 Likes

Worked for me

This solved the problem for me! Thanks!

Edit: Or at least I thought so. I can build, but I cannot “build and run”. Building the project solely succeeds, but opening XCode automatically afterward produces the same error, and a failed built.