mapbox / mapbox-unity-sdk

Mapbox Unity SDK - https://www.mapbox.com/unity/
Other
720 stars 213 forks source link

Issues with UnityARBuildPostprocessor.OnPostprocessBuildIOS (System.String pathToBuiltProject) (at Assets/MapboxSDK/UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs:80) #1552

Open madhugk opened 4 years ago

madhugk commented 4 years ago

Unity Version: 2019.3.0f6, 2019.3.1f1 tried in both versions. Mapbox SDK version: mapbox-unity-sdk_v2.1.1 Platform: both iOS and Android deployment. tested on Android and works well.

Problem: I have been using Mapbox and was able to build and test in both Android and iOS but in recent, I am getting this following build errors been reported on "build and run" for iOS player settings.

> 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)
> 11:17
> UnityARBuildPostprocessor.OnPostprocessBuildIOS (System.String pathToBuiltProject) (at Assets/MapboxSDK/UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs:80)
> UnityARBuildPostprocessor.OnPostprocessBuild (UnityEditor.BuildTarget target, System.String pathToBuiltProject) (at Assets/MapboxSDK/UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs:21)

https://issuetracker.unity3d.com/issues/ios-build-and-run-fails-on-mac-for-ios?_ga=2.97605151.1031879647.1582109832-1370876546.1580485179

I found this above link describes more similar with Advertisements package. I also tried compiling in different locations and also removing sub folder under Assets but not able to fix it to run.

Please help me on this as I am new beginner to unity and couldn't able to find any solution yet on this. Thanks in Advance.

brnkhy commented 4 years ago

I think this is the same problem posted here: https://github.com/mapbox/mapbox-unity-sdk/pull/1513

and the final fix branch is here; https://github.com/mapbox/mapbox-unity-sdk/tree/TargetGuidByNameFix

hope that helps!

madhugk commented 4 years ago

Thanks for the help. So changing GetUnityFrameworkTargetGuid() instead of TargetGuidByName("Unity-iPhone") in Assets/MapboxSDK/UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs made it worked!!

Nima-Jamalian commented 4 years ago

Mange to get in work in Unity 2019.3.15f1

The problem is that TargetGuidByName() has been deprecated so you need to go and replace it with GetUnityFrameworkTargetGuid() in order to fix 'MapboxMobileEvents.h' file not found in xcode.

There are two scripts that you need to change:

1- Mapbox_iOS_build You can find the script at Mapbox/Unity/Editor/Build/Mapbox_iOS_build.cs, change line 26 string target = proj.TargetGuidByName("Unity-iPhone"); to string target = proj.GetUnityFrameworkTargetGuid();

2- UnityARBuildPostprocessor You can find the script at UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor Go to Line 80 and 81 change the code to the following proj.AddFrameworkToProject(proj.GetUnityFrameworkTargetGuid(), "ARKit.framework", false); string target = proj.GetUnityFrameworkTargetGuid();

lukemadera commented 3 years ago

Any update on when we can get this fix merged in so we don't have to patch it?

MartinMajewski commented 3 years ago

September 2021 and this issue still persists. Please update the Unity SDK to be less of a pain for current software versions like iOS 14+ and Unity 2021.x.

Thanks!