XCode - creating archive fails with error «…-Prefix.pch» not found - xcode

I have a workspace with multiple targets.
Each target has its own prefix.pch file.
Prefix-Header is entered in Build Settings and Precompile Prefix Header is set to YES.
The app compiles and runs fine when I run it on my device.
There are no errors when I just build the app.
But when I try to archive it, I get a compile error saying:
No such file or directory: '/Users/me/Library/Developer/Xcode/DerivedData/myApp-dcmvkatguqcxgjfyrqcunbsfuxcd/Build/Intermediates.noindex/ArchiveIntermediates/myAppTarget/PrecompiledHeaders/SharedPrecompiledHeaders/13524936819627194222/myAppTarget-Prefix.pch'
And indeed, when I open this folder on my hd, I can't see the pch-file. There are, however, similar files there:
myAppTarget-Prefix.pch.d
myAppTarget-Prefix.pch.dia
myAppTarget-Prefix.pch.gch
I tried everything I found on SO and elsewhere, but nothing helped.
I have Cocoapods installed and use them in this project, but I don't think that error is related to that (they seem to compile fine).
XCode 12.4

Seems like I figured it out.
The culprit was a totally unrelated build-setting.
In Other C Flags my settings differed in debug and release.
I had $(inherited) in both of them, but in the release setting I additionally had -isystem - which apparently is already included in $(inherited). That caused a multitude of errors that ended with the prefix.pch not being copied...

Related

XCode standard C++ headers suddenly not found before installing OSX update

I have a C++ project that have been compiling fine until now, I did not install any update of my system or XCode but I get this error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/wchar.h:123:15: fatal error: 'wchar.h' file not found
This file does exist on my system, so I suppose it's the CMake env paths that are no longer set up properly in the console?
Edit: if I clean my build dir and regenerate the whole CMake project, it is working again, but I still find this behaviour very unpleasant.
This has happened just when there was an available update for MacOS 13.0, and probably XCode updates going with it. But I did not install any of them yet, and my compilation is already broken.
What is happening so that the dev env is changed anyway?
I remember I had likewise issues last time there was an OS update.
Is any configuration needed to "secure" a dev env on MacOS?
Are all OS updates going to screw my XCode includes etc?

Compile in Xcode Prefix.pch not found

I am a beginner in react-native. I tried to compile the apps, ran the pod install (because I used cocoapods I have to do this, I guess), and opened the generated xcworkspace. After I hit the compile button, this error show up
Showing All Messages
No such file or directory: '/Users/<username>/Library/Developer/Xcode/DerivedData/<project name>-bvczmgvzvgwjpyfsmvczxliopbfo/Build/Intermediates.noindex/PrecompiledHeaders/SharedPrecompiledHeaders/7446126693023229553/Prefix.pch'
The xcconfig file I used already had GCC_PREFIX_HEADER and targeted on correct file. It stated like this
GCC_PREFIX_HEADER = $(SRCROOT)/ExportedProject/Classes/Prefix.pch;
I checked my project's configurations using target "Release" and it pointed to the correct xcconfig file.
I searched around and found this SO. I checked on my Build Settings > Apple Clang - Language - Prefix Header, and it also targeted on the correct path and has the Precompile Prefix Header filled with "Yes".
I tried to use pod-deintegrate; reimport the project; deleted the project and use react-native upgrade, but nothing works.

Issue with running application on iOS9 XCode 7

After several hours of investigation I am stuck with this one. After migrating from Swift to Swift2 I manage to deal with all the errors, but in the end I got clang error:
ld: file not found:
-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I am not really sure why does this happen nor how I can resolve it. Some of you got similar problem ?
I tried :
close/open XCode
clean build
clean build folder
delete derived data
tried to add another device (Devices screen, add simulator)
tried to build for iOS device ( same error, just instead of iphonesimulator i got iphoneos )
opened particular folder, everything is there
I am able to open iOS simulator from code
EDIT, Oct-9-2015:
After a bit more investigation, I found out following:
Pods compile correctly. Every one of them.
If I remove iphonesimulator/iphoneos they don't work
Tried to clear Library path, set it to various differenet values - no success (Library path because of -L at the start).
Found out that swiftCore is somehow missing in path:
Unable to find swiftCore; please set SWIFT_LIBRARY_PATH (currently '')
to the folder containing swiftCore.
Building from terminal to get more info about the error.
Tried to restart computer, reinstall XCode and other most common things
Tried other project - working without problem(project without pods)
Seems like this will be a diary till I commit suicide...
After 2 days of losing my mind, finally got to the solution. Hope it will save someones day :)
First, I decided to recreate the project file and pods to see if there is something wrong with them. It turned out they are fine. Project build without any issue.
So, clearly, problem was in the project/workspace file. I started comparing flag by flag, and ended up in changing the following:
Duplicate Pods_X.framework - removed one
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO - was YES before
GCC_SYMBOLS_PRIVATE_EXTERN = YES; - was no for debug
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - was something long before
If someone knows why this flags could produce something that painfull I will be happy to find out...

