Xcode Project Code Changes Not Updating 100% After Save-Build-Run - iphone

When I make code changes to my iPhone game project in Xcode, and then do CMD-B + Enter, I expect the project to be saved, build and run on the simulator with the latest. What is happening though, sometimes, is that it doesn't pick up a small change I make unless I clean the project and then build.
I'm a long time Java person and newish to C-based languages and it's compiler. Can someone explain to me what is cached after each build that does this and how to change my project settings to avoid having to clean every time? Or tell me the bad news that this is part of C development? Not trying to bash it - I get compiled JSPs stuck in the working cache often in Java, too. :P
UPDATE: Does this have to do with the location of my builds at all? That's the only thing I can think of that's changed from a build config perspective.

Had a similar problem, I reset content and settings in the iPhone simulator

Seems odd to me, because I never get this problem in XCode. It's not a common issue with C or anything. The tools for C-based languages usually do this just as well as the Java ones.

Go to Product Menu and choose Clean and then choose Build. Thats it.

In the Xcode Build Preferences make sure that "Unsaved Files" is set to "Always Save". If not, Xcode will not autosave files before building and will use the last version saved to disk.

In case anyone still comes across this (as I was having this issue today on Xcode 5.1), all I had to do was open a new tab and close out the tab I was working in. Some sort of tab bug in Xcode.

I am not sure about this, But in case if you are using git, go to xcode preferences -> Source control -> General
Uncheck Refresh local status automatically
Uncheck Fetch and refresh server status automatically
Uncheck Add and remove files automatically
Uncheck Select files to commit automatically

Related

Xcode 7.3 autocomplete is so frustrating

