xamarin / GoogleApisForiOSComponents

MIT License
225 stars 161 forks source link

Maui - iOS push notification cannot be set up - Could not find a part of the path (Path too long) #630

Open Zack-G-I-T opened 1 year ago

Zack-G-I-T commented 1 year ago

Using the Xamarin.Firebase.iOS.CloudMessaging nuget in .NET Maui. Android works fine, but in iOS we get this error. I believe it is because the file path is too long - however I have set the system settings to enable long paths and still get this exception.

**An error occurred while trying to deploy the app 'SamplePush.app'. Details: Could not find a part of the path

'C:\Users\username\AppData\Local\MyTempFiles\Xamarin\HotRestart\Signing\SamplePush.app\out\Payload\SamplePush.app\SamplePush.content\Firebase.CloudMessaging.resources\FirebaseMessaging.xcframework\ios-arm64\FirebaseMessaging.framework\Headers\FirebaseMessaging-umbrella.h'.**

I changed my temp file location to be shorter C:\tmp but still get the following:

**An error occurred while trying to deploy the app 'SamplePush.app'. Details: Could not find a part of the path

'C:\Tmp\Xamarin\HotRestart\Signing\SamplePush.app\out\Payload\SamplePush.app\SamplePush.content\Firebase.Core.resources\GoogleUtilitiesComponents.xcframework\ios-arm64_x86_64-simulator\GoogleUtilitiesComponents.framework\Headers\GoogleUtilitiesComponents-umbrella.h'**

krirkGenerwiz0137 commented 1 year ago

Yeah , i found this problem too T^T i use window 11 home , visual studio 22 my project is c# .net 7 maui
i use Firebase and it's call xamarin.firebase.ios.CloudFireStore and BOOM Long Path error i try to set in regedit, gpedit.msc
it's not happen T^T
so sad brother

AdamEssenmacher commented 1 year ago

Try clearing your local nuget cache and run a nuget restore from the command line (not using Visual Studio).

Grzesik commented 10 months ago

Hi, I could manage the problem and now I can compile the iOS .Net 8 Maui App with Pulgin.Firtebase. I used "dotnet restore" to get the nuget package. But now I'd like to publish the app and I can't create an archive with the Archive Manager from Visual Studio 2022, because the path is too long! The zip file can be craeted, but the Unzip task crashes. The path, where the zip file is created is: C:\Users\Marian.GRZESIK\AppData\Local\Xamarin\iOS\Archives\2024-01-05 When I try to unzip the file in c:\tmp, than it works. Is it possible to shorten the paths? It worked well in Xamarin.Forms, but in .Net Maui it doesn't.

AdamEssenmacher commented 10 months ago

In the past, .NET iOS binding libraries were packed into .dll files. This led to naturally shorter file paths (e.g. /lib/xamarinios10/Firebase.Core.dll)

Apple has shifted to using XCFrameworks as the standard binary packaging format. This leads to naturally longer file paths (e.g /lib/net6-ios15.4/FIrebase.Core.resources/GoogleUtilitiesComponents.xcframework/ios-arm64/GoogleUtilitiesComponents.framework/Headers/GoogleUtilitiesComponents-umbrella.h)

Visual Studio (Windows) is fundamentally incapable of dealing with longer file paths like this. See: https://github.com/NuGet/docs.microsoft.com-nuget/issues/2323

The punchline is that Visual Studio (Windows) is simply no longer a reliably viable tool for building or archiving iOS apps (MAUI or otherwise).

gbrunton commented 10 months ago

I fixed this by changing the nuget package location to a path that’s shorter than the default path. I did this by adding the following configuration to my NuGet.Config.

`

`

Grzesik commented 10 months ago
  1. I tried the short path in Nuget. I can compile iOS, but I could it also before. The problem is still the Package Manager in Visual Studio 2022, which can't create the package because of too long path. It can't Unzip the package. I changed the tmp path in windows to a very short one and the location of the archive, but the path ist still too long.
  2. In Android I had to delete temporary iOS as the target framework, because otherwise it crashes with the same problem, because of iOS and too long path. It's strange. Without iOS I can build the package for the store.

I think the really well solution were the support of long path in Visual Studio 2022. It's awkward, that it can cope with long path till today.

PS. I had the same problem with an another Nuget Package -> Scandit for .Net Maui. The developer changed the names to much shorten ones, and now it works without any problem.

AdamEssenmacher commented 10 months ago

The developer changed the names to much shorten ones, and now it works without any problem.

You cannot simply change names in an XCFramework. They need to match the module names.

williambuchanan2 commented 10 months ago

I fixed this by changing the nuget package location to a path that’s shorter than the default path. I did this by adding the following configuration to my NuGet.Config.

<config> <add key="globalPackagesFolder" value="D:\nuget" /> </config>

That's a workaround - not a fix ;) . A fix would prevent the problem from happening in the first place!

krirkGenerwiz0137 commented 9 months ago

I fixed this by changing the nuget package location to a path that’s shorter than the default path. I did this by adding the following configuration to my NuGet.Config. <config> <add key="globalPackagesFolder" value="D:\nuget" /> </config>

That's a workaround - not a fix ;) . A fix would prevent the problem from happening in the first place!

i try this but C:\nuget is ok
but my main project is C:\XXXXXXX\XXXXXXXX\XXXXXXXXX\bin\debug................................... it's still too long T^T

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4911,5)

: warning MSB3026: Could not copy "C:\Nuget\xamarin.firebase.ios.cloudfirestore\8.10.0.3\lib\net6.0-ios15.4\Firebase.CloudFirestore.resources\grpc.xcframework\ios-arm64_x86_64-simulator\grpc.framework\PrivateHeaders\src\core\ext\filters\workarounds\workaround_cronet_compression_filter.h"

to "bin\Debug\net7.0-ios\iossimulator-x64\Firebase.CloudFirestore.resources\grpc.xcframework\ios-arm64_x86_64-simulator\grpc.framework\PrivateHeaders\src\core\ext\filters\workarounds\workaround_cronet_compression_filter.h".

Beginning retry 2 in 1000ms. Could not find a part of the path 'bin\Debug\net7.0-ios\iossimulator-x64\Firebase.CloudFirestore.resources\grpc.xcframework\ios-arm64_x86_64-simulator\grpc.framework\PrivateHeaders\src\core\ext\filters\workarounds\workaround_cronet_compression_filter.h'.

SamuelBachar commented 9 months ago

For anyone who have still problem with long paths (size bigger than 260 characters).

  1. Check if problematic paths do contains your project name. If yes you can try to rename it.

  2. If bin or obj files are problem you can try to set them in properties of your project under Build configuration

  3. Check if problematic path contains C:\Users\YourProfileName\AppData\Local\Temp... at the beginning, if yes there is DIRTY option to rename ENVIROMENTAL VARIABLE TEMP and TMP to something like C:\Test , BUT I needed to do RESTART of PC in order to stop copying into AppData\Local\Temp\Xamarin\ .... this will save you certain amount of characters

  4. I don't know how much it can effect other stuff if you change those variables, but I got rid of issue with MAX_SIZE (Windows 11 looks like had still problem no matter what I did)

Combination of following might help you. Hope it helps.