Xcode: Framework Header File not found - Every time after new launch - ios

Every time i open the project im working on, all header files of the frameworks are not linked. I have to manually add all frameworks reference so that xcode wouldn't give me the error that the header files is not found.
After quitting xcode and launching the project again, same thing.
If anyone could help it would be great ! its a huge pain in the ass tp link binary with libraries of all frameworks every time I launch the project.

Maybe its because of "spaces" in the names of the parent folders of the items that you added.
Check https://stackoverflow.com/a/25009037/1071320

I have tried this way which works for me
Create a group in Xcode
Drag the files inside the SDK to this folder
Build and Go!
N.B what i have tried earlier is drag the whole folder inside the SDK

As #Shumais Ul Haq mentioned. It looks like it is happening because of spaces in the containing folder. When the framework is dragged into the project that spaces are messing in Framework Search Paths. The way to fix it without changing a directory names is to escape a spaces in the framework search path by \ so instead of ../My Directory Name it will be ../My\ Directory\ Name

Related

Xcode keep using old framework version

From the beginning of my project, I use a custom framework, let's call it "custom.framework". But there was a bug in this framework and now I want to use another version of the "custom.framework".
At first, I simply removed the "custom.framework" file from my project and added the new one. But nothing changed, the bug was still there.
After multiple tries and hours, I understood that Xcode add the old version in memory and used this one instead of the new version. I know it because in the new version I added a method and when I cmd+click the class I've add the method into, it's not there and the file's path is unavailable.
Searching through the web, I tried to change some version parameters to my framework projects: Compatibility version, Curent Library version, Framework version. But this didn't change anything to Xcode which keeps using the old version.
I also tried to make the framework's project as a sub-project and add resulting framework as a dependency to my target. It worked well, but as the framework's project is on a separated remote git repository, I don't think this is an acceptable solution.
So my last try was to build a "custom2.framework", to force Xcode to use the real file and not some cached version. But again, it doesn't work and when building I get errors telling me that all my classes in custom2.framework are duplicated symbols of its cached version of "custom.framework".
So my question is simple: how can I finally tell Xcode to deleted its cached old version and let me use the file I gave him? I already tried to delete my project's derivedData but it seems cached frameworks aren't there.... I'm so desperate :(
Edit: Here are 2 screenshots to illustrate the issue
First screenshot is the path as shown by Xcode when I opened the file from the .framework object in the project navigator.
Second screenshot is the path as shown by Xcode when I opened the file from a cmd+click to a "DCEquipmentManager" in code.
As you can see, the framework linked with the code is not the framework in the project.
it seems problem with binding in new framework, your project still linked with old framework files.
try to remove all files and folder related to your "custom.framework and also remove path for that framework from project setting--> build setting --> search Path
Then after Drag and Drop Your "custom.framework" files in project.
it works for me.hope it resolve your problem.
Please try to clear derrived data:
Window -> Organizer
at the right side you will see projects list. Find your project and tap on it. I the top part of window you will see button delete in front of Derrived data, tap on it.
I guess it will solve your problem.
It might sound silly, but sometimes restarting XCode or the whole machine fix things.
Did you remove the old framework from Build Phases --> Link Binary With Libraries?
Use Clean Build Folder: option-shift-command-K, or select it from the Product menu when holding down the alt/option key.
First lets say something upfront. The build stage is a(are) command line tool(s) that is managed by Xcode according to your Build Settings.
So when Xcode doesn't find your Framework - the Build System will usually also not find it. This forces you to act but may end up in confused Xcode to catch an older reference.
Yes it may happen that the Header Xcode is pointing to is correct but the build system still uses an old copy somewhere. An outdated copy can dangle around literally anywhere depending on the steps you took before.
It (Xcode) assumes where it is located but the Build System still uses another version or the Search Paths just pointing in the wrong Locations even if they are visible to you and even your Framework icons are visible in the lists. So when you erase the last build you actually only force Xcode to rebuild from the known arguments, the settings stay the same, the lists stay the same. Even restarting Xcode does not change anything, the problem persists.
Ergo: Compiler Instructions, Xcode settings and Build System settings don't match what the code tells with #import <NAME/Name.h>
So you will check at least those 6 stages again:
Is your Framework Header File published in your Framework project?
are Build Settings really pointing to the right Framework Search Paths or System Framework Search Paths?
Is your Framework in linking list?
Is your Framework in Embed Framework list?
Does your framework appear in the Framework Group Folder in Workspace/Project Browser? (usually the very last Group Folder in the Browser below all your other files)
Is my Folder Structure correct?
At least 1 to 4 must be right otherwise it will fail.
Here a random list of common causes
Framework is located outside your Source Paths structure
Structure got changed after you added it to the project
You use Workspace's where Framework development and Final Application can appear side by side but you assume Xcode uses this to change its Search Paths
The contained build settings are misleading from former drag and drop operations, ending up tricking Xcode in the "wrong" corner. In this case recreating a project is just one of the possible ways to fix it but not the solution.
Also dragging a Framework into your Project > General or separated in Build Phases > Link Binary list or Embed Framework lists does not make Xcode aware of the wrong Build Settings.
The Linking works, embedding works, but compiling does not. The Header information is still missing.
The solution must be to correct your Build Settings.
As mentioned above Build System and Xcode are two different things. In particular only setting the right Framework Search Paths will solve those issues, even if you managed to kick your derived data manually.
Erasing Derived data?
Derived data is the place where precompiler collects data to compile. So it can be seen as expression of what all the settings are told to do. Erasing it does of course not change the settings but may fix inconsistencies related to former Build Settings. It would erase the derived data and rebuild from the Build System Settings you gave.
Correcting Linking?
Also Linking is not the same as making Xcode aware of the desired Headers. Linking is for your final Product to know where Symbols are to call on them at runtime, it does not change Framework Search Paths and System Framework Search Paths, they stay the same as given.
But it is not wrong to start fixing first with
Product > Clean Build Folder, it forces your build to parse all and compile all again on the next Build.
When the troubles come up because of folder structure in parallel or Frameworks are simply placed outside the Source Directory then you must point to them directly or relative.
Most likely you should place one extra entry in your Framework Search Paths like $(SRCROOT)/../Yourframeworksource/build/Debug. expression to point to relative higher folder structure.
Needless to say that a Release Build likely needs another entry ending in "/Release".Hint: Well you can have different Search Paths for different Compile Schemes..
This works particular good after you cleaned Linking List, Embed Frameworks List and then also check the very last Group Folder "Frameworks" for double entries to drag and drop a fresh Framework reference in there.
How to know if leading /../ will fix it?
Click on the dropped Framework Icon inside the workspace Framework Group Folder (lower most) while your Project is the active selected to work on, now watch for the relative Path information on the very upper right side of Xcode, if there is some /../ you know you need it as well.
Sorting of Framework Search Paths
play a role of course, just the same as #import/#include rule sorting matters.
Remember the first found, first wins rule because often we use #import that works different then #include but ignores second attempts to declare. This leads to once wrongfully declared headers to hide corrected declarations later on in parsing that share the same filename or define rules
#ifndef xyz
#define xyz
// all your code here.
// a second read attempt would be ignored
// a second read is hidden also when you use #include then.
#endif
So you can sort those entries either by code and/or in the build settings if needed because of course it matters what is declared before other declarations depend on it.

