Xcode 6 Cannot Find .pch File, Although it Exists - ios

I am getting the error clang: error: no such file or directory: '/path/to/my/project/MyProject/Supporting\ Files/MyProject-Prefix.pch' from Xcode 6.3.1 when I try to build my application.
However, this file clearly exists, since when I type (or even copy & paste the path from the error message) $ cat /path/to/my/project/MyProject/Supporting\ Files/MyProject-Prefix.pch into the terminal the contents of the file are printed to Stdout. The file is also linked to my Xcode, and is visible in the document outline.
Does anyone know why Xcode is not finding this file that obviously exists?

My guess would be in the project build settings you have "Supporting\ Files" with the backslash escaping the space in the value for "Prefix Header". The backslash should be removed.
I tried this on a test project both with and without the backslash and when editing the filename in Xcode UI the compile only worked without the backslash.
When the compile worked the pbxproj file had this value:
GCC_PREFIX_HEADER = "foobar/Supporting Files/test.pch";
and the "Prefix Header" on the Xcode Build Settings showed:
foobar/Supporting Files/test.pch
The backslash is needed when typing the path in terminal to escape the space.

You should set the short path for Prefix Header in the project settings like the following:
"MyProject/Supporting Files/MyProject-Prefix.pch"
Also it is uncommon to have folder named Supporting Files in your project folder and that file supposed to be right under the root

Related

Make Xcode build a C file generated by processing a file with a custom extension

I'm trying to set up Xcode to build generated .c files just like it does for files generated by yacc (*.y) and lex (*.l) files.
Say I have input files with a *.corn extension that are meant to be processed by a tool of mine to create C source files. I then want these C source files to be compiled and linked using the rest of Xcode's mechanisms.
This is exactly what happens to my .y and .l files for yacc and lex. The project target contains only the .y and .l files and the rest happens automatically. Generated .c files get put in the derived files directory and those get compiled and linked automatically.
Here's what I've tried so far:
-If I just add a .corn file to my target, Xcode copies it into the bundle at build time presuming it is a resource. Okay, whatever.
-I then create a custom build rule to handle
Source files with names matching: *.corn
Using Custom Script:
#!/bin/sh
cp "${INPUT_FILE_PATH}" "${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.c"
I have to give it an output file so:
OutputFiles:
${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.c
Note in this case I'm just copying the file as I rename it with .c extension. (As I'm playing around, the .corn file just contains C source.)
So now before the bundle directory even gets created I get the following warning:
unexpected C compiler invocation with specified outputs: 'blahblahblah/Build/Products/Debug-iphonesimulator/MyApp.app/foo.c' (for input: 'blahblahblah/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyApp.build/DerivedSources/foo.c')
Then after the link phase (sheesh!), the script above runs and I do end up with my foo.c in DERIVED_FILES_DIR. It doesn't get compiled however and notably, foo.corn didn't get copied into the bundle anymore so there's hope.
I've tried a bunch of other stuff, but this is the cleanest I can describe that others can try. Please what is the magic incantation to make this work?!
Note that I've also tried using DERIVED_SOURCES_DIR instead of DERIVED_FILES_DIR.
So I missed two things:
I needed to add the .corn files to the "Compile Sources" build phase.
By adding .corn files to the project/target before the adding the custom build rule, Xcode added the .corn files to the "Copy Bundle Resources" build phase which broke the build.

Xcode 7: Linker warning for -F/<path> but no settings in app.xcodeproj/project.pbxproj match <path>

