'Build input file cannot be found' Swift 4.2, Xcode 10.0

SwiftXcodeXcode11Xcode10Xcode12

Swift Problem Overview


I am getting the following error when building in Xcode 10.0 with swift 4.2:

This is the error

Swift Solutions


Solution 1 - Swift

Moving the folders around the inspector can cause the error "Build input file cannot be found"

SWIFT 5

In Swift 5, the error came up but the identity showed no errors.

  • Go under build settings and select packaging.
  • Delete the current paths for Debug and Release and enter your new path where the info.plist is kept.

For example [APPROJECTNAME]/[THEINFOPLISTFOLDER]/info.plist In the screenshot below, the path is API-client/Resources/info.plist

enter image description here

SWIFT 4

To fix it, go to the general tab and under identity reselect the info.plist that you like

enter image description here

enter image description here

I hope this helps

Solution 2 - Swift

Build input file cannot be found

How To fix This issue :

  1. Go in the project-navigator, select your project

  2. Select Build Phases tab

  3. In Compile Sources section, check for the file(s) that Xcode is demanding of

  4. Notice that the file(s) have the wrong path, and delete them by clicking on the minus icon

  5. Re-add the file(s) by clicking the plus icon and search in the project.

  6. Product > Clean Build Folder

  7. Build

Solution 3 - Swift

I got this issue after resolving the conflicts in project.pbxproj.

Step 1: Removing the "Build input files cannot be found" files from BuildPhases -> Copy Bundle resources and adding them back worked for me.

If the above Step 1 doesn't work, search for "Recovered References" folder in your project structure and remove the files that are causing this issue and repeat Step 1

Solution 4 - Swift

A most common error when you move Info.plist in another folder. To fix this error you can select the Info.plist and choose Relevant to Project from file inspector.

enter image description here

Next step, go to Build settings and search for info.plist and fix the file path.

enter image description here

Solution 5 - Swift

For build file missing i.e. info.Plist : Under Project navigator, select(click) Project name and icon,

In middle pane, click target click blue General tab on top click / Targets click [Choose info.plist File] button in pop-up window, select the info.Plist file

Solution 6 - Swift

I had the same problem with a missing view controller file that couldn't be found after cloning a project in a new folder. I deleted the view controller but the compiler continue asking for a file in a path that doesn't exist anymore.

I solved the problem as follows:

  • Select the project target in the Project-navigator,
  • Go to Build Phases tab
  • In Compile Sources section, check for the file that the compiler is asking for. You can filter by the name at the top right of the screen.
  • The deleted file is still on the list with a wrong path, delete it by clicking on the minus icon. You have to do it for all the target you may have.
  • In the case that you still use the file, add it on a new path by clicking the plus icon.
  • Clean Build Folder in the Product Menu.

It should work now :D

(Objective-C Project / Xcode Version 10.2.1 (10E1001))

Solution 7 - Swift

This works if you get the 'Build input file cannot be found error message' and also have files that are red in the inspector:

  1. Open your project folder in Finder

  2. Make a copy of the affected files onto your Desktop

  3. Delete the affected files in Xcode and then close Xcode

  4. Re-Open Xcode and drag your copied files into your Xcode project

This worked for me. Before I got the error message I was re-organising files in the file inspector which gave me that error message and made the files I was moving around turn red. Hope this helps !!

Solution 8 - Swift

Change the build setting to legacy

  1. First, open your project in XCode by double-clicking on ios/<YourApp.xcodeproj>

  2. Then go to File > Project Settings...

  3. Change the Build System to Legacy Build System in Per-User Project Settings:

enter image description here

Solution 9 - Swift

