简体   繁体   中英

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.

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

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 ?

使用Clean Build Folderoption-shift-command-K ,或者在按住alt / option键时从Product菜单中选择它。

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 doesnt find your Framework - the Build System will usually also not find it. This forces you to act but may end up in confusing Xcode to catch an older reference.

Yes it may happen that the Header Xcode (thinks) is the right one is pointing to an old copy somewhere, can be 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 re-build it, the settings stay the same, the lists stay the same, the problem persists.

Compiler Instructions and Xcode settings and Build System settings dont match what the code tells with #import <NAME/Name.h> .

So you will check at least those 6 stages again:

  1. Is your Framework Header File published in your Framework project?
  2. are Build Settings really pointing to the right Framework Search Paths or System Framework Search Paths ?
  3. Is your Framework in Linking list ?
  4. Is your Framework in Embed Framework list ?
  5. Appears your Framework in Framework Group Folder in Workspace/Project Browser? (usually the very last Group Folder in the Browser below all your other files)
  6. 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 way 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 make Xcode aware of the wrong Build Settings.
The Linking works, embedding works, but compiling does not. The Header information is still missing.

So the solution must be to correct your Build Settings. In particular only setting the right Framework Search Path will solve those issues.

Even if you managed to kick your Derrived Data manually.
Derrived Data is the place where precompiler collects data to compile. So it can be seen as expression of what all the settings told to do. Erasing it does of course not change the settings but may fix inconsistencies related to former Build Settings.

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. Framework Search Paths and System Framework Search Paths stay the same.

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 dropp a fresh Framework reference in there.

How to know if /../ 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 informations on the very upper right side of Xcode, if there is some /../ you know you need it as well.

Also sorting of Framework Search Paths play a role of course.
First found, first wins rule because we use #import that ignores second attempts to declare.
So you can sort those entries if needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM