Unable to get xcode project to index appropriate directories - swift

So I had to delete my project and then reclone it from my repository, but when I clone down the project and I open it, other files from some time ago show in there, how is this possible?
Example this is the cloned directory:
But when I open the project, it shows this project structure:
Also it produces the following error when attempting to build the project:
Build input file cannot be found: '/Users/Development/Projects/MapGlider/Application/Utilities/Extensions.swift'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
All help will be appreciated!

The structure of the project as you see it in Xcode is a combination of file system + information about your project in YourProject.xcodeproj/project.pbxproj file. So you have a mismatch between file system and that file, which is typically a result of inaccurate checkin (for example some changes were done directly in file system, and the project was not updated), or a bad merge (developer A did everything right, developer B, or even the same developer on a different branch, overrode those changes incorrectly).
So what you need to do is to fix those errors one by one.
Note: the steps below assume the project is in your control. If you are using some script or tool to generate the project, you will have to address those issues via that tool or script instead.
First, fix the project structure:
Make sure Inspectors on the right side in Xcode are open. Choose File inspector tab
Focus on a folder inside Xcode, and check Name, Location and Full Path of the folder. Especially notice the Full Path, if it's incorrect, change it to a correct one. Here's the example how. Repeat for all folders and files you want to have in the project
Delete all folders and files you don't want to have in the project from Xcode. For example you can delete Extensions which appears as a file in your project, while it's actually a folder. Typically while deleting you should be able to delete them from file system as well if it exists, but if not, you can double check in file system and delete files / folders from there as well.
Add folders and files missing from the project if needed. Follow Add existing files and folders to a project section in the linked page.
Once you cleaned up the project, you need to review / fix all your project targets:
To fix the Project targets
Try to build each target. If it succeeds, most likely everything is resolved (although watch out for runtime errors for resource files - so you may need to test your app to ensure nothing is missing too).
If building a target fails, you will need to see why. For example
if file is missing from the target, but you already added it to the Xcode project, you can add it to the target (see this page).
if file is missing from the target and is not visible in Xcode, go back to step 4 of the previous procedure and add those files to Xcode project, and then add them to the target
if a file is nowhere to find and is not needed, you can delete it from target. If it was needed, then... well, you have a problem and need to locate your missing code in your source repo or rewrite it.

Related

I need Netbeans help. NO project's -src node appears so no source files--only -Libraries node shows