finding the framework of a cocoa modules

I just followed a tutorial https://medium.com/#PyBaig/build-your-own-cocoa-touch-frameworks-in-swift-d4ea3d1f9ca3 for creating your own cocoa touch framework. There is one step where you need to right click a framework and it shows in finder, but it is not working for me. I can right click any other file and show in finder just fine. Any suggestions on how to find the framework file for dragging into another project?
well according to some apple doc I found:
Note: The standard locations for frameworks are the
/System/Library/Frameworks directory and the /Library/Frameworks
directory on the local system.
If it isn't in those directories, it is probably some custom path that would be specified on the CC line in the build output, and if you were really hard up, you could click the diff editor on the Xcode project and search for something.Framework, where something is the framework you are looking for.
... it is also possible that it is a framework that is build by a sub-project, and for whatever reason, it haven't been built yet.

DropboxSDK.framework file not found after relaunching Xcode

I am using the DropboxSDK.framework in a project of mine.
I have everything setup and working fine. However, every time I quite Xcode and open it again at a later point I get the error below:
Which is weird because I can see that the framework is in the project and nothing (that I know of) has changed since the last time I had the project open and working.
The way I make the error go away is to:
Right click on the DropboxSDK.framework in my project --> Delete --> Remove Reference.
In my project's Build Settings under Search Paths I remove the path that is under Framework Search Paths (the highlighted selection in the image below).
Then I clean my project SHIFT + CMD + K
Lastly, I click File --> Add files to my project, navigate to the DropboxSDK.framework file which I previously removed reference to and add it back to my project.
Then I build my project again and the error goes away and will remain gone until I quite Xcode and open it again.
Has anyone else ever encountered this happening and fixed it?
Or have any suggestions I could try to fix it? I'm using Xcode V5.1.1
Let me know if there's anything I can clarify. Thank you!
$(SRCROOT)/Application_Folder
Application_Folder is the name of the folder where your whole code other resources resides
Insert above line in Header Search Paths
I had a random thought sparked by Indrajeet's answer that solved my problem.
When a new project is created in Xcode a project folder is created. In that folder there is another folder with the same name as your project, a .xcodeproj file with your project's name and a yourProjectNameTests folder.
Visually like this.
Application_Name --> Application_Name
Application_Name.xcodeproj
Application_NameTests
When I was having the error I described above the DropboxSDK.framework and it's accompanying files were stored here in this folder:
After removing all references to the DropboxSDK.framework in my project I decided to move the DropboxSDK.framwork and it's accompanying files one folder level up to the main Application_Name folder here:
Once I did this, I clicked File --> Add files to my project, navigated to the DropboxSDK.framework file, now one folder level up and added it to my project.
After building no error was thrown. I restarted Xcode and tried again to make sure; still no error. Rebooted my computer to be truly sure... still no error!
I was having the sane problem and just found the answer by chance!
It happens when you create your project name with SPACES between the letters. Somehow it makes XCode crazy when searching for the frameworks.
So if want to create a project called "This is My Project Name", call it "This_is_My_Project_Name" and the frameworks will be found every time. It worked with me.

