Xcode 4可以从静态库依赖关系中找到公共标头文件

发布于 2024-10-29 08:04:55 字数 696 浏览 8 评论 0原文

辅助搜索的备用标题

  • Xcode 找不到标头
  • Xcode 中缺少 .h
  • 未找到 Xcode .h 文件
  • 未找到词法或预处理器问题文件

我正在处理来自 Xcode 3 的 iOS 应用程序项目。我现在已转移到 Xcode 4 我的项目构建了一些静态库。

这些静态库还声明公共标头,并且这些标头由应用程序代码使用。在 Xcode 3.x 中,标头被复制(作为构建阶段)到公共标头目录,然后在应用程序项目中,公共标头目录被添加到>标题搜索列表

在 Xcode 4 下,构建目录被移动到 ~/Library/Developer/Xcode/DerivedData/my-project

问题是如何在标题搜索设置中引用这个新位置?看起来:

  • public headers目录是相对于DerivedData目录,但是
  • headers search目录是相对于其他东西(可能是项目位置)

如何我是否应该在 Xcode 4 中为 iOS 开发设置一个静态库目标,以确保在尝试编译为依赖项时使用静态库的客户端可以使用头文件?

Alternate titles to aid search

  • Xcode can't find header
  • Missing .h in Xcode
  • Xcode .h file not found
  • lexical or preprocessor issue file not found

I'm working on an iOS application project which came from Xcode 3. I have now moved to Xcode 4 my project builds a number of static libraries.

Those static libraries also declare public headers and those headers are used by the application code. In Xcode 3.x the headers were copied (as a build phase) to the public headers directory, then in the application project the public headers directory was added to the headers search list.

Under Xcode 4 the build directory is moved to ~/Library/Developer/Xcode/DerivedData/my-project.

The problem is how do I reference this new location in the headers search settings? It seems that:

  • public headers directory is relative to DerivedData directory, but
  • headers search directory is relative to something else (possibly the project location)

How should I set up a static library target for iOS development in Xcode 4 that will ensure the header files are made available to the clients that use the static library when trying to compile as a dependancy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

谁把谁当真 2024-11-05 08:04:55

我见过的解决这个问题的每个解决方案要么看起来不优雅(将标头复制到应用程序的项目中),要么过于简化以至于它们只能在微不足道的情况下工作。

简短回答

将以下路径添加到您的用户标题搜索路径

“$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts”

为什么这有效?

首先,我们需要了解问题。在正常情况下,也就是说,当您运行、测试、分析或分析时,Xcode 会构建您的项目并将输出放入 Build/Products/Configuration/Products 目录中,该目录可通过 < strong>$BUILT_PRODUCTS_DIR 宏。

大多数有关静态库的指南建议将公共标头文件夹路径设置为$TARGET_NAME,这意味着您的lib文件将变为$BUILT_PRODUCTS_DIR/libTargetName.a并且您的标头将放入 $BUILT_PRODUCTS_DIR/TargetName 中。只要您的应用在其搜索路径中包含 $BUILT_PRODUCTS_DIR,则导入将在上述 4 种情况下起作用。但是,当您尝试存档时,这将不起作用。

归档工作方式略有不同

当您归档项目时,Xcode 使用名为 ArchiveIntermediates 的不同文件夹。在该文件夹中,您将找到 /YourAppName/BuildProductsPath/Release-iphoneos/。这是您进行存档时 $BUILT_PRODUCTS_DIR 指向的文件夹。如果您查看那里,您会发现有一个指向您构建的静态库文件的符号链接,但带有标头的文件夹丢失了。

要查找标头(和 lib 文件),您需要转到 IntermediateBuildFilesPath/UninstalledProducts/。还记得当您被告知将静态库的跳过安装设置为“是”吗?这就是您制作存档时设置的效果。

旁注:如果您不将其设置为跳过安装,您的标头将被放入另一个位置,并且 lib 文件将被复制到您的存档中,从而阻止您导出可以提交到 App Store 的 .ipa 文件。

经过大量搜索,我找不到任何与 UninstalledProducts 文件夹完全对应的宏,因此需要使用“$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts”构建路径

摘要

对于您的静态库,请确保您跳过安装并将公共标头放入 $TARGET_NAME 中。

