Cin316
Cin316

Reputation: 651

Xcode won't archive Swift iOS app with a Swift framework as a separate target. How can this be fixed?

I have an iOS app that I've created using Swift. Since I have a widget in my project and I want to share code between my widget and my app, I have a Swift framework also as part of my project. I can successfully build my app. First I have to build the framework, then I can build the app. However, when I try to archive the app for distribution, it fails with two errors.

module.modulemap: Header '{My Framework Name}-Swift.h' not found.

Could not build Objective-C module '{My Framework Name}'.

Screenshot of archiving errors.

I have three targets in my app, an app, widget, and framework.

enter image description here

The framework has a collection of Swift files, as well as an Objective-C header with these contents:

#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double XScheduleKitVersionNumber;
FOUNDATION_EXPORT const unsigned char XScheduleKitVersionString[];

My Mac is running OS X 10.10.2. Xcode is version 6.3. My app is for iOS 8.0+. The full content of the project I'm working on is open-source and available at https://github.com/Cin316/X-Schedule.

Upvotes: 1

Views: 1260

Answers (1)

A.C. Wright
A.C. Wright

Reputation: 941

I have run into this frustrating problem before myself. It seems that with pure Swift framework targets the Objective-C header file causes intermittent or strange build errors (Xcode bug?). It seems counter-intuitive but part of the solution at least is to either change the header file from public to project or simply remove it from the build target. I wish I had a better explanation as to why this works!

I have forked your project and created a build (that works on my machine at least) here: https://github.com/acwright/X-Schedule

Hope this helps!

Upvotes: 1

Related Questions