Xcode version 4.6.2 (4H1003) compiler error - iphone

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.

Related

Local Swift Packages Stopped Working in Xcode 13

I've local Swift Packages added to a workspace. They reside in the project subfolders and connected to different git repositories as git submodules. Everything had been working perfectly (the project was able to build, packages were able to resolve, and I could edit the packages within the same workspace).
After I updated Xcode to 13.0, the project started failing to build with multiple errors Missing package product for each local package dependency. Removing derived data, resetting packages, cleaning build folder and restarting Xcode didn't help.
Quit Xcode
Open Terminal
Navigate to the directory where your .xcodeproj is via Terminal (cd path/to/your/apps/folder)
Run xcodebuild -resolvePackageDependencies
After the packages finish resolving, open Xcode and try building again.
This is what worked for me:
Click on the project file then go to Project (not a target) -> Package Dependences tab.
Double-click on any Package and copy the location URL to clipboard.
Remove that Package using the - button.
Add it back, pasting the URL.
Clean Build Folder, then Build.
Alternatively, removing an unused package in the Target -> Build Phases -> Link Binary With Libraries, also removed the errors for me.
Removing package references from workspace and re-adding them (by simple drag-n-drop from Finder) resolved the problem.
I even didn't need to reconfigure corresponding schemes, or re-adding dependencies in targets.
If #lazarevzubov's answer doesn't help, try few additional steps:
Open xcode
Delete one or couple of libs under Build Phases / Link
Binary with Libraries
Discard changes under git
Clean project
Close xcode
Run xcodebuild -resolvePackageDependencies
Open xcode again and try to build
In XCode,
File > Swift Packages > Reset Package Caches

Sparkle 10.9 Linking Error

Having an issue where when trying to add Sparkle to my project with Xcode 5 running 10.9.
I have followed the tutorial to a T, but when I get to the point where I need to copy the framework and set its copy location that is where there seems to be no way to set the copy destination in the copy bundle resources section and it just puts the framework int the /Resources folder.
I have ready through this tread thoroughly and have tried all the suggestions here.
http://www.lists.apple.com/archives/xcode-users/2012/Aug/msg00249.html
I recompiled Sparkle from the latest source and set the Installation Directory to #executable_path/../Frameworks from #loader_path/../Frameworks I get the following error.
dyld: Library not loaded: #executable_path/../Frameworks/Sparkle.framework/
when I revert and try to re add the framework I get this error.
dyld: Library not loaded: #loader_path/../Frameworks/Sparkle.framework/
If I remove the framework from the link framework from binaries altogether and just focus on the Copy Bundle Resources then I get this error.
Unknown class 'SUUpdater', using 'NSObject' instead.
The tutorial is written for Xcode 4 I know. One step says to use Copy File Location but that seems to be gone in Xcode 5 any help is appreciated.
UPDATE
I found a work around but its very messy.
Add the framework to the "Add files to build" build step.
Unlink the sparkle framework.
Open Derived Data folder and then open the App Build, then browse to Resources. Move the sparkle.framework folder to the root of the app and place the framework into a folder named Framework in the root level of the app.
Remove the framework from the "Add files to build" step.
Re-Link the framework.
Rebuild the App and voila it works.
Basically your adding the framework in a Framework folder manually and then linking it up at the end. What makes it messy is that the build changes occasionally in the Derived Data folder.
I have the same problem. And I think I have solved it.
It happens because the Sparkle.framework isn't copied to Frameworks folder(where it should be), it is copied to Resources folder when you build the application. To solved it:
Download the source of Sparkle from GIT (https://github.com/sparkle-project/Sparkle) and open the project in Xcode 5;
Go to Build Settings of every targets, then find Base SDK, change the value to macosx.
Go to Sparkle.framework's Build Settings. Find Installation Directory, Change its value from #loader_path/../Frameworks to #loader_path/../Resources under Sparkle.framework's Build Settings.
Build.
Copy Sparkle.framework under Products group in Project Navigator to your project.
Say YES and take a self highfive.
I was suffering from the same problem, then I found this:
http://www.lantean.co/sparkle-in-sandbox-mode/
The key is to add the Sparkle.framework to the Frameworks folder using the "Copy Files" section from "Build Phases".

How to clean obsolete and excluded files from Xcode project?

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.

iPhone application build fails first time, succeeds second time even after "Clean All Targets"

I'm the build engineer for a new iPhone application and I've run into the following extremely weird situation. We're using git with Xcode 3.2.4 under Snow Leopard.
This happens whether I'm using the Xcode GUI or using xcodebuild on the command line.
I clone a clean copy of the repository and run "Build" or "Build and Archive".
The build fails with a bunch of compile errors.
I run "Clean All Targets" with "Also clean dependencies" and "Also remove precompiled headers" checked
I run "Build" or "Build and Archive" again.
Build succeeds.
The errors all seem to be of the form "file-something.h no such file or directory", but the files it claims it can't find are actually there.
Does anyone have any idea what is going on here? The git repo uses submodules, and as far as I can tell, all the "missing" files are contained in one of the submodules. However, as I noted, the files are present in the working directory, and the submodules have been inited and updated correctly.
It turns out that if I manually create all the build directories and their subdirectories before running a build (after a fresh clone), the build succeeds. Because of the submodules, there are actually three build/ directories (one in the main project, one in each submodule) and the submodule ones have a bunch of subdirectories.
This has to be due to a bug somewhere, and I will continue to research it, but at least for the moment I have a workaround and can get on with creating my automated build.
Edit: And in fact, this appears to be due to a bug in the build of one of the two submodules, three20. I'm guessing that it creates the build directories after it tries to use one or more of them. I will take this up with the three20 developers.

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...