This issue is not a major issue but has certainly made the process consume more time. When I build my application, indexing fails in one and only one file (.m file if it matters).
There is not intelligence, no color on global variables and most of the code except for important keywords are black in color. Since there is no intelligence, whenever I need to make changes, I have to see other files for doing the changes.
this happend for me when the file was not included in the target.
Method 1:
- Go to your project (the very first item in the project list) (cmd-1)
- select your target
- open tab Build Phases
- add your .m file in Compile Sources
Method 2:
- select your .m file
- show Utilities Pane (the one on the right side)
- first tab: show the file inspector (cmd-option-1)
- check the target in Target Membership
Here are the steps I follow when I face such a situation :
Clean the project, in Xcode menu Product -> Clean
Close the project
Open Organizer and go to Projects tab, select the project
Remove all derived data (the buttons are on the main view : Derived data and Snapshots)
Remove the project from the list on the left (select it and press backspace)
Finally close Xcode, launch it again and reopen the project
These steps will make Xcode rebuild the index for the whole project.
If indexing fails, try cleaning the product (or entire build folder). If that doesn't help, close Xcode, remove the DerivedData folder (you can find the location in the preferences "Locations" tab), and start Xcode again.
The indexing process will then try to re-index your files.
Hmm. Considering the normal Clean or Delete Derived Data solutions haven't worked, my next steps would be:
Copy the contents of the .m to the clipboard.
Delete the .m from your project (including sending the physical file to Trash)
Delete Derived Data
Try to compile the project (I know it will generate errors most likely, but let it do this).
Create a new .m file and paste the code back in.
Compile and run the project.
Delete Derived Data again to force a reindex.
Close XCode, reopen it.
Now hopefully it should be indexed. If this still doesn't work, try renaming that class (the .h and .m), see if it indexes, then rename it back again.
Try Product > Clean (XCode 4).
This can happen sometimes, it's annoying. If you get desperate, try creating a new project in a different location and copying the source files over.
I found solution to my question. Actually a localized file of that file was being created in en.proj folder, where indexing failed. So, I just copied that file into project main folder and deleted it from en.proj folder. It works fine now. I can see everything indexed.
Search for "GCC_INCREASE_PRECOMPILED_HEADER_SHARING" in your project build settings
Change 'increase sharing for precompiled header' from NO to YES
Hope this helps.
Go to Editor -> Syntax coloring, and change it to objective c. It might do the trick.
Related
Trying to add file to the project!
Right click on the subfolder and selected add file to projectName. I added file which are required into my project[Destination unChecked and selected folders Create groups for any added folders and selected Add to Targerts projectNameTest], and close the xcode and reopen! the file which are added to the project is not appear's. Then again right clicked on the project selected add file's from 'workspace' and add to project [repeated same scenario] And close the xcode still files are disappearing from my workspace.
each time i need to add the file again and again from the work space. When I close the Xcode.
what i need to do for this issue so When i Open Xcode the files need to be appears into my workspace
What i do generally when I need to add extra source files to my project is :
1. Drag the file from source to my project.
2. I add Tick mark to the "Copy items into destination group's folder (if needed)" option.
3. Now i can seed added file into my project.
Hope!! this helps.
If you want to add files with a CLI, as I do, since I use a remote mac for development, you can check XCodeControl at github. This method is much faster than licking somewhere, at least if you hung over ;)
I'm trying to "install" core plot 0.4.
The first instruction is to drag and drop the XCodeProj file into my own project. I do this. Normally when I drag and drop images or the such like it asks me if I want to copy the file into my own project. However for some reason its not asking me, its just creating a reference.
I'm not sure what the difference is, and whether it will still work or not with a reference, its just the first instruction (http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html) says to click the "copy into folder" checkbox.
However that whole dialogue doesn't come up. I drag and drop and it puts the xcodeproj into mine without anything happening!
confused lol
Thanks
Edit: My solution works, but the reason it works is in this answer: https://stackoverflow.com/a/5373575/264947
--
This is what I did to fix it:
Close Xcode.
Open Xcode and create a new workspace.
File > Add files to "Workspace".
Add the first project.
Build to make sure it builds correctly.
File > Add files to "Workspace".
Add the second project.
Build to make sure it builds correctly.
Drag one project into another.
Now, be careful with the next step:
Erase the second standalone project but choose **REMOVE REFERENCES. **
There. Now you should have one project as a dependent of another project.
I am trying to use facebook connect and you sare supposed to be able to drag and drop folders but it doesn't work in XCode 4! any ideas?
Update 1/8/2017: This is still true in Xcode 8.2.1
Previously:
drag folder from project A to project B.
Now:
1. in project A, right click - show in finder
2. finder - go up a level
3. drag the folder into project B
4. delete unnecessary files inside the newly added folder
Good job, Apple.
PS: And it doesn't work for groups, as #zeeple mentioned in comments.
Dragging resources between projects in XCode is generally a bad idea in my opinion, even if it is supported. When you drag and drop something in XCode, it doesn't actually create a new copy of that thing, it just adds a new reference to its old location.
This can be very bad, because now changing the resource in one project will make the same changes appear in the other. The vast majority of the time this is not what you want. SCM further complicates things, because if you add a resource to Project B by dragging from Project A and then check in the changes and then some other developer checks out just Project B, they will be missing the resources that you "added" to Project B.
So instead of dragging and dropping in XCode, I suggest using the Finder or the command line to explicitly copy your resources into the destination project's source tree. Then in XCode just add the copied files to the project the same way you normally would.
I renamed my project.. and step by step I renamed all the targets, AppDelegate classes etc. Anyway it builds now but crashes as it can't find the .momd in the below code:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"MyApp" withExtension:#"momd"];
How do I get it to 'refresh' or build this momd file again? I have read various potential solutions involving adding a version on the .xdatamodeld file but heres the other thing.
When I click on the .xdatamodeld file it doesn't open up the editor anymore. It just does nothing. Right click bring me zero options.
I tried deleting the xdatamodeld file and creating a new one, but it has the same problem. When I press on it it doesn't open the editor.
When I create a brand new core data xcode project template, it does open the editor when I press on it. What am I doing wrong here?
I re-added the .xcdatamodeld file to my project and deleted the old reference. Works again now.
I'm still using Xcode 3, but when I double-click an .xdatamodeld file, it just opens the organizer. If I double-click an .xdatamodel file, it launches the project. This is probably because the xdatamodeld a folder, not a single file. It sounds like your problem is that the project file has lost its tracking to the mom you're using.
Here are some notes I made during past troubleshooting:
Troubleshooting dbase access — getting the right mom:
The first thing to suspect is that the managedObjectContext is not pointing to the correct data model (or managed object model, “mom”). (Actually, you are probably using the type:#“momd”, but it’s the target mom that’s been lost.)
In your app delegate, look for the accessor method managedObjectModel (created by Xcode when you stipulated Core Data store upon creating the project). Put a breakpoint in this method at the line that returns the mom.
Execute the program, and when it hits the breakpoint, go to the debugger model, and type “po” followed by the name of the mom variable being returned. (This is gdb’s “print object” command.)
What prints out will include “entities {” followed by a description of the entities in your data model. If nothing follows the brace, a blank mom is being returned — you’re not accessing the correct data model.
If clicking on the xcdatamodel in Xcode shows the full data model as expected, is it enclosed in an xcdatamodeld? That’s a sort of bundler/router/path file, and it may have lost its way. Do this:
- First, is the current xcdatamodel, the one with the green check icon, the first one? If not, drag it into first place, then test the app again.
- In Finder, make a copy of your xcdatamodel elsewhere for safekeeping.
- Get rid of the xcdatamodeld, in Finder and/or Xcode (I’m not sure which order I did this in). When done, it should not appear in Xcode.
- Drag the xcdatamodel (the one in the project folder) from the Finder to Xcode’s Groups & Files pane for the project, and choose the option that makes a copy for the project.
- Select the xcdatamodel, Design>DataModel>AddModelVersion. Now you should have a new xcdatamodeld file.
- Run the test again, doing the gdb print object command at breakpoint. Hopefully you’ll get a nice long printout, representing your data model.
- In future, avoid grouping the xcdatamodel/d files into a folder in Xcode. That seems to confuse things.
Examining the contents of the xcdatamodel/d files in Finder:
These are actually folders in disguise, as you will see if you remove their extensions. The guts of the data model is a plist, which you can open by double-clicking.
If you do this, test your app afterward and make sure it is still able to access your database. If not, follow the steps above.
I was in same situation, and finally fixed.
In my case, problem come from Xcode project group property: path.
Check path property of your project group that has xcdatamodeld file.
In my situation, it was different from xcdatamodeld file really exists,
and path of xcdatamodeld file was ../Model/XX.xcdatamodeld (example)
Anyway there were no problem, but someday I removed directory that is group's path property.
So Xcode couldn't find xcdatamodeld file. I add new xcdatamodled file, but this situation repeated.
Check if your xcdatamodeld file really exists in your project setting.
The solution for me was to revert back to a working copy of my .xcdatamodeld. Then, instead of renaming it via finder or the navigator pane of XCode 4, I selected the .xcdatamodeld file in the left navigation pane and edited the .xcdatamodeld's group name in the right pane of XCode 4 under the identity heading at the top.
Once I changed the name there to match my new project name, XCode automatically updated the name of the file on the file system for me.
I did not have to edit the path property as moon6pence suggested.
For some reason Xcode's Refactor is always disabled. I used to be able to activate it via selecting a class name and right clicking in the editor to select it. But now no matter what I do, it remains disabled. Any idea what's going on?
Working with Xcode 5, I kept getting "Can't refactor during indexing" when trying to refactor. Rebuilding the index seemed to hang at "Indexing - Waiting for make" forever.
I then noticed that make was already used by another process on my machine (not by Xcode). Shutting this process down enabled Xcode to finally finish indexing
Your project's index might be out of date/corrupt. In the General tab of the Project Settings window, click Rebuild Code Index and wait until it's done.
You can check the progress of the rebuild in the Activity window (Window > Activity).
I just ran into a similar problem in Xcode. I could not refactor anything in the class's .m (implementation file). The only explanation I could come up with is that it was not indexing the file for some reason, and I could not force it to reindex. The only hack that I found that worked was to copy the file to temporary location, remove it from my Xcode project, copy the file from the temp location back to my project's location, and then re-add the file via Xcode.
None of these suggestions work for Xcode 3.2 - the ONLY way is to select the file you want to rename in the left Groups & Files column. THEN highlight the name of the .m or .h in the right code view, then you can right click and select Refactor!
For instance if you're changing the DetailViewController name, highlight the actual DetailViewController.h word in code.
Note, you should also always make sure you've selected the .h file, not the .m
I faced the same thing in Xcode 11. and this worked for me:
I changed iPhone 8 simulator to generic iOS Device and it worked when it is on Generic
I'm new in iOS development,I have met this similar problem.
Xcode:Version 7.1 (7B91b),it looks like Refactor not working:
But when I put my mouse on the red circle point in the following picture,and then the Refactor working.
I think this is a low level mistake,but may be a reference for someone.