In Xcode 4.4 it seems I am unable to add compiler flags to individual source files. I am trying to remove ARC from a single file but I can not get the pop up to add flags. Double clicking or selecting the item and pressing enter does not work, also tried selecting multiple and pushing enter which does not work. I have tried with two separate projects, one of which I created with Xcode 4.4. Is there another way to manually add compiler flags to a source file? (I do not have an older version of Xcode to see how it stores the value [likely in the pbxproj]).
Note: MacBook Pro w/ Retina Display - OSX 10.8
I found where the window was hiding. I had to drag Xcode pretty far down to the lower left corner of my screen as the pop up window was showing up and to the right. This made it completely hidden while full screen.
A bug report has been filed rdar://11970271
Related
I am using some personal Xcode snippets for shortcuts for like dispatching on main queue, or a #synchronized code. They have never interfered with Xcode's autocomplete function with regular methods.
Some time ago I've formatted my Mac, installed Xcode, and re-created the shortcuts the same way I did before:
Ever since, my shortcuts are always before anything else when autocompleting methods containing spaces, as seen below:
The completion for methods should obviously come before my custom snippets.
It also occurs before anything else on property completions either:
They should get listed and highlighted as I type d or dm, or s, sy and so on, just like the default snippets. They shouldn't be at top of everything.
Why would have it changed after the format, and how do I correct this (mis)behavior?
(I am currently on Xcode 9.3 but the problem used to occur before 9.3 too)
UPDATE: The issue still persists on Xcode 9.4.
UPDATE 2: The issue still persists on Xcode 10.1.
Well, there is a new update Xcode 9.4, try with the update because I had the same problem, my solution was delete Xcode and reinstall the latest version, but I think only you need to clear the configuration to return like a first launch.
In the release note for Xcode 9.3 says:
Text in the Code Snippets library filter bar now includes code completion shortcuts. (8147546)
User-defined code snippets now appear at the top of the library, rather than the bottom. (8901028)
You can read full changes here Xcode Releases Notes
First, I have xcode 3.4.3 installed on my hackintosh(10.6.5). When I started using xcode , I follow apple's steps from "Your First Mac App" tutorial. When I walked through creating actions for controls, it ask me to use the assistant editor to create connections between control and logic code, but I can't find anything called assistant editor is this because I am using xcode 3.4.3?
Could somebody please tell me some alternatives.
//edit: The assistant editor seems only present at xcode 4 and higher, so the tutorial you are using is newer than you current xcode version. Thanks #popeye for the hint.
The alternative is simply add the connections by yourself. You have to add the outlets in the interface-file (h-file) and the implemenations in the implementation-file (m-file).
There is a good tutorial video fromon how to achieve this:
Xcode 3 Recipes - Connecting an Outlet
Old Post:
The mentioned "assistant editor" is just a neat way to connect your outlets with your code. It connects the GUI with the code. For example if you have a button on your screen and you want to register a touch event on that than you can simply use the assistent editor to do that.
It is on the upper right corner of xcode. See the screenshot:
It shows you a split view with the code on one side and the Storyboard on the other. If you have that view open you can simply hold the control-key and drag a connection from the gui element to the code.
From the apple website: Assistant (): presents a separate editor pane with content logically related to that in the standard editor pane. Use the split controls in the Assistant pane to split the pane. Use View > Assistant Layout to set your preferred assistant pane and split configuration.
Apple iOS Developer Library - xCode Basics
I think you might be out of luck. I do not remember having an assistant editor in XCode 3, not like the version in XCode 4 anyway. Apple tends to keep it docs relevant to the newest release. The link provided by #palme is only relevant for XCode 4.
You might have be resigned to opening multiple windows to compare header and implementation files. In XCode 3, you will have to get used to mutiple windows at times, even seperate applciations (i.e. Interface Builder is completely seperate application from XCode 3).
While i finished developing an in-app-purchase application, and after several testing on iPad/Iphone, every thing was fine, the images of table view's cells and its hight was exactly as wrote in code, so i upload the application, when it was processed to the app Store, i download it, the table view cells in both IPhone/IPad were in different sizes much bigger size then that was set while testing,so the image in cells was like stretched!!!!and not clear, i tried to test it then directly via xcode to my device, it was almost fine as before, but the problem is only when downloading from store,
I really appreciate any help,
Regards,
This is quite likely to be do with floating-point calculation optimization.
When building for release, by default, Xcode will try to fully optimize your code, including making your floating-point calculations more efficient. However, sometimes they can be incorrectly optimized, and this can cause major issues especially with positioning / sizing of views etc.
For me, this happens when building for release + armv6 architecture, and I've had exactly the same problem (only realized when released) before.
Thankfully, there is a way to disable the floating-point optimizations. Here's how:
Using LLVM GCC 4.2
Click on your project in the files pane on the left
Click the project name under Targets (as seen below), then click "Build Settings".
Search for "thumb" in the search box on the right hand side
You should see a setting called "Compile for Thumb" under "LLVM GCC 4.2 - Code Generation". If you don't, it's because you're using the Apple LLVM compiler 3.0 (instructions for that are below).
Hover over Release, and click the plus icon.
A new option should appear, with a drop-down, select "ARMv6" from the dropdown.
Then select "No" for that option. It should now look like below:
Using Apple LLVM 3.0 Compiler
Follow steps 1 and 2 above.
Search for "other c flags" in the search box
Follow the same steps above to add a specific configuration for ARMv6 + release.
Double-click the box with the flags in, and add the flag -mno-thumb. It should now look like below
If it still has issues under the release build after that, you may want to try disabling compile for thumb globally.
Hope that helps.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 120; // also custom uitableviewcell should have same height
}
I have just upgraded to the new Xcode 4 and the code is not colored has it ought to be.
For instance, the string NSString is not colored in my custom code, but when I switch to Apple's code (NSString.h for example) everything is well colored.
How can I fix that?
It's a known bug with the latest XCode. This happens with some projects which are migrated from XCode 3.X to the new version. For some people it seems to help to go to the organizer, and in the project tab delete the derived data for the project where code sense does not work correctly.
If you have a small project, it might also help to create a new project in XCode 4 and import the files from the XCode 3 project.
Update: XCode 4.0.1 made the situation a bit better, at least in some of my projects I have syntax coloring and code sense back. But it's still far from fixed.
Update 2: XCode 4.0.2 did not change much. It seems that the problem is related to subprojects, specifically static libraries. According to comments of this blog post some people were successful by changing header search paths from relative to absolute paths, e.g. instead of Foo/Bar use $(SOURCE_ROOT)/Foo/Bar. This together with switching all projects to XCode 3.1 format and to use LLVM 2.0 fixed a lot for me as well. It's not perfect yet, but usable.
Update 3: After converting the sub projects to independent projects and putting them in a workspace (aka the XCode 4 way) I have now full syntax highlighting and code completion back.
My current environment is now a XCode 4 workspace with each projects being 3.1 compatible (as opposed to the default which is 3.2), LLVM GCC 4.2 (system default) and the header search paths are still absolute (using $(SOURCE_ROOT)/.../).
I used undefined Macro, But those macros defined in Preprocessor Macros in build settings. So the xcode4 didn't generate any error for that undefined macro.
Steps taken to resolve.
Removed undefined macros wherever I used those undefined macros.
Removed duplicate definitions of Marcos.
Removed duplicate Resources. (I'd added same (many Thumbs.db files) files into the project.)
Clean & Build.
if still you are not getting the color then, please relocate your project to some different location, I changed to my Desktop location.
After these steps I got the color in my eyes.
But its very bad issue. I sucks lot of valuable time. I think these steps may help you.
Thanks.
I had the same problem with mine. Its a cocos2d game with box and chipmunk. It was a hell of a mess getting the project to recognize and find the user search paths in the first place so I wasn't about to mess with those.
What I wanted to point out is that I DO HAVE recursive paths and I do have relative paths and I still got the issue. It happened when I added a new version of a 3rd party SDK I was using. It was Testflight 083 which I updagraded to 1.0. I erased my old version but only removed references. Then I manually deleted it from finder. Imported the new SDKv1 folder and readded it to my project and removed the old SDK0 folder path leaving only the newly added SDK1 folder path. For some reason I noticed that even though in v083 I had used a #import in my Prefix.pch file, it still wasn't recognizing a call to a method from AppDelegate. Which means the #import in Prefix.pch for some reason was not working. I had to add #import to my AppDelegate file individually. This gave me duplicate #imports as Jeeva said above. That sounded an alarm in my head.
So the solution was to go and effectively remove the duplicate #import in Prefix.pch therefore only leaving the one in AppDelegate. It reindexed and CodeSense works again. Thanks Jeeva!
This issue was driving me insane, and I had given up hope of fixing it without some ugly hack on XCode's configuration. I passed through this very forum thread a stack overflow of times. Then one day, I happened to accidentally fix it. I'm not sure if you need all these steps, but I've found this a sure-fire way to fix XCode's indexing issues:
Clean your project (Command-shift-K)
Open organizer, close your project.
Under the "Projects" tab in organizer, remove the derived data for the project you want to reset.
Quit XCode
In the terminal, run:
sudo mdutil -a -i on
This seems to reset spotlight indexing (I don't know much about it because I don't use spotlight).
When the command finishes, Spotlight will have to re-index. Look up to see a little dot in the magnifying glass for your spotlight's icon. When the dot leaves, spotlight has re-indexed. You can check the progress by opening spotlight.
Re-open XCode, and wait for it to re-index all your files.
Build the project.
On build success, you should now have appropriate syntax highlighting again. I hope you guys find this little discovery as useful as I did :)
EDIT:
I should probably add that the syntax highlighting sometimes seems to re-break when the debugger hangs the simulator during app launch. I just try to avoid this by being more careful about letting the process hang.
EDIT2: (sorry first contribution)
Works on XCode 4.6 and 4.6.2.
XCode frequently seems to lose it's mind, and doesn't color code system classes or provide correct "code sense" suggestions. This is endlessly frustrating. The question has been asked on at least three other occasions:
Problems with Xcode Syntax Highlighting
xcode code sense color/completion not working
Xcode: code loses syntax coloring
I have switched by project version to/from 3.1-compatiable and 3.2-compatiable, completely restarting XCode before and after each change with no effect.
I have rebuilt the code sense indexes and completely restarted XCode with no change.
I have built my project to make sure there are no errors and restarted.
I have copied my files (sans .svn files) to a different location - same problem.
I've already completely disabled the argument "placeholders" because they screw up my documents when i type too fast... all I'm asking for is for the "esc" key to display the correct list of properties and methods.
You should clean your project's derived data. They are likely corrupted.
Go to Organizer > Projects > Your_Project > Derived Data > Delete
Xcode will reindex your project and you should be back to normal.
For anyone interested; my app has some precompile directives:
#if ...
Turns out there was an error in one of these sections.
I'm assuming my app built fine because these sections were stripped out before they ever got to the compiler... but CodeSense doesn't care about these (it still wants to color code everything inside these) - so CodeSense would puke all over the place because of the error, even though I didn't find it when I tried to build the app.
Once I fixed the error within that block of code, my coloring returned.
Would be nice if XCode just greyed out those sections instead of dying.