对于您的应用程序,将用户标头搜索路径设置为“$(BUILT_PRODUCTS_DIR)”(适用于常规构建)和“$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts”(适用于存档构建)。

Each of the solutions I've seen to this problem have either seemed inelegant (copying headers into the application's project) or overly simplified to the point that they only work in trivial situations.

The short answer

Add the following path to your User Header Search Paths

"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts"

Why does this work?

First, we need to understand the problem. Under normal circumstances, which is to say when you Run, Test, Profile or Analyze, Xcode builds your project and puts the output in the Build/Products/Configuration/Products directory, which is available via the $BUILT_PRODUCTS_DIR macro.

Most guides regarding static libraries recommend setting the Public Headers Folder Path to $TARGET_NAME, which means that your lib file becomes $BUILT_PRODUCTS_DIR/libTargetName.a and your headers are put into $BUILT_PRODUCTS_DIR/TargetName. As long as your app includes $BUILT_PRODUCTS_DIR in its search paths, then imports will work in the 4 situations given above. However, this will not work when you try to archive.

Archiving works a little differently

When you archive a project, Xcode uses a different folder called ArchiveIntermediates. Within that folder you'll find /YourAppName/BuildProductsPath/Release-iphoneos/. This is the folder that $BUILT_PRODUCTS_DIR points to when you do an archive. If you look in there, you'll see that there is a symlink to your built static library file but the folder with the headers is missing.

To find the headers (and the lib file) you need to go to IntermediateBuildFilesPath/UninstalledProducts/. Remember when you were told to set Skip Install to YES for static libraries? Well this is the effect that setting has when you make an archive.

Side note: If you don't set it to skip install, your headers will be put into yet another location and the lib file will be copied into your archive, preventing you from exporting an .ipa file that you can submit to the App Store.

After a lot of searching, I couldn't find any macro that corresponds to the UninstalledProducts folder exactly, hence the need to construct the path with "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts"

Summary

For your static library, make sure that you skip install and that your public headers are placed into $TARGET_NAME.

For your app, set your user header search paths to "$(BUILT_PRODUCTS_DIR)", which works fine for regular builds, and "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts", which works for archive builds.

清晨说晚安 2024-11-05 08:04:55

我在开发自己的静态库时遇到了同样的问题,尽管 Colin 的答案非常有帮助,但我必须对其进行一些修改,以便在使用工作区在 Xcode 4 下运行和存档项目时一致且简单地工作。

我的方法的不同之处在于您可以对所有构建配置使用单个用户标头路径。

我的方法如下:

创建工作区

  1. 在 Xcode 4 下,转到“文件”、“新建”、“工作区”。
  2. 然后,您可以从 Finder 中拖入要使用的静态库以及正在构建的使用该库的新应用程序的 .xcodeproj 项目。有关设置工作区的更多信息,请参阅 Apple 文档:https:// developer.apple.com/library/content/featuredarticles/XcodeConcepts/Concept-Workspace.html

静态库项目设置

  1. 确保所有静态库的标头都设置为复制到“公共”。这是在静态库目标>设置下完成的构建阶段。在“复制标题”阶段,确保所有标题都位于“公共”部分内。
  2. 接下来转到“构建设置”,找到“公共标头文件夹路径”并输入库的路径。我选择使用这个:

包含/库名称

我在 RestKit 中采用了它,并发现它最适合我的所有静态库。它的作用是告诉 Xcode 将我们在步骤 1 中移动到“公共”标头部分的所有标头复制到我们在此处指定的文件夹,该文件夹在构建时位于 Derived Data 文件夹中。与 RestKit 一样,我喜欢使用单个“include”文件夹来包含我在项目中使用的每个静态库。

我也不喜欢在这里使用宏,因为它允许我们稍后在使用静态库配置项目时使用单个用户标头搜索路径。

  1. 找到“跳过安装”并确保将其设置为“是”。

使用静态库的项目设置

  1. 在 Build Phases > 下添加静态库作为框架将二进制文件与库链接起来,并为您要使用的任何静态库添加 libLibraryName.a 文件。
  2. 接下来确保项目设置为搜索用户搜索路径。这是在“构建设置”>“构建设置”下完成的。始终搜索用户路径并确保其设置为“是”。
  3. 在同一区域中找到“用户标题搜索路径”并添加:

    “$(PROJECT_TEMP_DIR)/../UninstalledProducts/include”

