ChatGPT解决这个技术问题 Extra ChatGPT

Problems after upgrading to Xcode 10: Build input file cannot be found

I upgraded my Xcode SDK to version 10 last night and then find I cannot build.

I'm getting this error:

Build input file cannot be found: '/Users/call01/Library/Developer/Xcode/DerivedData/Comp-Lite-Apps-gytvmossqptokeafrddvvmnlzadk/Build/Products/Debug-iphoneos/SG11.app/SG11

which did not exist before my upgrade and I'm tempted to revert back but would like to stick with version 10 if I can resolve this issue.


S
Sampath

Try to switch back to the Legacy Build System (File > Project Settings > Workspace Settings > Legacy Build System)


Nice. But I am still wondering what is going to happen later? We need to fix our project but how?
@schmidt9 hats off, thank you very much you're a life saver. secondly, I CANNOT believe this new build system was the issue. I've been struggling with this for days. after updating to iOS 12 and XCode 10, automatic signing was broke. I tried everything and even revoked and recreated all certs. and profiles. signing was fixed but the provisioning profile was always NONE. I COULD manually sign the app and it worked, but then the iCloud container and other entitelements were missing from the published app. anyway, fixed my issue. good lord how apple frustrates me with each update. cheers!
This fixed my issue with automatic signing and profiling. but I'm still having trouble with iCloud containers. when I install the app directly to my phone it works fine. I have an iCloud container and use iCloud documents to attaching files from the iCloud storage. but when I release the app to TestFlight, it doesn't work. fails silently, as if the iCloud container is not even present in the distributed app's profile. incredibly frustrating.
@Nexus this problem with new build system persists since Apple has launched it (xcode 8 or 9). Sorry did not deal with iCloud containers, cannot say what the problem may be there
@schmidt9 thanks anyway, switching back to Legacy Build System fixed my issue with the automatic signing. but I'm still stuck with my iCloud container T_T
C
Cloud

For Swift files or files that belong to the project such as:

Build input file cannot be found: PATH/TO/FILE/FILE.swift

This issue can happen when files or folders have been removed or moved in the project.

To fix it:

Go in the project-navigator, select your project Select Build Phasestab In Compile Sources section, check for the file(s) that Xcode is complaining of Notice that the file(s) have the wrong path, and delete them by clicking on the minus icon Re-add the file(s) by clicking the plus icon and search in the project. Product > Clean Build Folder Build

You generally find these missing files in the Recovered References folder of Xcode in the project tree (look for the search bar at the bottom-left of Xcode and search for your complaining file):

Deleting them from this folder can also solve the error.


Sometimes when I rename from within XCode, the file in 'Finder' still holds the old name. Locate the file in 'Finder' and rename it to the new name.
K
Krishna Kumar Thakur

For me In Xcode 10, this solution worked like a charm. Just go to the Recovered References folder and remove all files in red color and add it again with proper reference. If Recovered References folder was not found: Check for all missing files in the project (files in red colour) and try to add files references again.

https://i.stack.imgur.com/1nAEF.png


I cannot find "Recovered References" on my project
What do you mean by "add it again with proper reference" after we've removed the red files?
@PrimeTimeTran I meant that You can add those file references again in your project, with drag and drop or copy paste. Just like adding a new file in the project.
@davidmlee I think what this guy means in other words is: "open all of your folders in the project, delete the red stuff, and add it in again." There doesn't need to be a recovered references folder.
T
Tikhonov Aleksandr

Just check the path to .plist file in Build Settings of your target

https://i.stack.imgur.com/chxP6.png


Yep - I'd moved the plist into a separate folder. I think the folders used to be virtual and now they're real (the old blue/yellow folder thing). Either way your answer was spot-on :-)
XCode 13 started showing me the error for the missing Info.plist file and turned out to be this. I had to update the location of the file in the Project's Build settings. Thank you.
M
Mile Dev

This worked for me in Xcode 10:

Click Project icon/name in your Xcode project

Go to General tab

Click [Choose info.plist File] under Identity section

Select the info.Plist file

Check Info tab to see if info.plist was loaded successfully

Build and run


in my case i changed my project folder name and it could not found my info.plist. This worked for me. cheers
d
danielhadar

Funnily, closing Xcode and reopening it might also be enough.


I also deleted derived data, but simply closing/re-opening might have been enough.
I thought this was a Visual Studio way of fixing things... but it worked for me.
no way worked for me
d
david m lee

The above solution eventually works for me; however, I need to do some more extra steps to finally make it to compile successfully. (These extra steps were required even on Xcode 9.)

Xcode: File -> Workspace Settings -> Build System: Legacy Build System Xcode: Product -> Clean Rotate to compile thru different emulator types, such as "iPhone 8", "iPhone 8 Plus", etc. (They might fail or might not.) Eventually compile on "Generic iOS Device"


I needed to go through some of these steps to get it working too.
A
Anastasiia Staiko

