简体   繁体   English

Xcode 8构建成功,但无法归档

[英]Xcode 8 Builds Successfully but Fails on Archive

I am writing a program in Swift using Mac OS Sierra and Xcode 8.3.2 and am using the RandomKit module from: https://github.com/nvzqz/RandomKit . 我正在使用Mac OS Sierra和Xcode 8.3.2在Swift中编写程序,并且正在使用来自以下网址的RandomKit模块: https : //github.com/nvzqz/RandomKit I am using the basic Swift Package Manager to import the package into my project. 我正在使用基本的Swift软件包管理器将软件包导入到我的项目中。

My program builds and runs fine, but when I go to archive it, I get an error saying "No such module 'RandomKit' 我的程序可以构建并运行良好,但是当我将其存档时,出现错误消息“没有这样的模块'RandomKit'

It highlights my code: 它突出显示了我的代码:

import RandomKit

Does anyone know why this would build and run but fail when I attempt to archive? 有谁知道为什么它会生成并运行,但是在我尝试存档时却失败了?

By default, when you Run in XCode, it uses the Debug configuration, and when you Archive , it uses the Release configuration. 默认情况下,在XCode中运行时,它使用Debug配置,而在Archive中 ,它使用Release配置。 In Build Settings , look at the Build Active Architecture Only setting. 在“ Build Settings ,查看“ Build Active Architecture Only设置。 By default, it is Yes for Debug , and No for Release . 默认情况下,对于DebugYes ,对于ReleaseNo

This means that when you Run , XCode only builds for the simulator's architecture, but when you Archive , it builds for all possible iOS architectures. 这意味着,当您运行时 ,XCode仅针对模拟器的体系结构构建,而当您存档时 ,它针对所有可能的iOS体系结构构建。

Now, look at the settings for RandomKit to see what architectures it is built for. 现在,查看RandomKit的设置以查看其构建的体系结构。 It needs to include all of the iOS architectures, like arm64 , armv7 , and armv7s . 它需要包括所有iOS体系结构,例如arm64armv7armv7s

After probably 4 hours I finally figured it out. 大概4个小时后,我终于知道了。 I think this must be a bug in Xcode, but here is my workaround. 我认为这一定是Xcode中的错误,但这是我的解决方法。

In this folder: 在此文件夹中:

~/Library/Developer/Xcode/DerivedData/<My App Name>/Build/Products/Debug

I found RandomKit.framework and ShiftOperations.framework. 我找到了RandomKit.framework和ShiftOperations.framework。 I copied those two files into the root directory of my Xcode Project, and then linked the frameworks under General in my Xcode Project. 我将这两个文件复制到Xcode项目的根目录中,然后将框架链接到Xcode项目中的General下。

Linking Frameworks 链接框架

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM