Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 尝试将MMWormhole.h导入我的WatchkitExtension InterfaceController.h时出错_Ios_Objective C_Cocoapods_Watchkit_Apple Watch - Fatal编程技术网

Ios 尝试将MMWormhole.h导入我的WatchkitExtension InterfaceController.h时出错

Ios 尝试将MMWormhole.h导入我的WatchkitExtension InterfaceController.h时出错,ios,objective-c,cocoapods,watchkit,apple-watch,Ios,Objective C,Cocoapods,Watchkit,Apple Watch,我正在尝试使用MMWormhole库将我的应用程序与apple watch进行通信。我已经通过CocoaPods导入了MMWormhole库,但在尝试将MMWormhole.h文件导入Watchkit扩展名的InterfaceController.h时,我一直遇到错误。我已经在“链接框架和库”中导入了库。在我的应用程序中,当我将MMWormhole.h导入到任何类中时,我没有得到任何错误 这是我的手表套件扩展的IntefaceController.h: #import <WatchKit/

我正在尝试使用MMWormhole库将我的应用程序与apple watch进行通信。我已经通过CocoaPods导入了MMWormhole库,但在尝试将MMWormhole.h文件导入Watchkit扩展名的InterfaceController.h时,我一直遇到错误。我已经在“链接框架和库”中导入了库。在我的应用程序中,当我将MMWormhole.h导入到任何类中时,我没有得到任何错误

这是我的手表套件扩展的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
#导入
#进口
#进口
@接口控制器:WKInterfaceController
@属性(弱的,非原子的)IbInterfaceLabel*latitudeLabel;
@属性(弱、非原子)IbInterfaceLabel*纵向Label;
@结束

我在MMWormhole.h导入时出错。谢谢用这行代码编辑您的播客文件:

link_with 'MyApp', 'MyWatchExtension'
其中“MyApp”和“MyWatchExtension”是目标的名称。然后
pod update
将链接您的pod

此外,您还可以在手表分机目标的“构建设置”选项卡中手动链接播客。在搜索栏中键入“pod”,并将结果与主应用程序的目标进行比较,然后为watch extension添加缺少的链接

监视扩展的生成设置必须如下所示:

  • 创建框架:文件>新建>目标>框架
  • 然后下载MMWormhole的ZIP文件,并将MMWormhole.h和MMWormhole.m文件拖到“YourFramework”中
在“YourFramework.h”中写下:


在pod文件中,为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
?当你输入
#import时,检查什么是自动完成建议我已经试过了,但也不起作用。我已经在我的主ViewController上导入了它,我想这可能是WatchKit扩展的问题。当我做
#导入时,谢谢!非常感谢你!现在它可以正常工作了!谢谢你的时间!
import YourFramework
# 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