directory not found Apple Mach-O linker warning but Library Search Path and Framework Search Path are empty

I'm getting these messages:
ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed"'
ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed/../../../Downloads"'
But when I go to Build Settings (as suggested at ‘ld: warning: directory not found for option’), Library Search Path and Framework Search Path are empty, so there's nothing to delete.
Thoughts on other things I can do to get rid of this warning?
Here is a description how to avoid a problem based on Apple Dev Forum posted before. It works for me so I repost description for those people who don't want to go and register at the forum.
The bug is due to an error in XCode 5 when it deals with the user adding new files or folders to the project.
Xcode is modifying the 'Library Search Paths' build setting, and making a god-awful mess of it.
Instead of adding $(SRCROOT)/ it is adding fully rooted paths to all new items, and adding random amounts of /// into other elements of the string.
It also seems to be duplicating source paths in some instances, probably because it's broken the existing ones, and thinks they need adding again.
The solution:
Copy out your Library Search Paths string into a text editor.
Remove any fully rooted paths that shouldn't be there, and replace them with the usual $(SRCROOT)/MyFiles/ type paths.
Remove all extraneous slashes and make sure each path has a " character at beginning and end to protect against spaces in filenames.
Paste the edited string back into Build Settings.
Clean, then Build. Should be back to normal.
This error may well recur if you add new files to your project, so beware.
My project.pbxproj looked like this:
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\\\"$(SRCROOT)/AdMob-v6.4.1\\\"",
"/MyProject/AdMob-v6.5.1",
);
I closed MyProject, deleted the line containing AdMob-v6.4.1, reopened the project, performed a "validate project settings", cleaned, and built, and now all is well.
Yeah, Xcode is jenky sometimes.
Did you try cleaning your build (Product > Clean Build Folder / Shift-Cmd-K) and trying again?
Another thing you can do is to search for the two entries in [project_name].xcodeproj/project.pbxproj, remove them, close XCode, re-open, Clean Build Folder and try again.
Good luck!
To summarise what #user2963906 is suggest, I show my solution to this problem, which I think much easy.
I assume that you have all your files and libraries in your project folder.
Open your project Targets
Find Search Paths topic and Library Search Paths
Choose and remove all paths here
Then add path like this: $(SRCROOT)/"Your App Name"
In the same window change drop-down list from the right from non-recursive to recursive
Shift-⌘-K and Run your project
I found a solution for this with my case on the iOS Developer Forums. It happened to me with Xcode 5. See Massive Linker Error Warnings (directory not found for option) yet . For me it was caused by Xcode 5 junking up the "Library Search Paths" build setting.
Easy Solution :
It's work for me
when you want to add new files or folders to the project through xcode 5 and above error display.Just follow below simple step.(Please don't forgot to get backup of your project).
Open your Project in Old XCode (I recommend XCode 4.6.3)
Add your files or folder. (it will not mess your library search path as it mess in XCode 5)
Close the old xcode and open your project with XCode 5 and start to code.
I faced the same problem but was unable to fix it as per the steps since no library folders were getting displayed in the Project properties window.
So I solved it in another way (you need to be able to use the Terminal and the VIM editor. Also take a backup of the project just in case)
Open a Terminal window
Go to the project folder.
The XCode project is a folder. use cd project name to go into that folder.
use vim to open and edit the project.pbxproj file.
Remove reference to the offending lines by searching using / and using the dd command on that line to delete it.
Save using :wq command
Open the project in XCode and build. Works like a charm.
I had to escape any spaces with a \
So for example:
/Users/Me/Folder\ with\ spaces\(and\ brackets\)
in Library Search Paths
This worked for me :
Create this real directories (with no content), add them to project, remove via remove reference, clean, delete for real
In project folder -> target , under 'Build Setting' search 'library search paths' and simply delete previous path in Debug & Release area.
Now add the line below line using + symbol
$(PROJECT_DIR)/Library
Note: After adding the above line click out from popup. its automatically display the full path.Then check this path with your Finder if any correction add after the $(PROJECT_DIR)/
Clean , Build and Run … Simple its cleared that error. :)
-Anup

