How does Xcode compile files when changes are made in a project? - ios

I am new to iOS programming and Xcode. Please help me understand how does Xcode compile and run the code.
Ideally an IDE knows the changes made in the progranm and the next time when we compile or run it, it knows which files need to be compiled again. But while I was trying to add storyboards in a project which was working fine with a few ViewControllers and XIB files,
I moved the view from an existing xib file to a ViewController in the storyboard and changed the name of the class to its respective ViewController in the Identity Inspector and I deleted the XIB file. When I ran the program, I didn't see anything different happening. Out of curiosity I deleted all the XIB files and then again ran the program but the still the project ran perfectly.
Then finally I deleted all the files present in my project and when prompted to either "Send to Trash" or "Remove References" I chose remove references and again built and ran the application, but there was no problem and again it ran perfectly.
After that I closed the project and again opened the project from the 'Finder' and ran it this time finally I got more than 30 errors which were not resolved even after I added all the files back to the project in Xcode.
Please help me understand how Xcode compiles the projects and also that what I may be doing wrong to move the views in the XIB files to "Storyboard" in a project.

You are right in your understanding that XCode should detect changes and know when to rebuild things, however, XCode is not perfect, and is sometimes buggy. You can "Clean" the project under the Product menu to get it to rebuild.
You did not say if you were running on the simulator or not. I often have problems when adding or removing resources and running on a device. To fix these issues, you can delete the app on the device.
Restarting XCode also often fixes issues.
Also, ensure you have the latest version of XCode.
If you get to the point where you can recreate issues, consider submitting a bug report.

Related

App tries to load a storyboard the code doesn't try to load

I recently released a major version for an app that used to have a single storyboard called Main_iPhone. Part of this release, we splitted the single storyboard in smaller storyboards and removed the main one.
Everything went fine until we released the app and we now receive quite a lot of crash reports saying Could not find a storyboard named 'Main_iPhone' in bundle NSBundle </var/containers/Bundle/Application/D4A0C73C-F9B6-43D4-A2AD-6055DAF292E9/<APP_NAME>.app> (loaded). I repeat this version of the app doesn't have the storyboard Main_iPhone anymore but the app seems to try to load it somewhere.
I've honestly looked in every source and configuration files. I've used Xcode's feature to search for a mention of this storyboard and I've run a grep -R on every files in the project and I didn't find any mention of this storyboard. I'm now really running out of ideas about what could try to load this file. By any chance, has anyone encounter the same issue before? Has anyone an idea of how I could find where this file is referenced?
Thanks for your help.
Check Target Membership of your storyboard.
Check Main Interface on your target (or you can change the storyboard name and reset Main Interface).
Check Copy Bundle Resources on your target.

After changing file locations, project can't recognize some of my classes

First off, I know this is a config issue because my code was building and running just fine before I synced my project to GitHub. Xcode's internal source control seems to be having trouble recognizing some of my files and I'm getting Use of unresolved identifier... errors where these files' initializers are in use, and were working before. I'm running the latest versions of Xcode and OS X, and these are the steps I was taking before and after the issue started...
BEFORE:
After several rounds of implementation and committing with the default local repository, I built and ran the app multiple times with no issues.
I created a new repository on GitHub, committed (w/push to remotes) and everything made it to GitHub just fine and was building and running in the simulator.
In order to organize the repository (to match the 'groups' I had created in Xcode) I did some brief research and then added nested directories to my project folder. I re-opened Xcode and repaired the file paths. Some took, but several kept showing ? (although I could still access the code just fine) and I got the corresponding Missing Files... warnings.
Because I couldn't get the new hierarchy to work (the files w/?s, not being recognized, were not able to be committed to GitHub), I tried to move the files back. This worked for most, but for a few (which seem to be the effected files) I had to rename them, recreate a new file and then paste their contents over (this is where I think the problem lies). I was able to commit everything to GitHub (even the problem files went up) but all the warnings remained.
To clear out the warnings I attempted to run my tests, and that's when the Use of unresolved identifier... errors popped up, and of course the build failed.
AFTER:
I verified all the paths and target memberships were correct.
When that didn't work, I built an entirely new project (although I did add it to the same workspace; not sure if that matters) and copy/pasted all my code over to new files. I didn't drag / reference the files and I didn't link the new project to GitHub. When I went to build, same errors in the same places...
I exited the workspace and opened the new project separately. Still no joy.
Any help or points in the right direction would be much appreciated.
EDIT:
After some help, I tried deleting the reference and dragging the file in manually but that didn't resolve the issue.
I also checked Build Phases -> Compile Sources and everything was listed fine with no compiler flags. I removed and re-added from Compile Sources, issue persists.
You can try removing referencer for the missing class file in Xcode,then add same file to folder (right click add file ) from physical workspace location this might help.
After rebuilding an entirely new app a third time, with all new files, I copied the files over and this time everything seems to be working fine. Had to repair a bunch of provisioning issues to make sure it worked (maybe that was part of the problem, but I doubt it), but everything is back to normal with the app. The only thing I did differently this time was not adding the new project to the same workspace.

All xib and storyboard files crashes Xcode 6.1

I am having a really difficult problem and have no idea how to fix it. I have a workspace with 3 projects and whatever xib or storyboard file I choose from these, Xcode always crashes, saying (Xcode quit unexpectedly). Also, if I create a brand new project within the workspace, these storyboard also crashes xcode when opening (but project can be built and runs fine, except you cannot open layout files). What could possibly create such an affect? Is the problem in my .xcodeproj file? The project worked yesterday, and I have not performed any change that I can remember.
If I build the project without selecting any xib or storyboard file I receive the following very cryptic error:
Command /Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Similar to this one:
swift failed with exit code 1 while compiling in Xcode - possibly related to Bridging-Headers
Have tested all the answers, on both XCode 6.1 and 6.1.1 (Have tested to delete xcuserdata and DerivedData). If i build using the console, in the end I get this "very" helpful error.
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
I guess nobody has a complete solution for this problem, but could you help me on where to look? .xcodeproj file? Or could a error in one xib file prevent others from opening?
Ok, this was some sort of xCode bug. One of my swift files was corrupt somehow, and the fix was simply deleting it and copying the old content to the new file. Very strange that one SWIFT (!) file could prevent all xib and storyboard files from opening.
My recommendation to anyone having the similar problem is to backup your old project and remove files until xCode works. Then you have identified the problem, and should be able to fix it.

changes in MainStoryboard doesn't effect the app

I've made a few changes in my app, the changes are in the MainStoryboard.
When I click run, the changes doesn't appear in the application. What is the problem?
Example: I add a label in the main screen and when I click run I can't see this label.
I had this issue after I started internationalizing my project. I had one storyboard and two strings files. However, when I hoked around in the project using Terminal, I found that the old version of the storyboard was still there, so I moved it out.
All that said, to fix the issue I had to physically delete the app from the device/simulator and run it again. Performing a clean build didn't work for me.
If performing a clean build and deleting the app from the device/simulator doesn't work, then have a look inside your project directory for any rouge storyboard files.
clean your build folder. Complete remove all the build that are already install in your device or simulator.
I have also the same problem, actually I have two build install in the simulator with different identifier that is causing the problem

Why is Xcode 4 not running my latest build?

I was originally working from my desktop on a project. I then decide to continue working on the same project over at a friend's house. I come home and decide to use the newest project (on a different folder even) open the project I run it and it shows the same thing I had before... for some reason it appears nothing got updated.
Any ideas why this is occurring?
You might try cleaning the project (Command-Shift-K) to see if that helps. I usually have to do this when I don't change code and only change a resource such as a xib or image file.

Resources