这告诉 Xcode 查找用于 Xcode 在构建过程中创建的中间构建文件夹中的静态库。在这里,我们有用于静态库位置的“include”文件夹,我们在步骤 2 中为静态库项目设置设置了该位置。这是让 Xcode 正确找到静态库的最重要的一步。

配置工作区

这里我们要配置工作区,以便在我们构建应用程序时它将构建静态库。这是通过编辑我们的应用程序使用的方案来完成的。

  1. 确保您选择了将创建您的应用程序的方案。
  2. 从方案下拉列表中,选择编辑方案。
  3. 选择左侧列表顶部的“构建”。按中间窗格上的 + 添加新目标。
  4. 您应该看到您尝试链接的库出现静态库。选择iOS静态库。
  5. 单击“运行”和“存档”。这告诉方案在构建应用程序时编译静态库的库。
  6. 将静态库拖动到应用程序目标上方。这使得静态库在您的应用程序目标之前编译。

开始使用库

现在,您应该能够使用以下方法导入静态库。

import <LibraryName/LibraryName.h>

此方法解决了不同配置必须具有不同用户标头路径的麻烦,因此编译存档应该没有问题。

为什么这有效?

这一切都取决于此路径:

"$(PROJECT_TEMP_DIR)/../UninstalledProducts/include"

因为我们将静态库配置为使用“Skip Install”,所以编译后的文件将移动到临时构建目录中的“UninstalledProjects”文件夹中。我们此处的路径也解析为我们为静态库设置并用于用户标头搜索路径的“include”文件夹。两者一起工作让 Xcode 知道在编译过程中在哪里可以找到我们的库。由于调试和发布配置都存在此临时构建目录,因此您只需要 Xcode 的单个路径即可搜索静态库。

I ran into this same issue when developing my own static library and although Colin's answer was very helpful, I had to modify it a bit to work consistently and simply when both running and archiving projects under Xcode 4 using a Workspace.

What's different about my method is you can use a single user header path for all your build configurations.

My method is as follows:

Create a Workspace

  1. Under Xcode 4, go to File, New, Workspace.
  2. From Finder you can then drag in the .xcodeproj projects for both the static library you want to use, and the new app you are building that uses the library. See Apple Docs for more info on setting up Workspaces: https://developer.apple.com/library/content/featuredarticles/XcodeConcepts/Concept-Workspace.html

Static Library Project Settings

  1. Make sure all the static library's headers are set to copy to "Public". This is done under the settings for the static library target > Build Phases. In the "Copy Headers" phase, make sure all your headers are within the "Public" section.
  2. Next go to Build Settings, find "Public Headers Folder Path" and type in a path for your library. I choose to use this:

include/LibraryName

I've adopted this from use with RestKit and found it works best with all my static libraries. What this does is tells Xcode to copy all the headers we moved to the "Public" headers section in step 1 to the folder we specify here which resides within the Derived Data folder when building. Like with RestKit, I like using a single "include" folder to contain each static library I'm using in a project.

I also don't like using macros here because it will allow us to use a single user header search path later when we configure the project using the static library.

  1. Find "Skip Install" and make sure this is set to YES.

Settings for the Project Using the Static Library

  1. Add the static library as a framework under Build Phases > Link Binary With Libraries and add the libLibraryName.a file for whatever static library you want to use.
  2. Next make sure project is set to search for User Search Paths. This is done under Build Settings > Always Search User Paths and make sure its set to YES.
  3. In the same area find User Header Search Paths and add:

    "$(PROJECT_TEMP_DIR)/../UninstalledProducts/include"

This tells Xcode to look for static libraries within the intermediate build folder that Xcode creates during the build process. In here, we have the "include" folder we are using for our static library locations we setup in step 2 for the static library project settings. This is the most important step in getting Xcode to correctly find your static libraries.

Configure the Workspace