I hope it's OK to ask this here. Netbeans forums isn't responding. If not, I'll delete this or ask for it to be deleted. I'm desperate so I'll face the wrath, if any.
I moved my Netbeans projects folder from one directory node to another to make backing up all my stuff easier. BAD MOVE.
Now when I open a project using Files | Open project (ctrl-shift-O) NO source files appear because there is no "+Source Packages" node to expand.
It looks like this for all projects, e.g. one named GBL:
Projects
-GBL
+Libraries
It doesn't look like this anymore:
Projects
-GBL
+Source Packages (How do I get this back?)
+Libraries
The Netbeans Properties for each project shows me the path it's using. Windows 7 Explorer shows me that the src, build, and nbproject folders contain files and ALL the source files are in the src folder for that path.
What have I done and more importantly what should I do to get back to being able to open a project normally?
(I've tried recreating the original Netbeans folder and using Windows Explorer to copy an entire project folder into it but: same result--all I see is the Libraries node under the project's name node.)
I just tried to Clean (and also Build) to see what would happen. Error:
ant -f C:\\Users\\Dov\\Documents\\NetBeansProjects\\BasicShirt -Dnb.internal.action.name=build jar
C:\Users\Dov\Documents\NetBeansProjects\BasicShirt\nbproject\build-impl.xml:[u]231[/u]:
Must set src.dir
I just Set Configuration by right-clicking the project's name and provided a path to the src folder.
NOW I SEE MY SOURCE FILES BUT NOW THIS line in the .xml file is flagged with similar message:
<fail unless="[u][b]test[/b][/u].src.dir">Must set test.src.dir</fail>
NOW what do I do? (Netbeans 7.4.)
If I could get rid of the 7.4 automatic creation of +Test Packages, I might be OK.
If you can help, I'd be very happy.
(I'm considering re-installing 7.3 if available or removing and reinstalling 7.4 and try to avoid the "testing" requirement, but there goes all my many tweaks of 7.4.)
Well, after considerable frustration with the problem, I solved it, essentially.
It's here, in total. My synopsis plus how it helped me follows. In short, I had to set up a new java project based on existing sources using the New Project Wiz and simply direct Netbeans to the sources.
File > New Project
Choose Java Project with Existing Sources.
Type a (new) project name and ...
... make the Project Folder contains the path to where you want the new project to be stored. (For me, this is the folder where Netbeans has been able to find my sources.)
Click Next for the Existing Sources page of the wizard and ...
5a. ... in the Source Packages Folder pane, click Add Folder and ...
5b. ... navigate to your sources and select the source root folder.
Clicking Next goes to the Includes/Excludes pane, which I didn't need to use.

Could not create bundle folder for versioned model?

I received project from other developer. Then i opened iOS project in Xcode and build it, i got error as below:
Volumes/Macintosh D/My workspace/HCProject/Model/HealthCareModel.xcdatamodeld:0: error:
Could not create bundle folder for versioned model at
'/Users/TomMac/Library/Developer/Xcode/DerivedData/HCProject-bdxarurbgcdbaecxaoocaroetsjt/Build/Products/Debug-iphoneos/HCProject.app/HealthCareModel.momd'
Sorry if this is a basic question,please help me out.
Thanks a lot.
I don't know what causes this but I have experienced this error before.
The simplest way to fix it for me was to delete everything in in the "/Users/TomMac/Library/Developer/Xcode/DerivedData" directory.
There will be multiple directories under here you can probably get away with just deleting the one for the particular project that failed, but I haven't tested this.
I had this same problem after a large Git merge. It turned out I had a duplicate .xcdatamodeld in my Compile Sources. I deleted one and haven't had the problem since.
In case you're not sure where to look, open your project in Xcode and click the project name to view it's properties. Go to the 'Build Phases' tab, then expand the 'Compile Sources' heading.
iOS simulator, Select "iOS Simulator"
Select "Reset Content and Settings"
I had this and I thought I'd got rid of it but it kept coming back every few builds. I now seem to have permanently got rid of it with the following steps:-
Locate the model file in Finder and take a copy of it to another (safe) location.
In Xcode, delete the file from the project (selecting move to trash).
Build the project just to make sure the project file is saved.
Close Xcode.
Locate the derived data directory in Finder and delete everything. (I actually deleted the entire DerivedData directory just to be sure).
Re-open XCode.
Copy the model file back from your safe location to your project directory location.
Drag it into the Xcode project navigator in order to put it back in the project.
Build - it should now work...
I had same issue and got it resolved by deleting content of derived data.
Below is step for the same :
1. Press cmd + comma (,) shortcut key to open preference window of Xcode.
Or Goto Xcode menu on top and select Preference
2. Select Locations tab present in last
3. You can see Derived Data under Locations section
4. Click on small arrow present next to path. This open directory where project’s derived data content is present.
5. Select your project and delete it. Also delete the module cache folder.
Note : You can even delete all content of Derived Data folder.
The content of this folder is generated again when it run. It is like cache.
6. Quit your project
7. Open your project.
8. Clean your project (cmd+shift+k)
9. Build your project. This should build your project with no issues.
I had the same problem this morning. After multiple cleans, Xcode restarts, and finally a system restart, I looked in the system log. I found this error message that corresponded to the time of the build error.
"Interface Builder Cocoa Touch Tool[89487]: BUG in libdispatch client: kevent[EVFILT_VNODE] add: "Bad file descriptor" - 0x9"
I changed permissions on Library/Developer/ folder and granted read/write privileges to "everyone", then restarted Xcode. The build was successful.
I don't know for certain that the build error was caused by a permissions problem but it's worth a try. (If you have a lot of projects in the Developer folder, the permissions change can take several minutes to complete.)
In my case it was a duplicate version of the data model. Right click on the .xcdatamodel file in your project explorer and select "Show in Finder". Check for duplicates and delete them.
In my case I had to follow two steps to get this entirely fixed:
Delete the problematic version's hidden files. Note that FILENAME.xcdatamodeld is a folder and if you browse it you'll see the different versions you have there. The one that gave me the error was still there so I first had to look for hidden files and then delete it.
Clean Xcode's DerivedData folder as suggested by others here.
Hope this helps folks.
In my case my testsFileName.xctest (in workspace > Products > testsFileName.xctest) somehow has the application target as his target membership.

Three20 HEADER_SEARCH_PATHS strange behaviours

In one of my Three20 project, I have the HEADER_SEARCH_PATHS
HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/../three20 $(BUILT_PRODUCTS_DIR)/../../three20
But according to this: https://github.com/facebook/three20
I have must the following line in the path..
../three20/Build/Products/three20
I have re-created a project using ttmodule.py and confirm ../three20/Build/Products/three20 is the default but I am not sure why my existing project left it out.
Now the issue is:
Q. Why the project can build without error (Simulator/Device), what do you think is the reason?
in pre xcode 4 days the build folder would be under the project source directory which made sense to add a search header in a relative manner.
Three20 copies the header files into a specific place as part of a copy build phase.
Since xcode4 is out the build directory moved completely out of the project source tree into a temporary place configured as $(BUILT_PRODUCTS_DIR).
The reason you see 2 directories is because xcode generates 2 different paths for Archive builds and all the other kinds of builds (Run/Debug etc...)
$(BUILT_PRODUCTS_DIR)/../three20 $(BUILT_PRODUCTS_DIR)/../../three20
Notice that the manual instruction tells you to find that directory but it doesn't tell you where it is:
Finally, we need to tell your project where to find the Three20 headers. Open your "Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click it. Add the relative path from your project's directory to the "three20/Build/Products/three20" directory.

Resources check

hey I am frequently uploading my XCode iPhone projects to an svn repository to be build on another machine.
My problem is that when I add resources to my project sometimes I forget to add the resource as relative to the project.
I know one answer is to be more careful (not easy when your tired!) but if there was a way to run a script to check my resource paths are relative when I build and warn me if they are not it would be a great time saver for me.
How would I go about doing this?
Thanks
Chris
You can select all the files in your project and set the Path Type for all of them in one go. While this isn't a script this does save a lot of time over doing the files individually
I think the best approach to script this would be to look in the .xcodeproj file - the file paths are listed in there. If your project is called MyProject you need to open (either by using Show Package Contents in Finder or just the usual cd in Terminal) the MyProject.xcodeproj directory.
In here you'll find a file called project.pbxproj - open this in a editor that won't mess up your formatting and have a peek around the file. If you search for one of your files in the project you should be able to see how Xcode stores references to the project files.
Look for a section named /* Begin PBXFileReference section */. In here all your files are listed, along with where they are relative to the project, e.g.:
... path = Classes/MyClass.h; sourceTree = SOURCE_ROOT
If you can parse this file you should be able to acheive what you want - but remember to back up the file, otherwise you might corrupt your project.
How would it be if you instead write a script that asks the SCM if anything in the project is not committed? For example, think of this scenario
Project Root
Codex
Project.xcodeproj
…
Design
anImage.png
where anImage.png being outside of Codex, where the Xcode project sits (its path starts with a ../). A strong .pbxproj parser would have to support all the variants in which Xcode references files to know exactly if there are stray files.
OTOH, the SCM knows where everything is all the time (you mentioned up-ping to a SVN server), so why not ask it instead.
We have a Ruby script that prints a warning in Xcode’s Build Log if anything in the project is not committed.

Why are static library headers not found?

I've used Clint Harris' tutorial to set up code sharing between projects, and everything works just as expected on my computer. But on my co-worker's machine, it seems the compiler doesn't find the header file from the static library project when he builds.
My co-worker got my project by cloning a git repository. We've gone through all relevant build flags and XCode settings n times, but the project simply refuses to compile on his machine.
This is what I asked my co-worker to do, mostly copied and pasted from the tutorial:
Make sure there is NO blank space in the complete path to the projects' directory.
Inside the projects directory, create another folder called "build_output".
In XCode, under “XCode > Preferences" choose the "Building” tab and set “Place Build Projects in” to “Customized location” and specify the path to the common build directory you created.
Set “Place Intermediate Build Files in” to “With build products.”
Choose the “Source Trees” tab and create a new Source Tree variable by clicking on the “+” button and filling in the columns. In both "Setting Name" and "Display Name", put
[the name of the shared project which created the static library]. In path, you put the full path to the framework folder.
Following these steps, the project that uses the static library should compile the same on his machine as on mine. But it doesn't. Basically, the error he gets is:
error: TheFrameworkHeader.h: No such file or directory
and then a string of other errors caused by the missing header.
Any strategies for trouble-shooting this? Or anyone who had a similar experience and could share some hard-earned knowledge? Is anything missing from the instructions I've summarized? Do I need to set the roles of headers in the Copy Headers build phase when compiling a static library?
Despite some helpful advice, I never figured this one out, but here's a little info for anyone in a similar situation. I created the library and dependent project by splitting an original project into two. At first, the library and application were just two targets within the same project. Later, I moved the app to a separate project. Everything seemed to work, and I pushed both projects to remote git repositories. When these were cloned on other computers, however, the library headers were not found.
Later, I discover that the same error occurred when I cloned the projects on the original computer. After a lot of struggle, I pinned it down to one scary detail: the name of the dependent project's folder! (That is, the project with the application, not the library.) Not the name of the .xcodeproject package, not the application identifier, but the name of the containing folder. As soon as I change that, everything works. If I change it back to the original name (on any computer), again the headers are not found.
If anyone has any insight on this, please post an answer!
EDIT: Since I posted this, the same problem occured with another project, and again, merely renaming the folder that contains the .xcodeproject folder fixed the problem.
I don't think it is Git, I think it's xcode. I got a very similar problem here, where xcode / xcodebuild resolves an include path falsely (making it a simple .) With the exactly the same library project and xcconfig files (clean checkout from svn repo) but another containing folder - it works. So, thanx for the solution and don't blame Git anymore ;-)
I often forget to check this: are you sure that the missing file (i.e., TheFrameWorkHeader.h" is in the git repository? It may well be that your build settings are correct, but the file somehow did not get added to git correctly.
If you're having trouble building on a particular machine, then the problem likely is a machine or user setting. Such as an environment variable (perhaps INCLUDE_PATH or one of its relatives -- XCode uses GCC). You may have a "." in one of these variables.
The best way to fix this would be to add the needed folder path to the -I switch in the build script.
Double check that the "Search Paths->User Header Search Paths" build setting (for all configurations) points to the directory containing the shared Xcode project (you can use the new Source Tree variable you created).