如何在 Xcode 中构建 iOS 框架的发布版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34643800/
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-31 08:32:04  来源:igfitidea点击:

How to build a release version of an iOS framework in Xcode?

iosxcodeframeworksrelease

提问by Ana

Let's say I do the following:

假设我执行以下操作:

  1. Open Xcode 7
  2. File | New | Project | Cocoa Touch Framework
  3. Create "TestFramework" with the Swift language
  4. Create a file Hello.swift with public func hello() { print("Hello") }.
  1. 打开 Xcode 7
  2. 档案 | 新 | 项目 | 可可触摸框架
  3. 使用 Swift 语言创建“TestFramework”
  4. 使用 public func hello() { print("Hello") } 创建一个文件 Hello.swift。

From here, I can build a debug build of the framework (inside the Debug-iphoneos folder), but I cannot figure out how to build the release version of the framework (inside Release-iphoneos). I thought Archive might do it, but it doesn't. Pointers please?

从这里,我可以构建框架的调试版本(在 Debug-iphoneos 文件夹中),但我无法弄清楚如何构建框架的发布版本(在 Release-iphoneos 中)。我认为 Archive 可能会这样做,但事实并非如此。请指点?

回答by Beau Nouvelle

To get a release build, you need to change your scheme settings:

要获得发布版本,您需要更改方案设置:

enter image description hereAlternatively, create a new scheme for release builds.

enter image description here或者,为发布版本创建一个新方案。

Ensure you have a device selected. Not the simulator.

确保您选择了设备。不是模拟器。

enter image description here

enter image description here

Build your project and you should see that it gets added to this location: (Click the arrow to navigate there in finder) enter image description here

构建你的项目,你应该看到它被添加到这个位置:(单击箭头在查找器中导航) enter image description here

And after drilling down, you should be able to find the release folder with your release framework inside. enter image description here

向下钻取后,您应该能够找到包含您的发布框架的发布文件夹。 enter image description here

回答by Leszek Szary

This works for me:

这对我有用:

Select your framework target then click Product -> Archive. If organizer window does not pop up after successfull build of your framework then go to "Build Settings" of your framework target, look for option "Skip Install" and change it to "No" (and after that Archive again).

选择您的框架目标,然后单击产品 -> 存档。如果在成功构建框架后没有弹出管理器窗口,则转到框架目标的“构建设置”,查找选项“跳过安装”并将其更改为“否”(然后再次存档)。

回答by Ferenc Kiss

When you add the framework to your other Xcode project then you have to add "$(BUILT_PRODUCTS_DIR)" to Build Settings -> Framework Search Paths. This will create Debug when you run project (with Debug) and will create Release version when you archive project. The archive doesn't will create Release version under Products dir but will create Release in "Intermediates.noindex" folder.

当您将框架添加到其他 Xcode 项目时,您必须将“$(BUILT_PRODUCTS_DIR)”添加到构建设置 -> 框架搜索路径。这将在您运行项目(使用 Debug)时创建 Debug,并在您归档项目时创建 Release 版本。存档不会在 Products 目录下创建 Release 版本,但会在“Intermediates.noindex”文件夹中创建 Release。