Here we want to configure the workspace so that it will build the static library when we build our app. This is done by editing the scheme used for our app.

  1. Make sure you have the scheme selected that will create your application.
  2. From the scheme drop-down, choose Edit Scheme.
  3. Select Build at the top of list on the left. Add a new target by pressing the + on the middle pane.
  4. You should see the static library show up for the library you are trying to link. Choose the iOS static library.
  5. Click both Run and Archive. This tells the scheme to compile the libraries for the static library whenever you build your app.
  6. Drag the static library above your application target. This makes the static libraries compile before your application target.

Start Using the Library

Now, you should be able to import your static library using

import <LibraryName/LibraryName.h>

This method gets around the hassle of having to have different user header paths for different configurations, so you should have no problem compiling for archives.

Why does this work?

It all depends on this path:

"$(PROJECT_TEMP_DIR)/../UninstalledProducts/include"

Because we configure our static library to use "Skip Install", the compiled files are moved to the "UninstalledProjects" folder within the temporary build directory. Our path here also resolves to the "include" folder we setup for our static library and use for our user header search path. The two working together lets Xcode know where to find our library during the compile process. Since this temporary build directory exists for both Debug and Release configurations, you only need a single path for Xcode to search for static libraries.

怎会甘心 2024-11-05 08:04:55

Xcode 4 项目无法编译静态库

相关问题:“词法或预处理器问题文件Xcode 4 中未找到”

错误可能包括:缺少头文件、“词法或预处理器问题”

解决方案:

  1. 检查“用户头路径”是否正确 将
  2. “始终搜索用户路径”设置为 YES
  3. 创建一个组在项目中调用“索引标头”并将标头拖动到该组,请勿在出现提示时添加到任何目标。

Xcode 4 Project Fails to compile a static library

Related question: “lexical or preprocessor issue file not found ” in Xcode 4

Errors might include; missing header files, "lexical or preprocessor issue"

Solutions:

  1. Check the "user header paths" are correct
  2. Set "Always search user paths" to YES
  3. Create a group call "Indexing headers" in your project and drag the headers to this group, DO NOT add to any targets when prompted.
南薇 2024-11-05 08:04:55

这是一个非常有帮助的线程。在研究我自己的情况时,我发现 Apple 有一份 2012 年 9 月的 12 页文档,标题为“在 iOS 中使用静态库”。这是 pdf 链接: http://developer.apple.com/library/ios/technotes/iOSStaticLibraries /iOSStaticLibraries.pdf

它比大多数互联网讨论要简单得多,并且通过一些小修改来说明我正在使用的外部库的配置方式,它对我来说效果很好。最重要的部分可能是:

如果您的库目标有“复制标头”构建阶段,您应该
删除它;复制标头构建阶段无法与静态一起正常工作
在 Xcode 中执行“存档”操作时的库目标。

使用 Xcode 4.4 或更高版本创建的新静态库目标将会出现
具有适当配置的标头复制文件阶段,因此您
在创建之前应该检查一下您是否已经拥有一个。如果
如果您不这样做,请按目标编辑器底部的“添加构建阶段”
并选择“添加副本文件”。公开新的复制文件版本
阶段并将目标设置为“产品目录”。设置子路径
包括/${PRODUCT_NAME}。这会将文件复制到名为的文件夹中
在您的库之后(取自 PRODUCT_NAME 构建设置),在里面
一个名为 include 的文件夹,位于您的构建产品目录中。这
默认情况下,构建产品目录中的 include 文件夹
应用程序的标头搜索路径,因此这是一个合适的位置
放置头文件。

我确信,在许多现有情况下,苹果的方法可能还不够。我在这里为那些刚刚开始静态图书馆花园路径之旅的人发布此内容 - 这可能是简单案例的最佳起点。

This was a very helpful thread. In researching for my own situation, I found that Apple has a 12-page document dated September 2012 titled "Using Static Libraries in iOS." Here's the pdf link: http://developer.apple.com/library/ios/technotes/iOSStaticLibraries/iOSStaticLibraries.pdf

It's much simpler than most of the Internet discussion, and with some small mods to account for how the external libraries I'm using are configured, it's working well for me. The most important part is probably:

If your library target has a “Copy Headers” build phase, you should
delete it; copy headers build phases do not work correctly with static
library targets when performing the “Archive” action in Xcode.