iOS,CoreAudio: a strange 'CADebugPrintf.h: no such file or directory ... ' error

There are bunch of helper filess in 'iPublicUtility' folder of several audio related Apple sample codes, such as aurioTouch:
http://developer.apple.com/library/ios/#samplecode/aurioTouch/Introduction/Intro.html
I can build these samples fine. But whenever I create a new project for testing and include the files from 'iPublicUtility' folder, I get:
'CADebugPrintf.h: no such file or directory ... ' error in 'CADebugMacros.h' file.
I made the settings of my test project to coincide with Apple samples, but this error is
not going away. Any suggestion?
SDK: iOS 4.2,
iMac OSX 10.6.6
Thanks all.
sy
select the Target, open the Build Settings pane, search for "Preprocessor Macros". Leave the fields blank (I've got rid of a DEBUG entry)
I used the answer provided by Justin and it worked fine, until I installed Xcode 4.3.1 and the problem came back.
Currently I solved this by downloading CADebugPrintf.h and .cpp.
I found the 2 files at this link:
http://svn.perian.org/trunk/CoreAudio/PublicUtility/
Cheers.
i have three distributions of Xcode installed.
the file exists in all three.
1) verify that the file exists on your system.
2a) add a search path to your project for the PublicUtility directory
or
2b) add the header to the target's "copy headers" build phase
depending on how many depends you have for these files, you may want a more reliable approach (which exists). one (fairly) safe/easy way to do this if you use a lot of the audio technologies and sources is to add its parent dir's parent dir to your search paths or source trees (recursively).
another way is to add it to a shared build settings file.
you could also copy a specific release someplace, then add that to your search paths. just be aware that the sources get updated somewhat regularly, so you'll have to update it when it's a good time for you. in this case, you'll should change your project references as well.
Edit: Adding the search path (2a)
One way to add a search path (assuming Xcode tools are installed at : /Developer/):
1) In Xcode (3), select the target.
2) cmd+i (get info)
3) select the "Build" tab of the info window
4) enter HEADER_SEARCH_PATHS into the search field
5) if the value is not defined at this level (e.g., it is not bold), then set the value to /Developer/Extras/CoreAudio/PublicUtility/ $(inherited)
if it is already defined at that level, then add /Developer/Extras/CoreAudio/PublicUtility/ to the list of directories to search (the value).
if you want to search the library recursively, use /Developer/Extras/CoreAudio/**. this may be useful when building AUs, or other projects which require the AU includes and PublicUtility includes.
Same problem, but seemed to have fixed it by downloading from the link below and adding in the missing CADebugPrintf.h and CADebugPrintf.cpp files.
https://developer.apple.com/library/ios/samplecode/CoreAudioUtilityClasses/Listings/CoreAudio_PublicUtility_CADebugPrintf_h.html
I was having the same problem and downloading the files into the iPublicUtility folder did not solve it. I found the answer by accident while learning about .mm extension files on this page:
Objective C Project using C++ POSIX Classes
I renamed my implementation file with a .mm and the compiler errors disappeared. Hope this may help someone down the line!

Resources