How to clean obsolete and excluded files from Xcode project? - iphone

I have a problem, with running some project on iPhone 4 device. It displays some excluded and already deleted XIB files. For contrast, on the simulator everything is OK. I deleted the app from device, and used xcode feature to clean the build, and there are still some obsolete versions.

Hold down the Option key then select Product > Clean Build Folder... . This will completely wipe the build folder and you can then rebuild from a clean slate. If you also delete the app from your device then you can be sure that there are no leftovers from a previous build.

Related

Xcode version 4.6.2 (4H1003) compiler error

I just updated to Xcode version 4.6.2 (4H10003) and tried to run a previously working application project in the simulator and received the following error and the build failed.
PCH file built from a different branch ((clang-425.0.27)) than the compiler ((clang-425.0.28))
What went wrong and how can it be fixed?
Do a Clean of the project; hold Option so that you are cleaning out the whole build folder and intermediates. You might have to quit Xcode and throw away the whole contents of the DerivedData folder by hand in the Finder, as I describe here: How to Empty Caches and Clean All Targets Xcode 4
Go to your project's Build Settings, find a setting named Precompiled Headers Cache Path, then delete that folder
Do a cleanup using command+shift+k and run existing project again.
From XCode 4.6.2 Release Notes
Known Issues
Building
When building a product previously built with Xcode 4.6.1 or earlier, the build fails with an error similar to this one:
PCH file built from a different branch ((clang-425.0.27)) than the compiler ((clang-425.0.28))
To address this issue, choose Product > Clean before building your product. 13663167
Performing Product > Clean works
I've tried all the above and it works fine from Xcode UI, but it was still failing for me when I ran xcodebuild from command line.
That was due to dependencies to other libraries and their pre-compile headers. When running from command line, looks like xcodebuild store/reads pre-compiled headers from here:
/var/folders/v0/ztxy9kls7sv05dpmvjgg_xwr0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders
After cleaning up that folder, xcodebuild succeeded.
Specially if you build from command line or you have a build script, cleaning xcode target is not enough. You have to delete this folder.
The exact location of precompiled header can be found in the project, part of the folder path is random (I guess), esp after /var/folders/xx..xxx/C.
Target -> build settings => "Build locations" -> Precompiled headers cached path
Run Terminal and go to this folder and delete (use command),
#rm -fr SharedPrecompiledHeaders
I had to manually delete ~/Library/Developer/Xcode/DerivedData/
Clean didn't work for me.
use "command+shift+k" to clean your project, then you'll be fine.
Clean Your project and run
Product- > Clean
Then, Run.

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.

Removed MY_APP.app file

I moved MY_APP.app file by mistake, in Xcode Project Navigator, under "products" folder, it seems red now, what will be the consequences?
And how can I bring it back?
When I build and run the project in iPhone simulator it doesn't come back.
Delete the red marked file(which means that is not located physically).Reset the simulator and clean all targets. Build first and then run should work.

Frameworks are 'red' in Xcode

I downloaded a project developed by Apple employees ( who taught course at Stanford on iPhone application development). Strangely , the frameworks are red.
http://img.skitch.com/20100730-kcjun96mp2pxnpg7w3x6njw57.jpg
I tried to locate coreGraphics.framework and UIKit.framework to add them again but i couldnt find them either.
Taimur
The red text indicates that the actual files are not at the path that the project has for them.
Get info on the framework and look under the General tab. The first section shows the name and path of the framework bundle itself. The most common cause of a problem with system supplied frameworks is that the path type has been changed to something that breaks the path. The default setting is Relative to Current SDK. Change the path until you get one that leads to the actual framework.
If you have the developer tools installed in a custom location, you are more likely to run into this problem. If you copy a project from someone with non-standard settings, you can encounter it as well.
Are you building for a Simulator or for Device?
Try building for Device.
Found a way to fix this automagically:
Right click your main Xcode project file (the blue one at the top ),
Get info,
'General' tab,
At the bottom, set 'Base SDK for All configurations' to your desired one.
Done!
Steps to fix this issue in M1 Macs:
Install "sudo gem install cocoapods-deintegrate cocoapods-clean" to install deintegrate if not installed.
Run "pod deintegrate" in terminal in your project folder to uninstall all pods.
Run "pod cache clean —all"
Run "pod install"
Go to Project Explorer Select "Pods" in blue
Select the each pods in the target section
Search for "Excluded Architecture" in Build Settings Tab under "All" sub category.
Add "Any iOS Simulator SDK" in both debug and release and set the value to "arm64"
Repeat this for each Pod with the error "Framework not found".
Clean Build the project.
#Taimur Hamza - Its happen (red color) following any one of reason,
Your downloaded project may be miss some required files
Before run the application at first time.
so, first you have to find that above reason is happen and try to solve via copy the framework from another running project and paste it your project.
I had faced this problem before. I got over it by copy the missing (in red) framework from my friend's Mac then copy it to the Framework folder.
This is the path of my framework folder:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks
You may need to change the path depend on your system or your sdk version.
Most likely you decided to remove some of the frameworks you don't need and you deleted them but selected "Move to Trash" instead of "Remove reference".
The problem is that this framework was not included in your project's folder. It sits in a System folder when it can be used by multiple projects. So not only did you cause the current project not to compile, but also all projects on your computer.
If you have any frameworks left, you can right-click on them and check "Show in Finder". Than you can find your deleted frameworks in the trash (if it's not wiped already), and put them back in the system's Frameworks folder.
If you can't find this folder, for me it was here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library
Of course, when you go in Applications folder and select Xcode, you have to right-click on it and click "Show Package Contents".
If you deleted your frameworks even from the trash, than I guess you could re-install Xcode...

File not being copied when deployed to iPod device

I have an application with some images in it. Recently I added a new one in and it displays fine on the simulator.
When I create a distribution build and do an ad-hoc install it works fine, but for reasons unknown the image doesn't appear.
I have tried
"touching" the directory it is in
Re adding it
Cleaning the solution around 234087290 times
But to no avail! Any ideas?
EDIT
The file is definitly inside the "Copy Bundle Resources" folder.
Check that the image is being copied into your bundle. In the Groups & Files pane on the LHS of XCode expand Targets and then your app build target. Check that you file is included under the "Copy Bundle Resources" section.
Other than that, there's the tried and tested "Xcode Voodoo dance": Clean All Targets, delete build folder, restart Xcode
Make sure the image is added in Xcode as part of the project. I've seen the case where adding the file to the folder in Finder will make it available on the Simulator, but not on the device, because it was not added in Xcode.