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.
Try to switch back to the Legacy Build System (File > Project Settings > Workspace Settings > Legacy Build System)
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.
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.
Just check the path to .plist file in Build Settings of your target
Funnily, closing Xcode and reopening it might also be enough.
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
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:
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"
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.
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.
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 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.
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.
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
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.
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.
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.
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.
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.
In my situation I somehow had multiple files/images that were being referenced as described below:
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 !
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
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.
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.
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.
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.
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.
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.
In my case I accidentally deleted one third-party xcodeproj folder I used in my app.
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".
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.
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).
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:
With that setting, worked for me. Before I had "Copy plist".
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.
Random, for Cocoapods: I hadn't added my test target to my Podfile.
Related
I have folder where i store all my projects. I have problem with one of them.
All projects except this have projectname.xcodeproj file.
When i open Xcode i see this project - it has icon with white background (other have blue background). I can open it, build and run.
I can't find this .xcodeproj file - so i can't run pod init in terminal for this folder. I See error "No xcode project found, please specify one".
I don't use git. Searching for this file had no results. What else can i do?
I think you may have changed the path for the specific project you're experiencing problems with. Try to create another project and just copy/paste the files from the old project into the new one and reference the new project.
Using Xcode 4.5.2
I occasionally want to rename a project all the way through the project without leaving obvious folder name atavisms from previous versions in the project 's file system.
The usual instructions for renaming an Xcode project do not accomplish this. I have read them and done them many times. They only go so far. They leave the main directory (at the same level as the .xcode.proj file) with the ORIGINAL project name. Call me persnickety but I don't like that. So I endeavor to change it as follows.
I begin with the usual instructions, then attempt to rename the remaining original folder name both in Xcode and in Finder. It ends badly. Here are the steps I follow. It should be reproducible.
We will attempt to change a project named "JoeSchmoe" to "JoeSchmoe_1".
Do the Usual Project Rename Procedure
Create a new Xcode Utility project, named: "JoeSchmoe". Use Storyboards and ARC.
Build, run, and test functionality to verify that everything is OK. It is. Stop.
Hit cmd-shift-J
Open the Utilities panel on the right
Under Identity, change project name to "JoeSchmoe_1". Xcode will ask you, "Rename content project items?" Click "Rename"
Build. It should succeed. And it does.
The Problem
In the Project Navigator, notice that the main folder in the project is still named "JoeSchmoe"!
Change the name of that folder to JoeSchmoe_1
Build. It should succeed. And it does. We're done, right? Well let's look at the project's file system.
Quit Xcode
In Finder, open the folder containing the newly renamed and working "JoeSchmoe_1.xcode.proj"
(Its containing folder is still named "JoeSchmoe". That's ok for now. We could change it to anything without affecting Xcode, so long as it contains the .xcode.proj file and associated files and directories. We leave it alone.)
In that directory (at the same level as the JoeSchmoe_1.xcode.proj file), notice that the main project folder is also still named "JoeSchmoe" !!
Change the name of this "JoeSchmoe" folder to "JoeSchmoe_1". (We expect this to break the project because we know Xcode will still be looking for the "JoeSchmoe" folder, since it didn't change it for us.)
Start Xcode
Build. It fails, as expected.
Notice that all the filenames in the Project Navigator are now red colored, meaning files not found. (We expected this. Now we want to fix it.)
In the Project Navigator, select the project (top icon), then Target -> Build Settings -> Packaging -> Info.plist File.
Notice the file pathname in the Info.plist File settings row is named: JoeSchmoe/JoeSchmoe_1-Info.plist !! The directory still has the old project name. But in the file system we just changed it. So let's make this the same as what's in the filesystem.
Change its name to JoeSchmoe_1/JoeSchmoe_1-Info.plist
Re-Verify that the directoryname/filenames are identical in the file system and what you have in your Xcode Packaging -> Info.plist setting.
If they are, the project should build. Right?
It Fails. And all of the project files are in red (meaning not found).
Try cleaning the project (Product menu -> Clean),
Quit Xcode, Restart and Build.
It Fails, as before.
At this point I don't have a theory as to why it fails, other than to assume that there is an Xcode setting that needs to be changed somewhere that I haven't yet discovered. Looked all around for it. I'm stumped.
What am I missing?
Since they got rid of the feature that was in Xcode 3 to easily change your project name, it's been a pain in the butt to do manually. I found a great app in the mac strore Project Duplicator for Xcode 4 that copies your project and lets you name it whatever you want. I've been using it for a while now and have never had an issue with it, and it was only $1 when I purchased it.
GW
The last thing I had to change when renaming a project, including the finder folders, is the setting under "Build Settings->Prefix Header". It was still pointing to a finder folder that no longer existed and the compiler would throw on a file not found error.
Once I changed this to my new inner project folder, it all worked fine and I've been able to build the project as expected.
See this answer for fixing the problem manually
Renaming xcode 4 project and the actual folder
I'm getting interface re-declaration errors when I'm trying to build because xcode keeps referencing these old frameworks and headers that I've already removed from the project. I've sifted through my build phases and build settings and nothing seems to point to those files.
The funny thing is when xcode shows me my error and the line of code where the interface is supposedly redeclared, it won't show me any specific file when I click "Show in project navigator". However, if I ask it to "Show in finder", it instantly locates the file in my actual project directory (not xcode project directory). So this means that XCode is picking up unwanted frameworks that I've left in my project directory. I don't want XCode to do this. How do I clean this up? I've tried cleaning, restarting xcode and rebooting.
I looked at another SO discussion with the same problem but the user didn't give a proper solution (http://stackoverflow.com/questions/11759444/xcode-referencing-old-framework). How does one go about disabling the automatic framework searching?
Just in case: have u checked FRAMEWORK_SEARCH_PATHS ? (Project Build Settings). I had a similar situation and found there references to the old paths which I removed and that did the trick.
ADDITION:
As I moved my Xcode-Project to another location the compiler complained about "Library Search Paths" which where pointing to the old location.
See => Build Settings, "Library Search Paths".
In my project, I've include a full "shared" folder by link (not copy) that is outside my project folder.
In the .pch file, I have #import "MyStandardHeader.h"
My Build settings does not have any search path to the "shared" folder.
In the "MyStandardHeader.h", I have #import "NSMutableArrayCustom.h" that is inside a subfolder of "shared".
I use in my code a NSMutableArrayCustom class.
I never include NSMutableArrayCustom.h
I've clean the project, quitted XCode, launched it again, build, run on both iPhone and simulator : everything works fine, but I have a red compile error: MyStandardHeader.h - No such file or directory
I've tried in the build settings Always search user pathat YES and NO, it's the same.
What is the problem? Why do I have this error? How make it disappear?
I tried the steps mentioned above, but to fix the error I had to remove the file from "Copy Bundle Resources" in the project "Build Phases".
I've seen this too: files that clearly exist get wonky. Oddly, sometimes it fixes itself. It may be an Xcode bug, since the build always succeeds. I've had success with touching the file. sometimes a clean helps. and sometimes quitting xcode helps.... Voodoo really.
You could try to remove the index by deleting everything in ~/Library/Developer/Xcode/DerivedData
That directory is a combined version of the old Build and Intermediates directories from Xcode 1,2 and 3. Basically it's all the temporary and generated files from your project: object files, indexes, etc.
Another thing to try -- just deleting Derived Data wasn't working for me, but this did:
Delete Derived Data using the Organizer window, Projects tab.
In your target settings delete the value (path) set for "Prefix Header"
Close XCode and restart. Reload your project. Let it re-index.
Restore the "Prefix Header" setting.
What a major PITA.
If deleting data and Prefix Header path doesn't work then, try to click on the File (that is not found) in the Project Navigator and uncheck the target under Target Membership in File Inspector. Then deleted the files from Project Project Navigator and add again. This is the only thing that worked for me.
Merely closing XCode (6.4) fixed my particular case of this issue. I opened it back up, cleaned the project, and built. Warnings were gone! Before I closed XCode, I cleaned and built and the warnings would not leave. So something about closing XCode did it. Hope this helps others!
I deleted the #import, then moved to a different line and used autocomplete to reenter the import. That error and all others like it disappeared. Strange bug.
As I write most of my code using MacVIM, I need to add the new files to the XCode project in order to compile them into the executable. Today however I encountered an implementation file (.m) which XCode won't allow to be added. It appears light gray in the appropriate finder window as if it were already included in the project, but when I try to build, I get a linker error, stating that the symbol defined this implementation file could not be found. The corresponding header file could be added without problems.
Any idea what could have caused this problem?
Btw. I deleted a former version of the same file from the "Classes" tree before, as well as many others which were successfully re-added.
I think I saw a similar problem once with an old version of Xcode. IIRC the way I resolved it was to:
rename the source file (temporarily)
add the renamed file to the project
do a "Save As..." on the renamed file to get it back to the original name
The file is probably already in your project, but not in the target you're building. Use the Detail view and Search bubble to find it, Get Info, and in the Targets tab of the info window, check the check box for the target you're building.
The other answer (removing and re-adding) works because you end up removing it from the project, then when you re-add it, it's added to the current target by default.
I found that deleting my pbxuser file from inside the .xcodeproj solved the problem for me. There were references to the files I couldn't add in there, surprisingly. This has happened to me many times over the years.
Another trick is to:
Move the file into a different directory
Add it to the XCode project from there
Move it to the desired location
Select the file in Groups & Files
Choose File > Get Info from the menu bar. The full path will appear in red.
Press the Choose... button and select the file at the new location.
If you are using Xcode 4, you can do the following steps to add an existing file into your target:
1) Select your file in "Project navigator" view (aka. click your myfile.m file in the folder tree of Xcode)
2) Click menu item "View" => "Utilities" => "Show File inspector" (or use the shortcut "Alt + Command + 1)
3) There is one section called "Target Membership", check the target you want
I fixed this by deleting the .xcuserstate file and restarting the project. I am using a workspace file, for all it's worth.
You can find any and all referencing files via
grep -r -h [NameOfFileThatYouAreTryingToAdd] *
from within your project directory.