xcode library not found

I'm getting the following error:
ld: library not found for -lGoogleAnalytics
clang: error: linker command failed with exit code 1 (use -v to see invokation)
I've spent some time googling but can't find how to fix this problem. I'm new to xcode and this is an existing project that I need to work on.
In my case, the project uses CocoaPods. And some files are missing from my project.
So I install it from CocoaPods: https://cocoapods.org/.
And if the project uses CocoaPods we've to be aware to always open the .xcworkspace folder instead of the .xcodeproj folder in the Xcode.
You need to set the "linker search paths" of the project (for both Debug and Release builds). If this library was in, say, a sibling directory to the project then you can set it like this:
$(PROJECT_DIR)/../GoogleAnalytics/lib
(you want to avoid using an absolute path, instead keep the library directory relative to the project).
All in all, the Xcode cannot find the position of library/header/framework, then you tell Xcode where they are.
set the path that Xcode use to find library/header/framework in Build Settings --> Library/Header/Framework Search Paths.
Say, now it cannot find -lGoogleAnalytics, so you add the directory where -lGoogleAnalytics is to the Library Search Paths.
In my case I had a project with lots of entries in "Build Settings > Other Linker Flags"
I needed to reduce it down to just
$(inherited)
-ObjC
Old settings:
Updated settings:
For me, I open the projectname.xcworkspace file and it all works.
If you have pods installed, make sure to open the workspace folder (white Xcode icon) not the project folder. This resolved the library not found for ... error. Very simple issue but I was stuck on this for a long time.
This worked for me:
Go to build setting -> Linking -> Other Linker Flags -> Remove all other than $(inherited)
Cd ios && pod update
If you are using Pods to include the GoogleAnalytics iOS SDK into your project, it's worth noting that since the 3.0 release your Other Linker Flags needs to include -lGoogleAnalyticsServices not the old -lGoogleAnalytics
If your library file is called libGoogleAnalytics.a you need to put -lGoogleAnalytics so make sure the .a file is named as you'd expect
None of the above worked for me, what did was making sure the Pod file platform :ios, '11.0' matched with the minimum deployment target in the XCODE setting
You can also try to lint with the --use-library option, as cocoapods lint libraries as framework by default since v0.36
The problem might be the following: SVN ignores .a files because of its global config, which means someone didn't commit the libGoogleAnalytics.a to SVN, because it didn't show up in SVN. So now you try to check out the project from SVN which now misses the libGoogleAnalytics.a (since it was ignored and was not committed). Of course the build fails.
You might want to change the global ignore config from SVN to stop ignoring *.a files.
Or just add the one missing libGoogleAnalytics.a file manually to your SVN working copy instead of changing SVNs global ignore config.
Then re-add libGoogleAnalytics.a to your XCode project and commit it to SVN.
In XCode 10.1, I had to set "Library Search Paths" to something like $(PROJECT_DIR)/.../path/to/your/library
For me it was a silly thing: my mac uploaded the file into iCloud, and that is why Xcode did not find it.
If you turn off the automatic upload, it wont happen again.

Added Mac target to iOS project in Xcode, now 'Error Starting Executable File'

I've decided to make a Mac OSX port of my iOS app, so based on a number of suggestions I've received I've simply added a new Cocoa target to my iOS project, and set up a series of 'libraries' (which encapsulate the core business logic of my app) which I have added to the OSX target. I have not added all of the UIViewController code to the OSX target - I will have to rewrite the UI code, for obvious reasons. The app is building fine (no compiler errors for missing libraries, etc.), but for some reason I get the following error message when I try to run the 'hello world' program, which I'd like to get working before I start coding in earnest. Here's the message:
Error Starting Executable 'MyExecutableMac'
No executable file found.
Use "file" or "exec-file" command.
As per this SO question, I made sure that the proper executable file was listed under the scheme build settings, so that it will actually run. However it actually appears that the .app file is not being packaged properly - the .app file is stil listed as "red" in the file list, meaning the file is missing. What might be causing this error?
I had this problem in Xcode 4.2, I found that first doing a clean (Xcode > Product > Clean and option clicking Product > Clean Build Folder…) fixed it.

Resources