xcodebuild linking error fille cannot be open()ed, errno=2

I very recently migrated our project on Swift 6. After fixing every issues, mostly due to Swift Concurrency, I’m getting the following error when compiling with Xcode 16.0, which doesn’t make any sense to me :

Multiple errors: file cannot be open()ed, errno=2 
path=/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/Router.o in '/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/Router.o'; 

file cannot be open()ed, errno=2
path=/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AccountRouter.o in '/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AccountRouter.o'; 

file cannot be open()ed, errno=2 
path=/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AlertRouter.o in '/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AlertRouter.o'; 

file cannot be open()ed, errno=2 
path=/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AlarmRouter.o in '/Users/.../Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/AlarmRouter.o'

(The '…’ is just me obfuscating the real name)

I’ve checked the paths. The file are here and I can open them.

I tried cleaning the project, removing every derived data. I removed every dependencies (cocoapods & SPM). I’m using Tuist, so I fully cleaned the project and recreated it from scratch. Then I thought it might be an issue with my Xcode installation, so I tried running the project on another machine, I still get the same error every time.

Anyone has a clue on what’s happening?

Well, that’s a weird one. You’ve already done most of the first debugging steps that I’d recommend.

In this context error 2 is ENOENT, which pretty darned clear: Some program, probably the linker, is trying to open a file and it’s not present. Except that it is.

If you create a new test project from Xcode’s built-in in {mac,i,tv,watch,vision}OS > App template, does it have the same issue. Make sure to do that directly from Xcode, not using Tuist.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@DTS Engineer Well, the files are missing … how can it be missing if the compilation went well? I’d expect the compiler to fail before.

I tried compiling directly with xcodebuild to see if I can see something not showing up in xcode, but no luck.

Well, the files are missing

Huh? Earlier you wrote:

I’ve checked the paths. The file are here and I can open them.

which suggests that the file are present. Did I misinterpret your original post?

Did you run the test project exercise I outlined in my previous post?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Sorry for the misunderstanding, my bad. When I wrote the post, the files were here. Then I tried again cleaning everything, compiled again, then the files were missing. I forgot to specify that in my previous comment ^^

I realized that sometimes the error message changes slightly. Instead of showing these four files, it’d only show some of them. For example, I just modified the file Router.swift. Compiled again and the error message became :

File cannot be open()ed, errno=2 path=/Users/MyUser/Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/Router.o in '/Users/MyUser/Library/Developer/Xcode/DerivedData/MyApp-euxwyncffackymerzuntbjccezyq/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/Router.o'

Yes I ran the test and it compiled properly.

encountering the same error with XCode 15.4, ios-only project re-generated every time by Tuist and all code in Swift Packages under version 5.10.

the build goes well, tests is good too, but archiving for Debug configuration throws op error on ld for one of our feature packages to application's notification extension. archiving for Release configuration unexpectedly works like a charm 🤧

I can add that this error is not a complete blocker — if i'll retry enough it will pass on our CI after a few attempts.

tried to archive failing package in Debug on my machine — works okay.

the .o files are present in ArchiveIntermediates of notification extension product after every try. if i can provide some more context to help resolving this issue — hit me up

os-only project re-generated every time by Tuist and all code in Swift Packages under version 5.10

@oiuhr I thought the problem wouldn’t come from Tuist, but the fact you’re having a similar issue and you’re using Tuist makes me wondering now. Can you tell me which version of Tuist you’re using ?

I’ll reach out to the Tuist team.

We're using Tuist v4.21.1 for all of our projects, but only one fails in a way you described.

Currently I'm researching if Tuist is a root of problem by generating project with no Tuist optimizations / creating plain project by bare hands, I'll keep you updated

@oiuhr I had a chat with the Tuist team.

It doesn’t seem to be related to Tuist, but let us know if you find anything. I’ll keep looking as well :) Thanks!

Any resolution of this ? I have just hit this problem after using Xcode 16 for a few days to build a project. Suddenly this morning I started getting this same error about missing files from the linker.

OK this line of code seems to have tripped Xcode up resulting in the above errors

DebugLog("No planogram fixtures for \(level.store.code).\(\(level.store.number))")

Note that the typo wrapping the 'level.store.number' twice - coupled with the fact that number is not a property on store seems to have been enough to confuse the compiler as no compiler error was being shown.

Not sure why that code error suddenly started showing up now which allowed me to fix it.

Seems the error above is indicating that some source file has failed to build so start by tracking down the file and look for the code error the compiler hasn't been displaying an error for.

xcodebuild linking error fille cannot be open()ed, errno=2
 
 
Q