I'm having an issue with frameworks not being recognized:
For some reason the path for the frame work is set to Derived Data folder:
Is there anyway to change this to point the frameworks search the right folder?
Also, what kind of language is this and how would I go about changing the directory to the proper module (in the repo)?
Thank you for any insights you can provide, this is confusing for an amateur like me.
Is there anyway to change this to point the frameworks search the right folder?
Yes, and you seem to have found the Framework Search Paths setting in the project already. Change that setting to include your frameworks folder and Xcode should start seeing your frameworks.
Also, what kind of language is this and how would I go about changing the directory to the proper module
It's not a language at all, its just a list. When you double-click in the right-hand column of the setting, as you've done in the image above, a view opens that lets you edit the list. It's not shown in your image, but at the bottom of that view there are + and - buttons — click the + and you'll add another item to the list. You can add your folder there.
The $DEVELOPER_FRAMEWORKS_DIR item that you see in the list is just the value of the DEVELOPER_FRAMEWORKS_DIR project variable. Each of the settings in the build settings have a corresponding variable that the setting changes — the variable for each setting is listed in the Quick Help panel for that setting. The $(inherited) is a sort of macro within the Xcode build system — it specifies the values that have been inherited for that build setting from other settings levels. See What is $(inherited) in Xcode's search path settings? for more information about inherited.
You shouldn't add an absolute path to the Framework Search Paths setting, e.g. one that starts with /Users/yourname/Library/... because then the project will only build on your machine. Instead, you should specify the path relative to some point in the project, and the various environment variables in Xcode can help. If you want to specify a folder called Frameworks at the top level of the project directory, for example, you could add an item to Framework Search Paths that says $PROJECT_DIR/Frameworks. You can find a list of project variables here: How do I print a list of "Build Settings" in Xcode project?
Related
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.
I thought it would be interesting to attempt building multiple apps using the same code base, where the only differentiating data is held in a few plists. For example, one plist holds some theme info - a few key/values to drive the color scheme used in the app. I'll call the original version of this theme.plist.
I soon learned that I should create multiple targets in my project, and have been able to add these successfully. Each one, via it's own appname-info.plist, has a different name and bundle id - it's neat seeing all three on my home screen without any real extra work.
But right now they are all identical. I haven't figured out how to use a different set of data for each one.
My first thought was to have some folder for each target - each with its own theme plist named theme.plist - and somehow distribute each target with a different folder. But researching that idea doesn't get me much google juice.
So what about multiple theme files? Ok, so far that looks better - I can create an app1-theme.plist and 'app2-theme.plist' with different values for the same keys in each. And Xcode even lets me use some flags to say which targets should include each resource.
But I don't know how to load the appropriate plist at runtime. I need to examine something (the bundle ID?) and then assign the appropriate name of the theme plist to something (what)?
It seems like this might have something to with #ifdef, whatever that might be...?
Can someone explain how I should be looking to accomplish this? Am I on the right track? I'm happy to put some reading time in but I don't even know what to look up yet.
You are just about there. Xcode supports having multiple files with the same name in a project, one way you can do this by storing them in different folders within your project folder.
Unfortunately at this point Xcode won't give you a lot of help, so open your project in the Finder, create one subfolder for each of your apps, in those folders place a copy of the plist. Now add each copy in turn to your project, making sure you add each to just one of your targets.
You might want to create a group in Xcode called, say, "Theme files", to keep them altogether.
HTH
What you are trying to do is trivial. If you select a file from your project, and bring up the "File Inspector" in the utilities area (Press Command option 1) you should see a section "Target membership". Each target in your project will be listed, with a checkbox next to it. If you check the checkbox for a file and target, that file is built into that target. Un-check the checkbox for a file and target and that file is not copied over to the specified target (you may need to run a clean, and delete the app from the target device, to get rid of files that used to be included but that you have un-checked. Xcode generally won't automatically remove things that used to be included.
You could create a directory in your bundle and teach your app to scan that directory for plist files. Then include a different set of files in that directory for each target and each target app's behavior will change.
All of a sudden today I get an unexpected problem with Xcode (5).
This is how I normally add an external framework:
Drag-n-drop the file (xxx.framework etc) (or the folder which contains the file) into the project manager.
In "Choose options for adding files" I check "Copy items into destination (if needed)" only if needed (if the files are already in the project's folder I don't do this)
In "Folders" I select Create groups for any added folders
And I add it to my app target.
Normally this would also add the relative path(s) to the framework in Build Settings/Framework Search Paths and Library Search Paths.
However today the path that shows up there is direct (aka absolute). This breaks stuff down the line because the paths should be relative. How come Xcode does this all of a sudden? I suspect it might have to do with this one project only (it comes from a 3rd part dev) and something about their project setup could be causing this.
I faced the same issue. There is a simple fix. Go to framework search paths. Remove everything from there. Add ./ and make it recursive. That's it.
I am having the same problem on XCode 5, so far the best solution is to modify the path of your framework search.
Go to your project
Build settings->Framework search path
Add the relative path to your framework.
If it was correctly copied now you can modify the path, to something like this:
./MyProject/Libraries/ACoolLibrary
Supposing a file structure like this:
-MyProject.xcodeproj
-MyProject
--Libraries
-----ACoolLibrary
-------- TheCoolLibrary.framework
Ok, here's what I've tried.
I have the header files in two separate directories IRL. They're named the same, but are in two different locations.
I want to only include the relevant header file for each target. Lets say for ease of explaination that the header file is called "Config.h".
So I have:
${PRODUCT_DIR}/Header1/Config.h
and
${PRODUCT_DIR}/Header2/Config.h
These files appear in the LHS of Xcode as well in two different groups (Header1 and Header2 which point to the IRL folders).
So now all I need to do is to make Xcode choose the right one from the right folder for each target.
Target1
and
Target2
I have tried adding the path to the User Header Search Paths for each target, but its still choosing the wrong one. I've also tried toggling "Always search user paths" which also doesn't seem to have an effect.
So my question is, is this because they're in the Project directory? Or is it because they're in Xcode in the file manager on the LHS, so therefore Xcode is copying them into the build folder?
The strange thing is it seems to be choosing the header files from the folder with the last name alphabetically...
In previous versions of Xcode I'm sure you could choose which headers to copy into the build folder.
Anyway.. does anyone know how I can fix this so that I can have it select the proper header file for the target?
Many thanks.
The problem I was having was 2 fold:
You need to remove the header files from the project. If they're in Xcode, in the file manager, then they will automatically be included in the project.
You need to use relative paths to your folders in "User Header Search Paths". I was using ${PROJECT_DIR}/path/to/header/folder which gave the right path, but didn't seem to work properly. Changing the entry to ./path/to/header/folder instead worked fine.
I have 4 targets in 1 proyect and more than 40 headers, the best solution in XCode 8
I think the best solution is change the following tag:
Always Search user Paths
To yes an all was fine for me:
I am trying to add 3 targets to my existing project. Dev, QA, and Prod.
The problem is that when I rename the target, during the build it looks for the target name as my project root folder, so I get a bunch of build error because all my header search path, library search paths are now broke.
Is it possible to make it so that Xcode uses the same project root name regardless of what the target name is?
Did you change the name in the box below? I had similar problems with names getting out of kilt, and it turned out this was the key if I recall. I should add if you have one target and want to duplicate it, you can select the one, then right click and get a duplicate contextual menu.
EDIT: Then, go to the Manage Schemes and make sure the name is correct there, and not "Project Copy". If all else fails grep you project in Terminal looking for "Copy" - you might have to edit the project file with vi (with it closed in Xcode!)
I found out what the problem was: $(SRCROOT)/$(PRODUCT_NAME) in my frameworks search path. $PRODUCT_NAME is being used to find the root directory of the project, and since all the targets are pointing to the same project I ended up hard-coing the project name. $(SRCROOT)/MyProject.