我正在尝试将myFramework
导入项目中。在“Build Phases(构建阶段)” -> “Link Binary With Libraries(链接二进制库)”中已添加myFramework
。
Objective-c可行:
#import <UIKit/UIKit.h>
#import <myFramework/myFramework.h>
但是在Swift中,我遇到了一个No such module myFramework
错误:
import UIKit
import myFramework
根据 Swift 文档:
Importing External Frameworks
You can import external frameworks that have a pure Objective-C codebase, a pure Swift codebase, or a mixed-language codebase. The process for importing an external framework is the same whether the framework is written in a single language or contains files from both languages. When you import an external framework, make sure the Defines Module build setting for the framework you’re importing is set to Yes.
You can import a framework into any Swift file within a different target using the following syntax:
SWIFT
import FrameworkName
You can import a framework into any Objective-C .m file within a different target using the following syntax:
OBJECTIVE-C
@import FrameworkName;
我使用 Xcode 5 创建了 myFramework
,但是 Xcode 5 没有 "Defines Module" 的构建设置。
问题出在哪里?
@import
非系统框架,这个功能从 Xcode 6 开始可用。 - Shmidt