New static library targets created with Xcode 4.4 or later will come
with an appropriately-configured Copy Files phase for headers, so you
should check to see if you already have one before creating one. If
you do not, press “Add Build Phase” at the bottom of the target editor
and choose to “Add Copy Files.” Disclose the new Copy Files build
phase and set the Destination to “Products Directory.” Set the Subpath
to include/${PRODUCT_NAME}. This will copy files into a folder named
after your library (taken from the PRODUCT_NAME build setting), inside
a folder named include, inside your built products directory. The
include folder inside a build products directory is in the default
header search path for applications, so this is an appropriate place
to put header files.

I am sure that in many existing situations Apple's approach may not be enough. I post this here for anyone who is just beginning their journey on the static library garden path - this may be the best starting point for simple cases.

孤者何惧 2024-11-05 08:04:55

http://developer.apple.com/library/ios/ #technotes/iOSStaticLibraries/Articles/creating.html

根据 Apple 文档:

您的库将具有该库的客户端需要导入的一个或多个头文件。要配置将哪些标头导出到客户端,请选择库项目以打开项目编辑器,选择库目标以打开目标编辑器,然后选择构建阶段选项卡。如果您的库目标有“复制标头”构建阶段,您应该删除它;在 Xcode 中执行“存档”操作时,复制标头构建阶段无法与静态库目标正常工作。

http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html

Per Apple documention:

Your library will have one or more header files that clients of that library need to import. To configure which headers are exported to clients, select your library project to open the project editor, select the library target to open the target editor, and select the build phases tab. If your library target has a “Copy Headers” build phase, you should delete it; copy headers build phases do not work correctly with static library targets when performing the “Archive” action in Xcode.

秋日私语 2024-11-05 08:04:55

看看 Jonah Wlliam 的解决方案(中间向下)& GitHub 模型(在评论中)以获得见解。
http://blog. Carbon Five.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

Take a look at Jonah Wlliam's solution (mid way down) & GitHub model (in comments) for an insight.
http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

窝囊感情。 2024-11-05 08:04:55

$(OBJROOT)/UninstalledProducts/exactPathToHeaders 添加到标题搜索路径。

由于某种原因,递归复选框对我不起作用,我必须添加其余的标头所在位置的路径。

在 Xcode 中的日志导航器(断点导航器右侧的选项卡)下,您可以看到构建历史记录。如果您选择实际构建失败,您可以展开其详细信息以查看 setenv PATH 并检查以确保头文件的路径在那里。

Add $(OBJROOT)/UninstalledProducts/exactPathToHeaders to the Header Search Paths.

For some reason the recursive checkbox didn't work for me and I had to add the rest of the path to where the headers are located.

Under the Log Navigator in Xcode (the tab to the right of the break points navigator) you can see the build history. If you select the actual build failure you can expand its details to see the setenv PATH and check to make sure the path to your header files is there.

去了角落 2024-11-05 08:04:55

上面的答案在 Xcode 7 上都不适合我,但它们给了我一个好主意。对于那些在 Xcode 7 上苦苦挣扎的人,我通过将以下内容添加到用户头搜索路径(包括引号)来解决此问题

"$(BUILT_PRODUCTS_DIR)/usr/local/include"

根据“公共头文件夹”中的内容更改相对 URL 部分 usr/local/include静态库路径设置

None of the answers above worked for me on Xcode 7 but they gave me a good idea though. For guys struggling on Xcode 7, I got this fixed by adding the following to User Header Search Paths (include quotes)

"$(BUILT_PRODUCTS_DIR)/usr/local/include"

Change the relative URL part usr/local/include according to what's there in 'Public Header Folder Path' setting of static library

仅冇旳回忆 2024-11-05 08:04:55

就我而言,我的工作区有几个静态库项目,其中一个项目具有依赖关系,包括与另一个项目的头文件。问题出在建造顺序上。在“构建”部分下的“编辑方案”页面中,我取消选择并行化选项并根据依赖关系排列目标的顺序,并解决了问题

In my case my workspace had a couple of static library projects and one of them has dependency including header files with the other. The issue was with the order of building . In edit Scheme page under Build section, I deselected parallelize option and arranged the order of the targets as per the dependencies and it solved by problem

