无法在 xcode 中生成 iOS App 存档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10715211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:29:14  来源:igfitidea点击:

Cannot generate iOS App archive in xcode

iphoneiosxcodemacos

提问by Filip Majernik

I have a problem generating a iOS App archive from an application. The application compiles just fine and even works in the simulator. Now I wanted to make som ad hoc testing and cannot generate the iOS App Archive. When I click on the Product -> Archive it generates a generic xcode archive. Can anyone help me. I should mention, that I have already generated an iOS App Archive of this application. It has just stopped to generate iOS Archive for some reason. Thanks a lot.

我在从应用程序生成 iOS 应用程序存档时遇到问题。该应用程序编译得很好,甚至可以在模拟器中运行。现在我想做一些临时测试并且无法生成 iOS 应用程序存档。当我单击 Product -> Archive 时,它​​会生成一个通用的 xcode 存档。谁能帮我。我应该提一下,我已经生成了这个应用程序的 iOS 应用程序存档。由于某种原因,它刚刚停止生成 iOS 存档。非常感谢。

回答by Alex L

Check Build Settings:

检查构建设置:

  1. Skip install is NO for the main project target
  2. Skip install is YES for framework (sub-projects) targets
  3. In Build Phases for sub-projects, Copy Headers needs to be in Project, not Public (does not apply if building static library)
  4. Installation Directory under Deployment is valid (/Applications for example)
  1. 对于主要项目目标,跳过安装是否
  2. 对于框架(子项目)目标,跳过安装是 YES
  3. 在子项目的构建阶段,复制标题需要在项目中,而不是公共(如果构建静态库不适用)
  4. 部署下的安装目录有效(例如/Applications)

回答by delany

This can happen if you've added a framework/library ... you need to edit the Target->Build Settings of that library and set the 'Skip Install' setting to 'Yes'. When you re-archive, XCode should start producing a 'iOS App Archive' again rather than a 'generic xcode archive'.

如果您添加了框架/库,就会发生这种情况……您需要编辑该库的目标-> 构建设置并将“跳过安装”设置设置为“是”。当您重新存档时,XCode 应该再次开始生成“iOS 应用存档”而不是“通用 xcode 存档”。

回答by ebtokyo

In addition of Skip Installto Yesand in case you opened another lib/framwork project within your app project you have to move headers (if any) from publicto projectin the Build Phase/ Copy Headers.

除了Skip Installto Yes 之外,如果您在应用项目中打开了另一个 lib/framework 项目,您必须在Build Phase/ Copy Headers中将标头(如果有)从public 移动项目

build phase of your lib/framwork target

你的 lib/framework 目标的构建阶段

回答by abbood

I did the following to make it work for me:

我做了以下工作以使其对我有用:

  1. I had a three20 static library, I used cocoapodsto include the files within the main project
  2. followed the skip install for all other sub projects/static libraries and switched the copy headers from public to project as stated above
  3. most importantly:in each library your project uses go to build phases -> Copy Filesand ensured that destinationis changed from Absolute pathto products directory. Note: see the hint below to narrow your search to find the library causing this error.
  1. 我有一个three20静态库,我使用cocoapods将文件包含在主项目中
  2. 遵循所有其他子项目/静态库的跳过安装,并将复制头从 public 切换到项目,如上所述
  3. 最重要的是:在每个库项目使用去构建阶段- >复制文件,并确保目标从改变Absolute pathproducts directory。注意:请参阅下面的提示以缩小搜索范围以查找导致此错误的库。

and that was it!

就是这样!

hint:to get an idea of the offending files that's causing your archive to create an archive file rather than an ipa do this:

提示:要了解导致存档创建存档文件而不是 ipa 的违规文件,请执行以下操作:

  1. Select the archive and click the Distribute button.
  2. Select the 'Save Built Products' option.
  3. Hit Next and Save.
  4. Browse the created directory in Finder.
  5. The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes.
  6. in some cases usr/local/includewill identify the culprit header files you need to move from Public to Project or the files that you have to change from absolute path to products directory (or even the files you forgot to set the skip install to yes flag). but that directory (ie usr/local/include) varies depending on your sublibrary directory structure. In many cases.. you will see allthe files listed under Copy Filesin step 3 above listed here. If you find them here, then you have a definite answer for the cause of your problem.
  1. 选择存档并单击分发按钮。
  2. 选择“保存构建的产品”选项。
  3. 点击下一步并保存。
  4. 在 Finder 中浏览创建的目录。
  5. 'libraries' 子目录将标识您需要将跳过安装设置为是的库。
  6. 在某些情况下,usr/local/include将识别您需要从 Public 移动到 Project 的罪魁祸首文件,或者您必须从绝对路径更改为 products 目录的文件(甚至是您忘记将跳过安装设置为 yes 标志的文件)。但该目录(即 usr/local/include)因您的子库目录结构而异。在许多情况下.. 您将看到此处列出的上述步骤 3 中的复制文件下列出的所有文件。如果您在这里找到它们,那么您对问题的原因就有了明确的答案。


update to hint:to make life even more simpler.. whatever files appears under step 4 in hintabove.. simply search for it in the global search of xcode.. and you should get immediate results for what you want.. for example, this was the content of my folder (following the steps in hint above):

更新提示:让生活更简单..上面提示中第 4 步下出现的任何文件.. 只需在 xcode 的全局搜索中搜索它.. 你应该立即得到你想要的结果.. 例如,这是我的文件夹的内容(按照上面提示中的步骤):