There is a new autocomplete in Xcode. Probably might be useful because it checks not only beginning of names etc. But I found that very often it doesn't find a class name or a const name at all etc. I need to type in entire name by myself. Over all I found it makes my life harder and coding more time consuming. Is there a way to switch to the old way it used to work?
Xcode 7.3.1
In Xcode > Preferences > Text Editing
uncheck Enable type-over completions
restart Xcode
It seems that clearing the checkbox "Enable type-over completions" in XCode -> Preferences -> Text Editing does the trick. At least in my case autocompletion fell back to a sort of old way, so it could autocomplete the class name that I had to type in manually before that.
This is by no means an adequate solution, BUT it has allowed me to (barely) maintain my sanity the past few days:
After every build, you need to trash your Derived Data folder. You can find this folder in Xcode > Preferences > Locations > Derived Data. Just trash the whole thing and it'll kick off a re-indexing step that should restore proper autocomplete functionality.
Unfortunately, I've found that once I build, the autocomplete behavior reverts to its broken state.
just open Xcode derived data folder and delete the folder
/Users/yourUserName/Library/Developer/Xcode/DerivedData
then restart Xcode, now autocompletion works like a charm
I have the impression that some 'parts' of autocompletion simply fail after a while. I use to restart the Mac to get it back working. But sometimes it fails quite soon again.
Maybe the answer of #Alex Bykov combined with a restart will do the trick.
Anyway: auto-completion of Xcode always was crap. AppCode used to get it much better. Unfortunately not yet with swift.
Closed Xcode, opened Xcode, let it index, it worked.
it doesn't find a class name
As a work-around, you can try to press
Command + Shift + K and Command + B
Several times,it works temporarily.
Xcode 7.3.1
I will share another posible reason, that after couple of days we found out. We have multiple schemes, and in one of them, the bridging header was importing a file that didn't exist anymore. So, it didn't break while compiling and running (the header belongs to another scheme) but it caused the autocompletion to break (couldn't find any objective-c class).
Hope it would help someone!
After having tried different methods:
Delete Derived Data
Switching Module Enabled off in Build Settings
Full Clean
Relaunch
Only this worked:
Find any commented out (/* abc */) code after #end in your files and delete.
Credit to Max_B:
https://forums.developer.apple.com/thread/7439
In my case, other projects were auto-completing correctly. If all your projects fail to correctly predict code, then it might be a different issue, and the other answers might work.
I ran into this issue while trying to make an OS X app and I was able to fix this issue by making sure that the Xcode 7.3 documentation and the OS X 10.11.4 documentation was actually downloaded. Doing this fully restored my autocomplete functionality. My full instructions are below as well as in my answer to a similar question: https://stackoverflow.com/a/39420664/3444925
I had this problem myself and after looking through all the other similar questions & answers about this, I couldn't find a solution. However, I finally found what worked for me.
Go to Xcode -> Preferences -> Components. There you will probably find a screen that looks like the following:
This shows that the documentation has not has not been downloaded and therefore, any attempts to re-index or re-build the application without downloading the documentation would prevent you from being able to use the autocompletion functionality.
Once I downloaded the Xcode 7.3 Documentation and the OSX 10.11.4 Documentation, this was enough for me to get the autocomplete functionality back (I was trying to build an OS X app, so feel free to download as much documentation as is relevant for you).
I didn't run into this until I created a couple of new class files. Other classes worked fine, but autocomplete would NOT work for anything in the new files...
FIX (for me) - I had to add those files to ALL of my targets, including the unit test targets even though I wasn't using them yet.

Use LLVM compiler by default for all Xcode projects?

I really enjoy switching from gcc to LLVM compiler, but do I have to switch manually every time I start a new project, or is there any way to make LLVM the default compiler?
I'm talking about xcode 3.
Thanks.
To accomplish this you will have to modify the project template within the Developer directory.
Navigate to where your templates are (probably something like: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/
Once you're there, you can select the project template you wish to modify, and locate it's .xcodeproj file. You can "show package contents" and inside is a project.pbxproj. You can modify this file and edit in the build setting to change the default compiler.
You'll have to find each section that relates to the build settings for each configuration (Debug, Release etc.), search for /* Begin XCBuildConfiguration section */.
Then you'll have to add GCC_VERSION as a key and com.apple.compilers.llvm.clang.1_0 as the value (1_0 in this instance is actually LLVM 1.6 according to Xcode. I also assume that the key-name GCC_VERSION only has GCC in it for legacy reasons, this will probably be updated to COMPILER_VERSION or something in the future).
Save the template and create a new project (You may have to restart Xcode if it was open). The compiler should be set to LLVM now.
However, I don't recommend you do this as LLVM still isn't 100% fit for deploying applications to users.
I don't believe there's an (easy) way to do this. (i.e.: There's no preference pane option for such a thing.) That said, the advice within the existing Setting GCC 4.2 as the default compiler on Mac OS X Leopard question should work #Jasariens answer seems ideal, if the per-project setting is proving tiresome.
However, LLVM isn't quite ready for prime time, so I'd really recommend not using it for the final deployment of apps, etc. (If you're encountering any odd issues, switch back to using GCC and they'll quite possibly go away.)
Incidentally, whilst off-topic, there's some great tips within the Hidden Features of Xcode question as well, so that might be worthy of a browse. :-)
The very easiest way (and smartest, I think) to do it for all future projects is to do the following 5 steps :
go to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPhone Base.xctemplate (you can simply Command + o (open) in Xcode then Command + Shift + G (go to folder), then paste this path)
open the file TemplateInfo.plist in Xcode
go to Project > SharedSettings > GCC_VERSION property and change its String value to com.apple.compilers.llvm.clang.1_0 : http://grab.by/a0dV
save the file
test by opening a new iPhone project.
You can do the same for other new project by going to, for example, /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPad Base.xctemplate for the iPad projects, etc.
That's it.
Have a nice day everybody.
I’ve written a simple script that creates a fresh Xcode project with sane defaults. Might be worth adapting, so that you don’t have to set up every new project by hand.
All answers tell how to change default compiler value for new projects.
This is how to change directly the "iOS default" values in XCode for any projects :
EDIT the file (with sudo)
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSXXXX.sdk/SDKSettings.plist
Restart XCode and done!

Restore Project Settings in XCode

How can I restore Xcode project settings? I can't see few settings (like Targeted Device Family, iPhone OS Deployment Target, etc.) after I gave my Macbook to my friend. :(
I also saw that the info.plist file was not in the project, I recovered it via TimeMachine though, the Base SDK is also missing. :( She messed all things up, I don't know why she went in there. Anyways, is there any way to restore the settings?
Unfortunately, the snapshot that I have is also very old. :(
No way to restore them. You can set the base sdk on the project info screen.
Project > Edit Project Settings > Base SDK, Check the same for your Target.
Is this issue occurring for a specific project, or all projects? If you create a new project, what happens?
I forget the exact syntax, but different versions of XCode handle project files slightly differently. A new SDK (and version of XCode) couldn't read my project file right (same symptoms you explain).
In my case, there were 2 different SDK settings in the project file due to 2 separate versions of XCode editing the file (this could be very likely if you restored from backup and had upgraded SDKs in the interim).
Look for something like:
SDKROOT = iphoneos4.2;
Or really, just look around the text that contains the build settings (all of your build settings are stored in the file in flat text) -- you may see something related to SDKs where there are 2 lines very similar right next to each other. That'd probably be your problem. If you don't know which to delete, try both and then re-set the setting using the interface.
Of course in any case, you should back up your project file (project.pbxproj) before trying any of this.

When my colleague changes code and commits it to the repository I can see the code, but xCode compiles as if his contributions weren't there

Have any other iPhone developers experienced this phenomenon? I can see his contributions in xCode - I see for example my colleague has wrapped a navigation controller around one of my view controllers and added it to my tab bar. Great! That view really did call for a navigation controller and this is a welcome addition to the project.
So, I up my code and compile - no navigation controller. I do build -> clean all targets, thinking maybe some pre-compiled code is mucking me up and compile again. Same result. I was eventually able to get his changes to compile by deleting the whole directory and checking it out from the repository, but I really don't want to do that every time my colleague checks in code.
Is there some kind of box I need to check or something? What could be causing this behavior?
Thanks in advance.
Here are a number of possible fixes:
1) Delete the current version of your app off the simulator and/or device. This especially becomes necessary when using Default.png or app icons. There are a lot of shortcuts that the compiler takes for apps that are already "installed".
2) Make sure that there are NEVER any build folders or user specific files (pbuser.USERNAME I think). These files wrecked havoc on a few projects and we basically had to delete and start over.
3) Make sure that all files are svn added to the project before each commit (although this wouldn't matter for your current problem.
4) Find the changed code and set breakpoints for the debugger to catch. I believe that breakpoints that turn YELLOW while running signify that there is a difference between run and code.
I would tend to believe that it would be a problem with the .proj file also, but it sounds like that's not it.
Some things to check (but maybe you already did it):
is the new code added to the correct target? You will still see it in the project tree, but it won't be compiled
if you are using a SVN (or CVS) client that is not XCode, you have to remember to commit (and update) the .xcodeproject file too.
Your question isn't entirely clear to me, so forgive these follow-up questions:
Where in Xcode did you see the changes? In the repository browser, or in the file browser part of Xcode?
What do you mean by "up your code"? (I'm assuming you mean that you chose the "Update source from repository" option or whatever it is called - I'm away from my mac right now - but I thought I'd check.)

MY XCode datatips are not showing up

I've got a little problem and I'm hoping someone here can help me out. I've used XCode pretty regularly for a while now and have made plenty of use of the Debugger datatips. All of the sudden today on a new project that I am working on, they are not there. The setting is toggled on under the Run->Debugger Display->Datatips menu, but they just aren't showing up for this project. If I go into any of my other projects or make another new project they show up fine.
Any ideas?
Thanks in advance.
I have two solutions for when I get random weirdness with a specific Xcode project:
quit Xcode, trash the "build" folder for the project, open up the project again and re-build (harmless, just costs you a rebuild)
quit Xcode, delete foo.xcodeproj/username.mode1v3 and foo.xcodeproj/username.pbxuser (relatively harmless - you lose personal settings such as debugger breakpoints and custom executable settings - the files get re-created with default settings)
I know it's just voodoo but these seem to fix a lot of random problems.