挖个坑埋了你 2024-11-05 08:04:55

将以下路径添加到您的用户标题搜索路径中:

$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts

已验证!

Add the following path to your User Header Search Paths:

$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts

This is verified!

寄离 2024-11-05 08:04:55

冒着暴露我是个白痴的风险...我整个下午都在遭受 XCode 拒绝找到我的 .h 文件的痛苦。

然后我意识到了。

因为我使用的是“XCode 4”,所以我“明智地”决定将所有项目放入名为“XCode 4 项目”的文件夹的子文件夹中。

文件夹名称中的那些空格将 XCode 搞得一团糟!

将此文件夹重命名为“XCode_4_Projects”给我的生活带来了欢乐(并且减少了咒骂)。

再次提醒我,今年是哪一年?

也许有人可以告诉苹果开发者......

At the risk of showing what an idiot I am... I've been suffering from XCode refusing to find my .h files all afternoon.

Then I realised.

Because I was using "XCode 4", I had "intelligently" decided to put all of my projects in a subfolders of a folder called "XCode 4 projects".

Those spaces in the folder name messed up XCode big-time !

Renaming this folder to "XCode_4_Projects" has brought joy (and less swearing) back into my life.

Remind me again, what year is this ?

Perhaps someone could tell the Apple developers...

不顾 2024-11-05 08:04:55

这些答案都不适合我。这就是所做的。将以下内容准确添加(复制并粘贴,包括双引号)到您的用户标头搜索路径构建设置:

"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include/"

请注意与其他答案相比,添加了“/include/”子目录。正如其他用户所指出的,“递归”选项似乎没有做任何事情,因此您可以忽略它。

的项目现在能够在以以下形式导入静态库头文件时成功归档:

#import "LibraryName/HeaderFile.h"

