Problems adding Projects to Workspace in Xcode 4 - xcode

I have a couple of projects that I had started under Xcode 3.2.x some time ago. I switched to Xcode 4 a few days ago and want to make use of the Workspace feature as both projects. Basically, my plan is to extract some common features out of the two projects and make them a common library that both projects depend on. However, before I even get to the tricky bit of dependencies I get stuck just adding my two projects to the workspace.
I tried creating a new workspace and selecting "Adding files to " from the context menu; I then select the .xcodeproj file from my first project and it appears in the left-hand side tree browser in my workspace. However, it's just the file, not the project that I get. That is, rather than getting a two-line entry in the tree browser where the first line states the project name and the second line says something like "1 target, iOS SDK 4.3" like in the Apple documentation, I get a single line simply stating the name of the .xcodeproj file including the extension. There is also no triangle on the left to expand the node. It's like I just dragged some file in the workspace, not a project. The same goes for the second project.
I have also created a new Project "Foo" from scratch in Xcode 4 and added it to my workspace, with the same result. I looked at Apple documentation and watched the 16 second video about a dozen times now, but cannot work out what I am doing wrong (if the problem is indeed in the chair and not in the computer).

I had this exact same problem. I think it stems from having another workspace already open referencing the project you want to add. I got it working by:
shutdown xcode completely
double-click the workspace to launch Xcode and open just that workspace
drag and drop the project file from the Finder
Worked fine. I have many workspaces all referencing an openssl project, and it seems to work OK when you only have one workspace open at a time in Xcode.

Actually, I made it work without exiting Xcode.
All you have to do is make sure the projects you want to add are closed, since Xcode is having trouble adding open projects to a workspace.
So:
Close the projects you want to add
In the Workspace window, choose "Add Files to MyWorkspace"
Add the .xcodeproj file of the project you want to add

I had the same problem. SO I just exit xcode, restart it. Then I can see the files under the project.

Exiting Xcode completely and then double-clicking the .xcodeproj file to open the project.

It works but when you add an activity to the project than r.java file is automatically removed and errors are coming.

Related

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.
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.

Rename Xcode Project Doesn't Change Filesystem Project Folder Name - Not A Redo of Other Q's

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

Xcode duplicates my repository and renames its location to lowercase

I have a Git repository where my project is linked to. It is located somewhere like /Users/a/Documents/Xcode Projects/MyProject. I use Xcode's UI to commit changes and it worked perfectly for a couple of times. But now, out of a sudden, I get this error when trying to commit new changes:
The working copy myproject could not be reached.
Please verify that the working copy is reachable and try again.
As you can see, the message shows my project's name in lowercase and when I check the Repositories in XCode (File - Source Control - Repositories...). I see there are two, apparently identical, repositories (they both link to the same Origin), but one with the name all in lowercase.
The correct one location is /Users/a/Documents/Xcode Projects/MyProject as I told you. But the duplicated one is supposed to be located in /Users/a/Documents/xcode projects/myproject which, of course, does not exist.
Does anybody know why is this happening? Can anybody help me to delete this duplicated repository and make my project link the correct one? So I can keep using the XCode's UI to commit changes in my code.
I found that Xcode 4.2 can behave in two different ways depending on what exactly you select in the File->Open dialog, when opening the project from within Xcode:
The .xcodeproj file
The project folder (containing the .xcodeproj file)
Selecting 1 or 2 and pressing enter wil give me two different repositories with different paths in Xcode's Repositories, so sometimes it helps to close the project, delete both repositories and then open the project in "the right way", say 1 or 2.
I had the same problem. You probably clicked the recent opened project offered at the beginning of Xcode screen. I chose to open the project/workspace from manual selection in the file system and it solved this duplicated working copy issue. Hope it could be a help.

Xcode 4.2 Product -> Run Greyed Out

My "Run" button under "Product" is greyed out and after trying a few things from various forums, can't figure out what's gone wrong.
I've tried removing the project.xcworkspace and xcuserdata files and letting xcode generate new ones, but no...
My co-worker uses AppCode from IntelliJ and when he pulls the code, it runs just fine. But if he opens the same files in his Xcode, his "Run" is also greyed out.
"Edit" your current "Scheme":
Make sure you have "Run" checked for that build target:
The scheme need to be fixed (I don't know why xcode changed it)
Here are the required steps:
, ,
Make sure you have the correct target selected.
(Upper-left in Xcode window, near the triangular Run button.)
My co-worker who uses AppCode had edited the configuration file, moved some frameworks around, etc... We noticed that there was a difference between XCode and AppCode in using relative vs. absolute paths in the project.pbxproj file.
Ultimately I just reverted the code to before his changes, so at this stage, I'm not entirely sure which difference in the config file actually caused Xcode to not be able to Run the project.
**EDIT
From the .git logs, it looks like AppCode was adding relative directories with 7 sets of "/../" and before there were only ever instances of 5 "/../" to get back to the root directory.
Rather frustrating that Xcode had no way of dealing with this from inside the IDE.

want to use Xcode 4 for everything, how to add folder in project navigator?

I'd like to move my web dev editing to Xcode 4 (currently using textmate). I have a couple of simple questions that are clearly a lack of experience on my end.
In Xcode's Project Navigator, how do I add a folder to the shown directory tree? Currently, I add via terminal and do File -> Add Files
Is there any way to tell Xcode to see the file system as the file system and not as references?
a less likely thing:
Is there any way to bring up a console within the context of a folder in project navigator (would like to be able to run grep again small portion or something)?
thx
I can answer the first question. Adding a folder of files to a project is the same as adding individual files. Choose File > Add Files in Xcode. When you add a folder of files to a project, you should see something like the following screenshot:
Create groups if you need to access the files in Xcode, such as adding a folder of source code files. Create folder references if you don't need to access the files in Xcode, such as adding a folder of audio files.
You can also add folders to the project navigator by selecting a file or folder in the project navigator, right-clicking, and choosing New Group.
As far as I know, Xcode won't mirror the filesystem as an Xcode tree (anyone correct me id I'm wrong). Wanting to have an identical structure is quite some work. I use to first place the files hierarchically in the file-system, then I mimic the same structure in Xcode.
This requires some attention since Xcode 4.1 not always writes new classes to the place you told him to - they may prefer to land in the highest level of the Xcode project.
I had similar thoughts and started a thread, might be helpful for further reading
Your second question: sorry, can't help you there.

Resources