如何在 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
How to build a release version of an iOS framework in Xcode?
提问by Ana
Let's say I do the following:
假设我执行以下操作:
- Open Xcode 7
- File | New | Project | Cocoa Touch Framework
- Create "TestFramework" with the Swift language
- Create a file Hello.swift with public func hello() { print("Hello") }.
- 打开 Xcode 7
- 档案 | 新 | 项目 | 可可触摸框架
- 使用 Swift 语言创建“TestFramework”
- 使用 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:
要获得发布版本,您需要更改方案设置:
Alternatively, create a new scheme for release builds.
Ensure you have a device selected. Not the simulator.
确保您选择了设备。不是模拟器。
Build your project and you should see that it gets added to this location:
(Click the arrow to navigate there in finder)
构建你的项目,你应该看到它被添加到这个位置:(单击箭头在查找器中导航)
And after drilling down, you should be able to find the release folder with your release framework inside.
回答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。