不需要需要启用始终搜索用户路径设置,除非您使用尖括号包含静态库标头(#import),但如果它不是系统/框架标头,那么无论如何你都不应该这样做。

None of these answers worked for me. Here's what did. Add the following exactly (copy and paste including the double-quotes) to your User Header Search Paths build setting:

"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include/"

Note the addition of the "/include/" subdirectory as compared to other answers. As other users have pointed out, the "recursive" option doesn't seem to do anything, so you can ignore it.

My project was now able to archive successfully when importing static library header files in the following form:

#import "LibraryName/HeaderFile.h"

You do not need to enable the Always Search User Paths setting unless you are including your static library headers with angle brackets (#import <LibraryName/HeaderFile.h>), but you really shouldn't be doing it that way anyway if it's not a system/framework header.

不一样的天空 2024-11-05 08:04:55

这是一个相关问题,导致我提出这个问题,因此我严格添加我的解决方案以用于文档/它可以节省另一个灵魂时间的汗水

DropboxSDK.h 文件未找到

经过几天的尝试获取 VES为了针对 iOS 进行编译,我最终遇到了这个问题。 DropboxSDK.h 绝对可以到达搜索标头,我什至将其添加到framework headers 搜索路径,include直接找到.h,并竭尽全力尝试找到DropboxSDK.h

解决方案

EXPLICITYDropboxSDK.framework文件拖动到Xcode的项目导航中,并确保选中如果需要复制文件。还要确保根据需要检查您的目标。

警告

构建阶段中设置显式框架位置对我来说不起作用。我必须将 .framework到 Xcode 中,并确保将文件复制到我的项目中。

#mbp2015 #xcode7 #ios9

This is a related issue which led me to this question so I'm adding my solution strictly for documentation / it could save another soul hours of sweating

DropboxSDK.h file not found

After days of trying to get VES to compile for iOS I eventually ran into this issue. the DropboxSDK.h was definitely in reach of search headers I even added it to the framework headers search path, included the .h directly and went to all sorts of great lengths to try and get DropboxSDK.h found.

Solution

EXPLICITY drag the DropboxSDK.framework file into Xcode's Project Navigation and make sure Copy Files if needed is checked. Also make sure your target is checked as needed.

Warning

Setting the explicit framework location in build phases did not work for me. I had to drag the .framework into Xcode and make sure the files copied to my project.

#mbp2015 #xcode7 #ios9

兲鉂ぱ嘚淚 2024-11-05 08:04:55

有各种复杂的方法可以做到这一点,并且在此线程中提出了一些非常聪明的解决方案。

所有这些解决方案的主要问题是它严重降低了库的可移植性。

  • 每次您需要使用您的资料库开始一个新项目并将其存档到 iTunes 时,
    这是一个配置地狱。
  • 每次您需要分享您的项目时
    与您的团队或客户一起,它可能会因任何原因而中断(上下文、
    Xcode 版本,无论如何,..)

我的选择最终是简单地使用框架 - 始终 - 正如 Apple 推荐的(WWDC 视频)。

它是如此简单,并且最终完成相同的工作!

另一个相当优雅且可行的解决方案是使用 Private Cocoapods。
Cocoapods 完成所有配置工作、标头复制等。

框架摇滚!

There is various complex ways to do this, and some very smart solutions are proposed in this thread.

The main problem to all these solution is that it seriously decrease your library portability.

  • Each time you need to start a new project using your library and archive it for iTunes,
    it's a configuration hell.
  • Each time you need to share your project
    with your team or customers, it can break for any reason ( context,
    Xcode version, whatever,.. )

My choice has been finally to simply use frameworks - always - as recommended by Apple ( WWDC Videos ).

It is so easier and does the same job at the end !

Another quite elegant solution which seems to work is to use Private Cocoapods.
Cocoapods does all the configuration work, header copy and so.

Frameworks rock !

晚雾 2024-11-05 08:04:55

这就是为我解决同样问题的方法。

我有一个应用程序目标和一个 iMessage 扩展目标。
然后我有 2 个 SDK(我自己的),App Target 链接到它们。

问题是:我的 iMessage 目标也在使用我的 2 个 SDK(单独的项目),但它没有在构建阶段中链接到它们 -->将二进制文件与库链接。我必须将我的 2 个 SDK 添加到那里的 iMessage 目标,以匹配我的应用程序目标,现在它已存档。

所以这个故事的寓意是:如果您有多个目标(例如扩展),请确保所有目标都链接到它们所需的库。它能够构建并部署到模拟器和设备,但不能存档。

Here is what solved the same problem for me.

I have an App Target, and an iMessage Extension Target.
Then I had 2 SDKs (my own), which the App Target links against.

The problem was: my iMessage target was also using the 2 SDKs of mine (separate projects), but it wasn't linking against them in Build Phases --> Link Binary With Libraries. I had to add my 2 SDKs to the iMessage Target there, to match my App target, and now it archives.

So the moral of the story is: If you have multiple targets, such as extensions, make sure that all of your targets are linking against the libraries they need. It was able to Build and Deploy to Simulator and Device, but not Archive.

李白 2024-11-05 08:04:55

更新:Xcode 9

上述答案对使用 Xcode 9 的我不起作用,但是这个答案非常适合我。我已将 $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include 添加到我的“标头搜索路径”中,并且 Xcode 确实链接了我的静态库的标头,没有任何问题。

Update: Xcode 9

The above answers did not work for me using Xcode 9, but this answer worked perfectly for me. I have added $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include to my "Header Search Paths" and Xcode did link the header of my static library with no problems.

仙气飘飘 2024-11-05 08:04:55

当您创建静态库 .modulemap 时,除了 .a 库之外还会生成 umbrella.h

要使用 Objective-C 静态库,您应该

  • 链接库- 将库添加为依赖
  • 项集库搜索路径
  • 设置标题搜索路径

[示例]

When you create static library .modulemap and umbrella.h is generated additionally to .a library

To use objective-C static library you should

  • Link Library - add library as dependency
  • set Library Search paths
  • set Header Search Paths

[Example]

不回头走下去 2024-11-05 08:04:55

省去麻烦,这样做 = 在 Mac 上创建新用户帐户 - 在新用户帐户下打开项目 - 所有问题都会消失。节省您的时间并保持理智。所有这些书呆子的回复都没有帮助!

祝你好运

Save yourself the trouble and do this = create new user account on your Mac -- open the project under the new user account-- all problems disappear. Save your time and keep your sanity. all of those nerdy replies don't help!!

Good Luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文