enter image description here

在此处输入图片说明

So I could tell it has something to do with the cryptoand ssllibraries.. searching for them:

所以我可以说它与cryptossl库有关..搜索它们:

enter image description here

在此处输入图片说明

made me realize that i forgot to set skip install to yes.

让我意识到我忘记将跳过安装设置为是。

回答by Josh Habdas

If you export the archive, open it and see /urs/local/includein Productstry this suggestion:

如果您导出存档,请打开它并/urs/local/include产品中查看尝试此建议

In each pod, under Packaging, Private Headers Folder Pathand Public Headers Folder Pathis set to /usr/local/include. If I clear them then I get a valid archive.

在每个 pod 中,下Packaging,Private Headers Folder PathPublic Headers Folder Path设置为/usr/local/include。如果我清除它们,那么我会得到一个有效的存档。

enter image description here

在此处输入图片说明

Worked for me after upgrading my React Native app to 0.11.0, Xcode 7and CocoaPods 0.39.0.beta.4.

将我的 React Native 应用程序升级到0.11.0Xcode7和 CocoaPods后为我工作0.39.0.beta.4

回答by rebello95

If you're using CocoaPods as well as WatchKit or a Today Extension, there is an open issueon the CocoaPods repo explaining what your problem might be.

如果您使用 CocoaPods 以及 WatchKit 或 Today Extension,则CocoaPods 存储库上有一个未解决的问题,解释了您的问题可能是什么。

The solutionfor me was to remove the Copy Pod Resourcesphase from the WatchKit Extension and Today Extension targets under Build Phases. The project compiled and archived as expected once I did this.

我的解决方案Copy Pod ResourcesBuild Phases. 完成此操作后,该项目按预期编译和存档。

Hope this helps someone, this had me stumped for an entire day!

希望这对某人有帮助,这让我难倒了一整天!

回答by Ehmad Zubair

If any of the above answers don't work, your issue is probably with cocoaPods. The latest update 0.38.1messed things up for me, but then i downgraded to 0.37.1and things returned to normal. Using Xcode 6.3.1

如果上述任何答案都不起作用,则您的问题可能与cocoaPods. 最新的更新0.38.1对我来说把事情搞砸了,但后来我降级了0.37.1,事情又恢复了正常。使用Xcode 6.3.1

Later edit:updating to 0.38.2will also fix this. More info about what caused this issue here: Cocoapods 0.38.1 failed to create valid Archive

稍后编辑:更新到0.38.2也将解决此问题。有关导致此问题的原因的更多信息:Cocoapods 0.38.1 failed to create valid Archive

回答by Stephen Watson

Although I'm using Xcode5 and what sorted it for me was editing the Build Scheme - trying all of the above suggestions that were applicable didn't help in my case.

尽管我使用的是 Xcode5 并且对我进行排序的是编辑构建方案 - 尝试上述所有适用的建议对我的情况没有帮助。

I had two targets, say, "App" and "App FREE". My problems with the generic archive happened when I was trying to Archive the FREE version, which I added after the 'normal' version of the app. In my case, when I selected its Scheme in the toolbar and chose Edit Scheme ... I saw that Build section had two targets, namely App and App FREE.

我有两个目标,比如“App”和“App FREE”。我在尝试存档免费版本时发生了通用存档的问题,这是我在应用程序的“正常”版本之后添加的。就我而言,当我在工具栏中选择它的 Scheme 并选择 Edit Scheme 时......我看到 Build 部分有两个目标,即 App 和 App FREE。

I unchecked all columns for App, leaving only App FREE's columns checked, and clicked OK. Next time I chose Product > Archive I got my App FREE instead of a Generic Archive. :)

我取消选中 App 的所有列,只选中 App FREE 的列,然后单击“确定”。下次我选择产品 > 存档时,我的应用程序是免费的,而不是通用存档。:)

回答by roman777

If you have only single project, maybe this solution would be useful. This problem had occurred, when I duplicated the target. As a result I had two targets parallel built. This was causing the issue. Generic IOS archive was built.

如果您只有一个项目,也许这个解决方案会很有用。当我复制目标时发生了这个问题。结果我并行构建了两个目标。这导致了这个问题。通用 IOS 存档已构建。

To turn the parallel built off go to

要关闭并行构建,请转到

  • Manage schemes,
  • Edit scheme,
  • Build,
  • Remove the other target.
  • 管理计划,
  • 编辑方案,
  • 建造,
  • 移除另一个目标。

回答by julianwyz

I had this problem after updating to iOS 9 and Xcode 7. Josh H's solution worked for me:

更新到 iOS 9 和 Xcode 7 后我遇到了这个问题。Josh H 的解决方案对我有用:

In each pod, under Packaging, Private Headers Folder Path and Public Headers Folder Path is set to /usr/local/include. If I clear them then I get a valid archive.

在每个 pod 中,在 Packaging 下,Private Headers Folder Path 和 Public Headers Folder Path 设置为 /usr/local/include。如果我清除它们,那么我会得到一个有效的存档。

I also made a post install script for my Podfile to do this automatically!

我还为我的 Podfile 制作了一个安装后脚本来自动执行此操作!

    post_install do |installer_representation|
        installer_representation.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['PUBLIC_HEADERS_FOLDER_PATH'] = [""];
                config.build_settings['PRIVATE_HEADERS_FOLDER_PATH'] = [""];
            end
        end
    end

Just add it to the bottom of your Podfile and run pod install

只需将它添加到 Podfile 的底部并运行 pod install