I tried going to Compile Sources in the Build Phases tab and deleting and re-adding the selected file (and cleaning and rebuilding)but it didn't work :( Instead, this following answer worked for me if you get the 'Build input file cannot be found' error message:

  1. Delete the affected files in Xcode (I right-clicked->Delete'd in the Navigator)
  2. Re-add the affected file (mine was .mlmodel) and I selected "Copy items if needed" under Destination.
  3. Cmd-shift-k to clean and then Cmd-b to build and voila! The file was recognized and error gone!

Hope this helps!

Solution 10 - Swift

For me this worked:

Click the app name under TARGETS

Build Settings -> Packaging -> Info.plist File

There change the file location of the Info.plist File to the new location.

DemoApp/Info.plist to DemoApp/Assets/Info.plist

enter image description here

Solution 11 - Swift

I got this error when I moved my Info.plist into a folder.

When I took Info.plist out of the folder, I no longer got an error.

Solution 12 - Swift

Select general tab and under identity select the info.plist you want for your development

Solution 13 - Swift

For me something totally different worked:

Go to Target>Build Settings>Architectures

My valid architectures before: arm64 arm64e armv7 armv7s (Defaults)

Changed it to: armv7 i386 arm64 armv7s

Solution 14 - Swift

In my case I got this error when I renamed a ViewController name using Refactor. The view controller name occurrences were changed but the real file not.

I tried to do what @ajji said but it didn't work. So I changed the name of the real file. After that all worked like a charm

Solution 15 - Swift

If your file(s) - that couldn't find - icon color is pale. And you right click on it and "Show in Finder" does not open Finder. It means your file name is not same as what you see in the Navigator. How icons of your files show in normal and pale mode

to Solve it, go to where your file exist, and change its name to be same as what you see in the Navigator.

Solution 16 - Swift

If all else fails:

  1. In Xcode. Remove references of files in question from your project.
  2. Open your project.pbxproj file as a file in Xcode. This is in .xcodeproj
  3. Delete all lines containing the name of said files. Save.
  4. Back in Xcode. Re-add files to your project in Xcode.

Solution 17 - Swift

In my case the file wasn't at the right path, Xcode was expecting to find the input file at a path like /Users/Malloc/Projects/MyProject/Info.plist while in reality the file was located at a different path like /Users/Malloc/Projects/MyProject/Subfolder/Info.plist.

A quick fix to this is to simply right click on the file then select Show in Finder, then drag the file to the correct path Xcode is expecting.

Solution 18 - Swift

I got this error when i renamed a ViewController name using "Refactor". The view controller name occurrences were changed but an old reference was somewhere still existing.

> Deleting derived data & Clean build folder worked for me.

Here's how to delete Derived data:

File>Workspace settings> Click arrow & remove all folders inside Derived Data.

Solution 19 - Swift

I also faced same issue while building my xcode project - "Build input file cannot be found:" Cause: I renamed my entire project but not the build setting. Solution: In my project's build setting--> Packaging, I updated the path of the info.plist file. Now working fine.

Solution 20 - Swift

  • Goto Project Navigator.
  • Click on project.
  • Click on Targets.
  • Goto Build Settings.
  • Search Prefix.pch.
  • Change the location of this file (input the updated location).

This will resolve the issue as mine.

Solution 21 - Swift

Had the same problem with swift files. Select files that are not recognised and Delete with Remove Reference option. Right click in the folder and Add files again.

Solution 22 - Swift

In some cases, if you Refactor your existing ViewController files or any other files using right-click -> Refactor option within the Xcode workspace then on compiling this error will come since the File name is not changed in original place but reference is updated, so in that you need to also manually change the old file to new name.

Solution 23 - Swift

When I checked out the code first time from the Git I faced the same issue for few pod file. Updating the pod file solved my issue.

  1. Open the project folder in the terminal window
  2. Run 'pod update'
  3. Clean the XCode and run.

Solution 24 - Swift

I just had to open the project in finder and drag/drop the appropriate files in the project folder

Solution 25 - Swift

Build input file cannot be found

How to fix this issue?

My Approach:

  1. 1.From Project Navigator ->Files ->Add Files to Lowes ->In Finder View, check to which folder this lost referenced file is moved to and check with your team members if anyone moved it for a reason.If it occurred by mistake then follow below steps

    2.From Project navigator, directly tap on the file which is causing issue.This is the same file that XCode shows as not found in error .So clearly this file has lost reference and we need to restore it back

    3.The Swift bird folder icon appears in light red color which is an indication of lost reference

    4.Right click on it and Delete it

    5.Next from Project navigator -> Files ->Add Files to Lowes -> Finder View go to the folder where this referenced file is moved to and tap on ADD button in popup window

    6.Now if you look at the Project Navigator this file swift bird icon appears in bright red , but you will also find an extra file with the same name at the top of the Project Navigator

    7.Make sure you have this file in the right folder if not move it to right folder

    8.Now right click to delete the very top redundant file, here do not select " Move to Trash" option.Just select "Remove References" option

This fixed my issue.

Solution 26 - Swift

Adjust the file path according to that provided in the Xcode Error

Solution 27 - Swift

Solution 28 - Swift

Update for Projects w/ Swift Packages

How did the errors happen?

I ran into this issue when I had imported Swift Packages into my project but later cleaned DerivedData to fix an unrelated app caching issue. My existing project was not a local Swift Package but an iOS app project.

Note that we can still encounter the same issue in local Swift Package projects.

What is the reason for the errors?

Swift Packages are checked out into DerivedData and are not referenced from the ModuleCache.noindex subfolder. Thus, cleaning the app's folder in DerivedData or DerivedData itself breaks dependency resolution within Xcode for Swift Packages.

This is a misleading build error since there may be nothing wrong with the app code you've written or your dependency resolution graph. The only thing required is to refresh the dependencies.

How can I resolve the build errors?

Xcode now has nice options within the IDE itself to resolve Swift Packages. These options trigger a new checkout into DerivedData:

enter image description here

We can use three options, as shown in the image above depending on our use case:

  1. Reset Package Caches: Trigger a re-install of your existing Package dependencies w/ same versions.
  2. Resolve Package Versions: Use this option for updating Package checkouts when fixing Package Versions for cross-compatibility (in Project Settings).
  3. Update to Latest Package Versions: Use this to update all Swift Package dependencies to the latest versions. This option may be a local breaking change if the API changes.

NOTE: Apple's documentation recommends to use Xcode for dependency resolution when working with Xcode projects excluding CLTs.

Other solutions

  1. We can also fix the error by restarting Xcode, but I find this step breaks my workflow and is tedious.

  2. If we are running from the command line (local Swift Package executable), we can stick with a swift build variant without jumping to Xcode at all (Source). swift build doesn't work as easily out of the box in other projects, however.

  3. Use xcodebuild:

    xcodebuild -resolvePackageDependencies
    

I prefer staying in Xcode for simplicity but YMMV.

Solution 29 - Swift

My issue was a missing SettingsController file.

I copied a file from projectA to projectB but forgot to tick Copy items if needed. Unbeknownst to me a couple of weeks later when I deleted projectA the SettingsController file in projectB got deleted along with it. Afterwards in projectB the error Build input file cannot be found ... path/Folder/toSomeFile was shown.

To fix it I closed Xcode, went to the main folder that it was in, opened the folder and right clicked on the blue Xcode icon with the extension .xcodeproj, then I choose Show Package Contents

enter image description here

From there I double clicked on the project.pbxproj icon

enter image description here

Once the project.pbxproj file was opened I pressed command+f and in the search field I entered the path part of the error path/Folder/toSomeFile

It took me to 1-2 lines of code that looked like this

enter image description here

Once I deleted those 1-2 lines, when I went back to the projectB and opened it the error was gone.

Just for a little more clarity the exact path of the error was whogotgame_42/whogotgame/Controllers/SettingsController.swift. So that is what I exactly entered in the project.pbxproj search field to get to those 1-2 lines that you see in the picture.

Solution 30 - Swift

I got this error when I put the Info.plist file inside a folder. Then when I extracted the file to public view, the error went away.

Solution 31 - Swift

You can use $(INFOSTRINGS_PATH)

It's Bundle file path. Specifies the file that contains the bundle’s localized strings file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobbie CroninView Question on Stackoverflow
Solution 1 - SwiftSTerrierView Answer on Stackoverflow
Solution 2 - SwiftM MurtezaView Answer on Stackoverflow
Solution 3 - SwiftDurga VundavalliView Answer on Stackoverflow
Solution 4 - SwiftRashid LatifView Answer on Stackoverflow
Solution 5 - SwiftMohanSView Answer on Stackoverflow
Solution 6 - SwiftL33MURView Answer on Stackoverflow
Solution 7 - SwiftJames.devView Answer on Stackoverflow
Solution 8 - SwiftSunil TargeView Answer on Stackoverflow
Solution 9 - SwiftlizziepikaView Answer on Stackoverflow
Solution 10 - SwiftNilanshu JaiswalView Answer on Stackoverflow
Solution 11 - SwiftS. CarrView Answer on Stackoverflow
Solution 12 - SwiftMahadhi Hassan ChowdhuryView Answer on Stackoverflow
Solution 13 - SwiftAmritpalView Answer on Stackoverflow
Solution 14 - SwiftJorge CasariegoView Answer on Stackoverflow
Solution 15 - SwiftEsmaeilView Answer on Stackoverflow
Solution 16 - SwiftMartin BergerView Answer on Stackoverflow
Solution 17 - SwiftMallocView Answer on Stackoverflow
Solution 18 - SwiftAjjiView Answer on Stackoverflow
Solution 19 - SwiftKavya JoshiView Answer on Stackoverflow
Solution 20 - SwiftSyed Faizan AhmedView Answer on Stackoverflow
Solution 21 - SwifttoxicsunView Answer on Stackoverflow
Solution 22 - Swiftvikas kumarView Answer on Stackoverflow
Solution 23 - SwiftSoumenView Answer on Stackoverflow
Solution 24 - SwiftgrantespoView Answer on Stackoverflow
Solution 25 - SwiftAnila KasturiView Answer on Stackoverflow
Solution 26 - SwiftMalik Mussabeheen NoorView Answer on Stackoverflow
Solution 27 - SwiftM.M.View Answer on Stackoverflow
Solution 28 - SwiftPranav KasettiView Answer on Stackoverflow
Solution 29 - SwiftLance SamariaView Answer on Stackoverflow
Solution 30 - SwiftMuaz Talha BULUTView Answer on Stackoverflow
Solution 31 - SwiftahmeturhanView Answer on Stackoverflow