WatchKit扩展在CocoaPods下不起作用 [英] WatchKit Extension not working under CocoaPods

查看:75
本文介绍了WatchKit扩展在CocoaPods下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iOS-8.3,Xcode-6.3.1和MacOS-10.10.3-RealmSwift(v0.92.3)的CocoaPods(v0.37.1)安装描述了此处基本有效,除了WatchKit扩展程序找不到任何Realm关键字.

Using iOS-8.3, Xcode-6.3.1 and MacOS-10.10.3 - The CocoaPods (v0.37.1) installation of the RealmSwift (v0.92.3) described here and here basically works, except the WatchKit Extension does not find any Realm keywords.

我的Podfile如下:

My Podfile looks as follows:

xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'

source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

def shared_pods
      pod 'RealmSwift', '>= 0.92.3'
end

target 'MyApp' do
    shared_pods
end

target 'MyAppTests' do
    shared_pods
end

target 'MyApp WatchKit Extension' do
    shared_pods
end

link_with 'MyApp', 'MyApp WatchKit Extension'

我在WatchKit扩展程序中的所有Realm关键字均无法正常工作,如以下错误消息所示(...已注释掉任何导入的RealmSwift语句)(请参见下图)

All my Realm-keywords in the WatchKit Extension do not work as can be seen in the following error messages (...having commented out any import RealmSwift statements) (see pictures below)

任何仍然强烈认为可能仍然是错误的想法???

Any idea strongly appreciated of what could still be wrong ???

关于目标设置必须如何的任何想法.提示:两个目标(即MyApp和MyApp WatchKit扩展)都使用NameEntry领域对象.这似乎增加了CocoaPods使用的复杂性.双重使用(即在两个目标中)是否都需要特殊的cocoapods设置的想法吗?怎么样"import RealmSwift"-这是必需的吗?

Any idea on how the target-settings must be. Hint: The NameEntry Realm-Object is used in both targets (i.e. MyApp and also MyApp WatchKit Extension). This seems to add complexity to the CocoaPods usage. Any idea if the double-usage (i.e. in both targets) need a special cocoapods setting ?? What about "import RealmSwift" - is this necessary or not ??

推荐答案

上面的Podfile实际上是正确的!!

The Podfile above is actually the right one !!

但是,重要的是您仍要使用CocoaPods在Realm-Object定义中导入RealmSwift",如下面的更正示例所示.这将使您的WatchKit Extension错误消息无法识别任何领域对象!

However, it is important that you still "import RealmSwift" in your Realm-Object definition(s) using CocoaPods as can be seen in the corrected example below. This will make your error messages of the WatchKit Extension not recognizing any realm-object go away !

此外,如果打算在两个目标(即"MyApp"和"MyApp WatchKit Extension")中使用Realm-Object,请确保在RealmObject.swift文件的目标选择窗格中选择了两个相应的目标(参见下图):

Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):

这篇关于WatchKit扩展在CocoaPods下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