如何在 Xcode 中 link 带有“-force_load” 的库?

How to link the library with "-force_load" in Xcode?

我的其他库不允许我设置 -ObjC 或 all_load 标志。 所以我需要使用 -force_load 到 link 我的图书馆。

我的项目下有 "GoogleOpenSource.framework" 和 "GooglePlus.framework",那么如何正确映射它们才能工作。

我设置的路径是这样的:

-force_load $(PROJECT_DIR)/Project_name/GooglePlus.framework/Versions/A/Headers/GooglePlus.h

-force_load $(PROJECT_DIR)/Project_name/GoogleOpenSource.framework/Versions/A/Headers/GoogleOpenSource.h

在其他 linker 标志下,但它不起作用。

我做错了什么?

-force_load标志是加载静态库,所以你把库存档,不是头文件作为参数。

改为使用以下内容:

-force_load GooglePlus.framework/Versions/Current/GooglePlus
-force_load GoogleOpenSource.framework/Versions/Current/GoogleOpenSource

我遇到了同样的问题,但最后我通过以下提到的步骤解决了这个问题:-

步骤

  1. 转到项目构建设置中的"other linker flags",然后
  2. 添加-force_load $(PROJECT_DIR)/yourframewokname.framework/yourframeworkname

注意** 需要在其他链接器标志中添加 -ObjC 标志的框架在这​​种情况下会与其他库冲突,因此在这种情况下您需要强制加载需要 -ObjC 的库。

使用上述步骤有效。