I fixed this issue this way: go to your project's Build Phases (click on project icon at the top, and then click on Build Phases). Search for your file there. If it's there (it'll be grayed out), delete it. Then clean (shift + alt + command + k), and run! Hope it helps.


d
derbs

This is an architecture problem. Do not change to legacy build system!

I got the same error, but what solved it for me was this:

https://i.stack.imgur.com/XX6QF.png

The top says architectures in VALID_ARCHS are also excluded in EXCLUDED ARCHS. I was messing around with them to get a Swift Package to compile in Xcode 12, and have spent hours on this.

It would compile on the simulator and not on a device.

The Solution:

Go to Build Settings

Ensure "Architectures" contains 1 entry : $(ARCHS_STANDARD)

Ensure there is nothing in "Excluded Architectures"

https://i.stack.imgur.com/o55t8.png

Now scroll right to the bottom of Build Settings.

Make sure the VALID_ARCHS is exactly the same as this screenshot.

The arm stuff is $(ARCHS_STANDARD) again.

If VALID_ARCHS doesn't exist, add it with the + button.

https://i.stack.imgur.com/FL7mw.png

https://i.stack.imgur.com/MLfV3.png

Clean (cmd-shift-K)

Your project should now build perfect on both the simulator and device!

If it doesn't work, you need to make sure all these settings are the same both in your target build settings and the project build settings.

Note, if you have a Mac with Apple silicon, you may not need to do any of this.


How to add VALID_ARCHS in Xcode 12? I cannot find any + button to add it
@PersianBlue It's the + button at the top - not very intuitive! I've added a screenshot to the original post.
I have mac with Apple Silicon. If I try to build the app I am getting the error as Showing All Errors Only Build input file cannot be found: '/Users/name/Library/Developer/Xcode/DerivedData/helloapp-dhdivlzaazbnhtguhlgnkkglsibo/Build/Products/Debug-iphonesimulator/Hello App.app/Hello App'. Any work around for this?
This should be the top answer! Thank you!
I had added arm64 to excluded archs for simulator because it wouldn't work on M1 otherwise, but this seems to be the solution that actually works both simulator and device now. Thank you!!
k
keverly

If the error says it can't find Info.plist and it's looking in the wrong path, do the following:

Select your project from the navigator, then select your target Select "Build Settings" and search "plist" There should be an option called Info.plist File. Change the location to the correct one.


This answer is also applicable if you rename your app folder/structure. Thanks @keverly
B
Ben Gomm

None of the above worked for me, but this did:

Open project in Finder, right click on your .xcodeproj file and show package contents Open project.pbxproj in a text editor Find the reference to your missing file Edit path = "path/to/file.swift" to the actual location on disk and save the file. Rebuild the project


V
Vlad

In my case I had a build script that generated the .app binary (Buck). The Buck build script ran in parallel with Swift Embed build step. Because the .app binary was not generated yet the Swift step would fail.

In my build script I added "$BUILD_PRODUCTS_DIR/$EXECUTABLE_PATH" under "Output Files".

This tells Xcode's New Build System that this script will output the app Binary and in turn Xcode will make sure to synchronize any build steps that depend on this artifact.

https://i.stack.imgur.com/YAUGt.png


m
mfaani

I ran into this error after renaming a file. Somehow Xcode didn't correctly rename the actual file on disk.

So it wasn't able to find the file. Sometimes the files gets highlights with a red text color. At other times the Swift icon in front of the file was getting a gray overlay.

The fix was simple.

Look into the error and see exactly which file it's unable to find.

Select the file that can't be found.

Go to the 'File Inspector'. It's on Xcode's right navigation pane.

Click on the folder icon.

Select the correct file.

Clean build and run it again.


O
Oriol Roma

Open the right navigation pane where your project files exist OR JUST click on cmd + 1. Then search for "Recovered References" folder. Open it and delete all red files, then everything will work so fine.


D
Declan McKenna

I had this happen for building my unit tests. This may have happened because I deleted the example tests.

I removed the Unit test bundle then re-added it as shown in the pictures below and all was well again.

https://i.stack.imgur.com/MkihP.png

https://i.stack.imgur.com/LayOr.png


J
Julian Silvestri

I had a similar issue after upgrading to a new swift version recently. Moving files around caused my xcode project to reference items that were no longer in the project directory giving me the Error Code Build Input File Not Found.

https://i.stack.imgur.com/qoABM.png

In the image above.

Navigate to your Targets page.

Then Click on the Build Phases tab on the top.

Scroll Down to Copy Bundle Resources

Find the affected files and remove them. (hit delete on them or select them and hit the minus button )

It was in here that I somehow had multiple files and images that were being referenced from other folders and the build would fail as they could no longer find them. And I could not find them either! or how Xcode was still referencing them

I hope this helps someone else !


A
Aditya A.Rajan

This worked for me

try deleting the red colored files delete the files in derived data clean the build folder then try building by using "new build system" from file->workspace settings


e
egabor

I had the same issue. The problem was that I didn't have any file under the Target > Build Phases > Compile Sources. The problem was solved after I added at leas one file to Compile Sources.


m
mfaani

Not that I did anything wrong, but I ran into this issue for a completely different reason and kinda know what caused this.

I previously used finder and dragged a file into my project's directory/folder. I didn't drag into Xcode. To make Xcode include that file into the project, I had to drag it into Xcode myself later again.

But when I switched to a new branch which didn't have that file (nor it needed to), Xcode was giving me this error:

Build input file cannot be found: '/Users/honey/Documents/xp/xpios/powerup/Models Extensions/CGSize+Extension.swift'

I did clean build folder and delete my derived data, but it didn't work until I restarted my Xcode.


A
Arka Mukherjee

In my case, the file (and the directory) that XCode was mentioning was incorrect, and the issue started occurring after a Git merge with a relatively huge branch. To fix the same, I did the following steps:

Searched for the file in the directory system of XCode.

Found the errored file highlighted in red (i.e, it was missing).

Right clicked on the file and removed the file.

I tried building my code again, and voila, it was successful.

I hope these steps help someone out.


f
fredy

What Xcode was complaining about was a XIB file I got it working by going to Project -> Build Phases -> Copy Bundle Resources, removing the "problematic" XIB, cleaning (CMD+Shift+K), building and adding it back again.


x
xskxzr

There is also one possibility that sometimes when you move your files to different folder and especially when you move your info.plist to other folder, you need to define the location of that file. To solve this problem, simply click on your project blue icon on the top, and you will see a button in place of project name and bundle id, click on it and locate the info.plist file there, clean and compile happily.


A
A'sa Dickens

I ran into this problem soon after upgrading to Xcode 10, but that was not the issue.

I tried changing the build system, but that gave me a separate error that meant the same thing. Generally saying "File X can not be found".

There are multiple things to check when a file can not be found.

Recovered references Folder Apple does this nice thing where if it detects a reference to a file that doesn't exists it will add this reference into a group called "Recovered References"

That is nice of Apple but it doesn't always work.

Build Phases Compile Sources In this list, there could be meta data for a file that the project is suppose to compile, but the file does not actually exists and it's attempting to find the file at the given path. In this list it will be dimmed out, delete them and re-add them by toggling the file's target dependencies or manually removing it and dragging it in. File's Path Double check the file path that the error is printing out and the file path for the file in finder. You can easily see this by clicking on the file in Xcode and checking the "Show the file inspector" tab (the left most tab). If these paths are correct then you are good! Dimmed out files in your project that are not in recovered references or red This one pissed me off because it's not obvious about what happened, but basically if you go into finder and move a file to a different location with out updating the reference in the project it will throw the error as the file no longer exists there. The only indication I have found for that is that the file in the "Project Navigator" tab (left most tab) is very slightly dimmed, but when you go to delete this file Xcode doesn't prompt you to delete the reference or send to trash. You can fix this by deleting the file and re-adding it to the project or going to the "File Inspector" tab and click the folder icon next to the path and change it to the proper location.

Either way, the error indicates that it can't find a file, switching to the old build system is a bandaid for a more concrete issue. We as developers understand that a compiler just wants an artifact to be listed at the end of a file path. Somewhere the path is not correct! We have to find where that is!

My issue was resolved with item 4 listed above. Hope this helps somebody.


s
sabiland

In my case I accidentally deleted one third-party xcodeproj folder I used in my app.


K
Konchog

If you tried profiling, and then it didn't work, and now you cannot build, go into your Target pane (via the Project Icon), Switch to the Build Settings tab, search for PROFILE - and set CLANG_USE_OPTIMIZATION_PROFILE to "No".


K
Kwaku Eshun

In my case, I had created a new test target and deleted the default swift file so it was left with just the info.plist. Adding a new file fixed this.


R
Ricardo Barroso

The "Legacy Build System" solution didn't work for me. What worked it was:

Clean project and remove "DerivedData". Remove input files not found from project (only references, don't delete files). Build (=> will generate errors related to missing files). Add files again to project. Build (=> should SUCCEED).


P
P. LoThaR

I know that this is an old subject, but I found the issue with xcode 12.3 and was related to an error while doing the CopyPlist of the main.Storyboard during compilation.

Actually, changing the build settings to "Legacy Build Setting" worked, but it is deprecated, so I discarded it because is a short term solution.

Check this:

https://i.stack.imgur.com/ov1jJ.png

With that setting, worked for me. Before I had "Copy plist".


T
Tomas Ward

I had deleted a Pod Folder to fix an error. If you're using cocoa pods, run:

pod deintegrate pod install

This should rebuild your pods and all files inside of them.


A
AmitGupta

After struggling with this issue for about 45mins, here is a super easy solution that worked for me.

On the project explorer, click on the file/folder that is in red colour (means project is not able to locate the file) Look at the details tab in the file inspector (generally to the right of the screen - see the attached screenshot) Click on the folder icon and locate the real file/folder in your local machine.

That is it. This should do the trick. Basically help your xcode locate the directories and update the reference cache.

https://i.stack.imgur.com/JU2we.png


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now