简体   繁体   中英

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 . I am using the basic Swift Package Manager to import the package into my project.

My program builds and runs fine, but when I go to archive it, I get an error saying "No such module '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. In Build Settings , look at the Build Active Architecture Only setting. By default, it is Yes for Debug , and No for Release .

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.

Now, look at the settings for RandomKit to see what architectures it is built for. It needs to include all of the iOS architectures, like arm64 , armv7 , and armv7s .

After probably 4 hours I finally figured it out. I think this must be a bug in Xcode, but here is my workaround.

In this folder:

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

I found RandomKit.framework and 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.

Linking Frameworks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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