我正在尝试使用MMWormhole库来将我的应用程序与apple watch进行通信。我已经通过CocoaPods导入了MMWormhole库,但在尝试将MMWormhole.h文件导入到我的Watchkit扩展的InterfaceController.h时,我一直收到错误消息。我已经导入了“链接框架和库”中的库。在我的应用程序中,当我将MMWormhole.h导入到任何类中时,我没有得到任何错误。
这是我的Watchkit扩展的IntefaceController.h:
#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import <MMWormhole.h>
@interface InterfaceController : WKInterfaceController
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *latitudeLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *longitudeLabel;
@end我在MMWormhole.h导入时遇到错误。谢谢
发布于 2015-04-10 19:33:25
中
在"YourFramework.h“中写入:
#import <YourFramework/MMWormhole.h>将MMWormhole.h的目标成员身份设置为"YourFramework“,并设置Public.为
最后,将框架导入您想要使用的所有swift文件中。
import YourFramework发布于 2015-05-30 11:55:21
在您的Podfile中,为您的WatchKit扩展创建另一个目标,并像这样添加pod 'MMWormhole'。
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
target 'MyApp' do
pod 'SomeOtherLibrary', '3.10'
pod 'MMWormhole'
end
target 'MyApp WatchKit Extension' do
pod 'MMWormhole'
end运行pod update,现在#import <MMWormhole/MMWormhole.h>将同时适用于这两个目标。
发布于 2015-04-10 16:43:57
使用以下代码行编辑您的Podfile:
link_with 'MyApp', 'MyWatchExtension'其中'MyApp‘和'MyWatchExtension’是目标的名称。然后pod update会链接你的pods。
您还可以在监视扩展目标的“构建设置”选项卡中手动链接您的pod。在搜索栏中输入'pod‘,并将结果与主应用程序的目标进行比较,然后为watch扩展添加缺少的链接。
监视扩展的构建设置必须如下所示:

https://stackoverflow.com/questions/29539716
复制相似问题