Packaging for iOS fails with "Cannot create because a file with the same name already exists."

I recently have issues packaging for iOS (and tvOS) on Mac. I use UE4Editor/Mac/Development built from latest 4.11 branch to package my game for iOS/Development. All goes well except in the end I get a message that it Cannot create /Volumes/Dev/UnrealEngine/4.11/Projects/SkookumDemo/Binaries/IOS/Payload/SkookumDemo.app/SkookumDemo because a file with the same name already exists.. I checked and indeed there is a file already named like that (the executable). Any clues why this is happening?

Full log text below:

MainFrameActions: Packaging (iOS): Project.Package: ********** PACKAGE COMMAND STARTED **********
MainFrameActions: Packaging (iOS): IOSPlatform.Package: Package /Volumes/Dev/UnrealEngine/4.11/Projects/SkookumDemo/SkookumDemo.uproject
MainFrameActions: Packaging (iOS): Getting IOS Deploy()
MainFrameActions: Packaging (iOS): Program.Main: ERROR: AutomationTool terminated with exception: System.IO.IOException: Cannot create /Volumes/Dev/UnrealEngine/4.11/Projects/SkookumDemo/Binaries/IOS/Payload/SkookumDemo.app/SkookumDemo because a file with the same name already exists.
MainFrameActions: Packaging (iOS):   at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at System.IO.DirectoryInfo.Create () [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
MainFrameActions: Packaging (iOS):   at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at System.IO.DirectoryInfo.Create () [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
MainFrameActions: Packaging (iOS):   at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at IOSPlatform.Package (AutomationTool.ProjectParams Params, DeploymentContext SC, Int32 WorkingCL) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at Project.Package (AutomationTool.ProjectParams Params, Int32 WorkingCL) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at BuildCookRun.DoBuildCookRun (AutomationTool.ProjectParams Params) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at BuildCookRun.ExecuteBuild () [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.BuildCommand.Execute () [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.Automation.Execute (System.Collections.Generic.List`1 CommandsToExecute, Tools.DotNETCommon.CaselessDictionary.CaselessDictionary`1 Commands) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.Automation.Process (System.String[] CommandLine) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.Program.MainProc (System.Object Param) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.InternalUtils.RunSingleInstance (System.Func`2 Main, System.Object Param) [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS):   at AutomationTool.Program.Main () [0x00000] in <filename unknown>:0 
MainFrameActions: Packaging (iOS): Program.Main: AutomationTool exiting with ExitCode=1 (Error_Unknown)
MainFrameActions: Packaging (iOS): Domain_ProcessExit
MainFrameActions: Packaging (iOS): RunUAT ERROR: AutomationTool was unable to run successfully.

Hi GreatGuru,

You cannot have a directory with the same name as the executable. Change the name of one and retry. Let me know if this does not work for you.

-.

Hmm both the folder and the executable name come from the build process as far as I know, presumably both reflecting the project name, SkookumDemo. I did not choose these names. How do you suggest I go about changing them? I could try renaming the project see if that helps I guess.

Using the project you sent, SkookumDemo 4.11 3, I was able to launch successfully to a folder on the Desktop called “TestPackage” for both Mac and iOS without issue. Please try this and/or renaming the project and let us know your results.

So - renaming the project file from to SkookumDemo.uproject to SkookumDemo2.uproject fixes the issue. I take it back, renaming the project file does not fix the issue. I renamed the project to all sorts of names, and just get the same message just with the word SkookumDemo replaced with the new project name. I am using UE4Editor on Mac and I “Package” for iOS.

Ok this looks like a bug related to the staging of additional NonUFS files. Seems like the folder hierarchy of staged files was changed between 4.10 and 4.11. You are not seeing the issue because you probably don’t have SkookumScript installed and never generated SkookumScript binary files that are packaged with the excutable, exposing this problem. Try to reproduce this (on Mac):

  1. In the SkookumDemo project, verify that there is an entry in the Config/DefaultGame.ini file

    [/Script/UnrealEd.ProjectPackagingSettings]
    +DirectoriesToAlwaysCook=(Path=“ScriptLoaded”)
    +DirectoriesToAlwaysStageAsNonUFS=(Path=“skookumscript”)

  2. Now, in the project’s Content folder, create a subfolder skookumscript, and inside that folder place a random file, e.g. a text file test.txt containing the string “Hello World”.

  3. Try to package the project for iOS, see if you get my error. What should happen here is that the skookumscript folder with the test file will be placed in the staged package inside the cookeddata/content folder. Instead it creates a folder SkookumDemo/content right beside cookeddata and places the skookumscript folder there. This then causes the naming conflict with the executable.

Thanks!

I cannot install SkookumScript… I get an error saying not compatible with this version of the Engine. I see the plugin is for UE4.11 preview 4, and everyone on the support team has updated to preview 5.

So do you have a preview 5 version of the plug-in available? If not, I may be able to find a workaround or someone who has not updated yet.

Have you tried the three steps above? They don’t require SkookumScript and should still cause the error to occur. We will post a pre-built plugin for 4.11p5 soon as well.

After following the first 2 steps I cannot open the project to perform step 3. However, while researching I discovered a similar bug that started in Preview 4 and is fixed in Preview 5. Please download preview 5 and see if this issue persists.

I missed your note before about opening on a Mac and was trying to open the Windows version. After following your steps on a Mac, the issue did not occur for 4.11Preview5, resulting in a successful package “SkookumDemo.ipa”

Your test file resides in: …SkookemDemo 4.11 3>Saved>StageBuilds>IOS>SkookumDemo>Content>skookumscript>test.rtf

If the folder Saved/StagedBuilds/iOS contains a folder SkookumDemo that would collide with the executable also named SkookumDemo which would be packaged at the same folder level. Also the content folder being mounted by the runtime file system is cookeddata and not SkookumDemo so test.rtf would not be found. Two problems right there. The folder 'skookumscriptcomes from the project'sContentfolder and has to end up in the package's content folder right beside thepaksfolder but obviously doesn't. Have you verified the ipa file that it contains in itsPayload/SkookumDemo.appfolder both yourtest.rtfinSkookumDemo/Content/skookumscriptand the executableSkookumDemo? If so that is a conflict constituting essentially a corrupt archive. Try extracting the archive - do you get an error message? If not, does the extracted data contain both the excutable SkookumDemoandtest.rtf`?

Also please try packaging the same project for Win64 you’ll see the folder structure is different = what it’s supposed to be. The skookumscript folder ends up next to the Paks folder where it belongs. Also works fine on Android btw. Just on iOS and tVOS it doesn’t. That is a bug.

Hi - any update on this? Were you able to reproduce it?

We are still looking at this and I should have more definitive information for you by noon tomorrow. In the meantime, have you tried updating to 4.11 preview 5?

Had some technical issues on the Mac that set me back. But following your steps from scratch, I came up with the exact same results as before: No packaging errors, successfully creating an ipa file. Wasn’t the initial issue that you were not able to create an ipa file successfully because you were getting the error: “Cannot create because a file with the same name already exists?”

Have you tried updating to preview 5 and setting your output to a different directory as troubleshooting steps? Are you able to create an ipa at all or does packaging fail when you get the error message? Please provide this information.

Hi - Yes my original issue was that packaging failed but the underlying problem is that folders specified using +DirectoriesToAlwaysStageAsNonUFS= will get archived incorrectly. This may or may not result in an error during packaging apparently. The folder skookumscript has to end up in the same content folder as the Paks and it’s not. Did you try unpacking the ipa as I suggested?

I have updated to 4.11p5 long ago. I tried both packaging with 4.11p5 and with latest 4.11 built from source. Both report an error that all my provisioning profiles are not valid (which they are, and they are not expired, and I have used them many times before). If I proceed anyway, 4.11p5 will fail with a code signing error, and 4.11 built from source will again fail with the error I started this thread on (Cannot create /Volumes/Dev/UnrealEngine/4.11/Projects/SkookumDemo/Binaries/IOS/Payload/SkookumDemo.app/SkookumDemo because a file with the same name already exists.). The Saved/StageBuilds folder - again - contains the wrong folder structure as described many times.
Can you please try to unpack your ipa? You will see that it is no good because either the executable or the test text file will be missing.

So, the provisioning profile issue is that the Apple World Wide Authority certificate expired. Go to Apple PKI - Apple and download the WWDR certificate that expires in 2023. Double click it and import it to the System keychain, if you haven’t already. The old one expired last Sunday, so that is relatively recent development. As for the StageAsNonUFS, I’ll have a look today. It’s possible something has changed in the last few months since 4.11 and 4.10 were similar which is causing this error.

-Pete

I already see the issue. So that we don’t collide with the executable name, all content is put in cookeddata/gamename. However, the code to copy the NonUFS data is not taking that into account for iOS, so it is putting in the root which collides with the executable. I’ll look into a fix today.

-Pete

Thanks Pete - so I did this, generated new certificates and provisioning profiles but also had to delete the old WWDR certificate from both System and Login keychain for the Keychain to be happy. Unfortunately, now I am getting an error that the bundle identifier “com.YourCompany.[PROJECT_NAME]” does not match my provision profile. Makes sense, so I fixed that in the project settings and set it to “com.agoglabs.[PROJECT_NAME]” which matches the “com.agoglabs.*” of the profile, and confirmed that it is correctly set in DefaultEngine.ini. However I keep getting the error despite fixing this. It continues to claim that my bundle identifier is “com.YourCompany.[PROJECT_NAME]” when it’s not. Tried deleting cooked and staged data but still getting this. Any insight into this would be helpful.