I converted a Swift 1.x project for iOS to Swift 2.x using Xcode 7 beta 3. It compiles and runs but I have a linker warning persisting. I've done a search through the project.pbxprox for the offending path, and have looked in the "build settings" in Xcode but no sign of the offending path (not even in the Library Search Path or the Framework Search Path). I did, however, find that the xcuser state file contains the substring.
The warning: 'ld: warning: directory not found for option "-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/Developer/Library/Frameworks\"'
The searches:
[foo#bar baz{Swift2}]$ grep -r Baz.xcodeproj/ iPhoneOS9.0
grep: iPhoneOS9.0: No such file or directory
[foo#bar baz{Swift2}]$ grep -r 'Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/Developer/Library/Frameworks' Baz.xcodeproj/
Binary file Baz.xcodeproj//project.xcworkspace/xcuserdata/bar.xcuserdatad/UserInterfaceState.xcuserstate matches
[foo#bar baz{Swift2}]$
As usual, I've done a "clean" on both the project as well as the simulators (watch, iPhone).
I've examined the directory path and see that indeed there is no such path; the path components exist up to the 'iPhoneOS9.0.sdk' component. That is, this path exists: '/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk' but there is no 'Developer' subdirectory at that location. There is, however, a framework directory underneath, but it's at 'iPhoneOS9.0.sdk/System/Library/Frameworks/' instead of 'iPhoneOS9.0.sdk/Developer/Library/Frameworks'.
I've seen this same issue. I believe that it happens because of some path incorrectly hard-coded into the test target's build settings. I don't know what path it is; my response is to delete the test target, and then the error goes away.
You can always make a new test target, and you don't have to delete the test files, so it's no great loss.
If you get this issue after upgrading Xcode, then just in Xcode click;
File -> Open Recent -> Clear Menu.
Xcode -> Quite Xcode
Go to your project directory and open your project normally.
click cmd + alt + shift + K, this will clean your project
clcik cmd + B
Then you should be fine.
Change framework search path to $(PROJECT_DIR)/* for your test target

iOS project won't compile because it can't find pch file as I had to rename folders

I'm new to iOS development, and I was using this guy's oauth implementation:
https://github.com/Christian-Hansen/simple-oauth1,
so I built a project based on his project file for simplicity's sake.
After a while I realised that I didn't like the folder structure, so I changed it by renaming some folders. I had to replace a bunch of files that came up red. Now I get these errors when I try to compile:
- Check dependencies:
Warning: The Copy Bundle Resources build phase contains this target's info.plist file '/Users/Manuel/Desktop/MyApp/MyApp/MyApp-info.plist'
- Precompile MyApp-Prefix.pch ...in /Users/Manuel/Desktop/MyApp/Simple-OAuth1
... a bunch of ProcessPCH stuff here that I can't decipher
clang: error: no such file or directory: '/Users/Manuel/Desktop/MyApp/Simple-OAuth1/MyApp-Prefix.pch
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
I have changed the folder name from Simple-OAuth1 to MyApp. I replaced the prefix file so it's not red anymore. Is there some setting somewhere that I need to change to get it to work? I also tried cleaning the project.
go to 'Build Phases' in your Target and remove the .plist file from 'Copy Bundle Resources'
go to 'BuildSettings' in your Target and search for 'Prefix Header' there you should check if the path is the same as your new/current .pch file
When you rename folders in your project sometimes you have to update the Build Settings in your project, especially when you rename the folders for things like *-info.plist and your *-prefix.pch files. But luckily this is simple to do following the below steps:
Updating *-prefix.pch location
Open your project up in xcode
Navigate to Build Settings for the Target you need to update.
In the Build Settings search bar type in "Prefix Header" or just "pch".
Double click the value field for Prefix Header and enter the new location for your *-prefix.pch file.
Save.
Updating *-info.plist location
Open your project up in xcode.
Navigate to Build Settings for the Target you need to update.
In the Build Settings search bar type in "Info.plist File" or "plist".
Double click the value field for Info.plist file and enter the new location of your *-info.plist file.
Save.

libsqlite3.dylib framework accidenlty deleted from xcode

libsqlite3.dylib is accidently deleted from my Xcode . It is shown as red in "Link Binary with Libraries" (Build Phases) . Not in Trash too . Do I need to install xcode again ?
While the above answers do tell you how to go about adding the library to Xcode, what happens if you cannot find the library? I noticed this issue, and then did a search in Spotlight for libsqlite3, which did not locate any files. While it is kind of crude, you can jump to a Terminal session to locate files throughout your file system. Spotlight does not index everywhere on your drives, and my suspicion is that it does not include the locations where this file lives. At a terminal prompt, type:
find / -name libsqlite3.dylib -print
This is a UNIX command that will locate the file, starting at the root, and printing out the results it finds. You can press CTRL-C to cancel the search at any time. I actually found it within the Xcode bundle; in this case I am running Xcode 7 Beta, so it was found in:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
For convenience, I copied the file from this folder to a Resources folder under Documents, where I keep libraries and other files for easy reference in my projects.
Please note, if you are developing in Swift, then you need to edit your Bridging-Header.h file, and add the line:
#imports <sqlite3.h>
If you don't have the Bridging Header, you can add it to your project, follow the steps:
Create a new file, Bridging-Header.h in your project.
Add the line above.
Go to your Project Build Settings (click on the Project,
click on Build Settings tab).
Locate "Swift Compiler - Code
Generation", "Objective-C Bridging Header" setting, and add the name
of the file above "Bridging-Header.h"
It looks your library is missing libsqlite3.dylib and libsqlite3.0.dylib, so copy these files from any other computer and place these files in your computer.
Procedure:
Open xcode on the computer where these files exists, add libsqlite3.0.dylib in your project from link binary with libraries.
Right click on the libsqlite3.0.dylib and show in finder.
Copy two files libsqlite3.0.dylib and libsqlite3.dylib and place on the same location on other computer where these files are missing.
original post:
XCode 4 - libsqlite3.dylib: No such file or directory

iOS - genstrings: couldn't connect to output directory en.lproj

I searched for this error online and here. Online it shows me results in a different language then english nice Google. Here it has one post and a guy that never really answered the guys question.
I have my xcode project folder on my desktop. Inside the project folder I have an en.lproj folder that has both iPad and iPhone storyboards inside along with a localization.plist file. However when I launch the project in Xcode this en.lproj folder is nowhere to be found. So this might be the problem?
With the project folder on my desktop I launch terminal type in: cd
then drag my project folder into Terminal and it gives me the path. I then paste this line of code into the Terminal
find . -name *.m | xargs genstrings -o en.lproj
I get this error message in the Terminal:
genstrings: couldn't connect to output directory en.lproj
it prints this line multiple times and then says my project is a path to a directory?
No .strings file is made. Any thoughts on what I am doing wrong? I got UILabels that I dragged and dropped from inside Storyboards, but I also I strings that are coded with
NSLocalizedString(#"First Level Passed", #"This is a message displayed on screen to allow the user to know they have passed the first level!");
So the above Terminal code snippet should be finding those NSLocalizedStrings right? I think it isn't even getting to find the en.lproj folder in the first place but I don't know?
Any help would be great.
Better late then never,
you are creating a file (localizable.strings) in the folder projectroot/en.lproj.
If this folder doesn't exist you get this error message. Simply create the folder en.lproj in the root and the command should work.
I got the same error, while execute the following command as per the tutorials.
genstrings -o en.lproj *.swift
Above command gives me following error:
genstrings: couldn't connect to output directory en.lproj
My issue:
I try to implement above command on my own directory(i.e. subdirectory of root project directory) where all the ".lproj" directory is there. - that gives me above error.
Then i have removed old “Localizable.strings” on sub-folder "Localization". and created new “Localizable.strings” in root directory. - here i got no errors but nothing is happen as per "genstrings" command.
Solution:
On command line move to the Root directory of project where you can get the all the ".lproj" directories.
Add the path of file, where you listed all the "NSLocalizedString("TEXT", comment: "COMMENT")" - in my case i have listed everything on "Constants.swift" file.
So, i have execute the following command and its work like charm.
genstrings -o en.lproj/ #ProjectPath#/Constants/Constants.swift
Note:
File path will be easily get via just drag file from the Xcode and drop to the terminal.
Solution is to manually create the folder en.lproj, then run genstring command
cd {project folder}
mkdir Localization
cd Localization
mkdir en.lproj
genstrings -o en.lproj/ ../*.swift
repeat for every language (ie: fr.lproj ) for French etc..

Resources