0
votes

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.

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'

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 ???

enter image description here

enter image description here

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 ??

1

1 Answers

0
votes

The Podfile above is actually the right one !!

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 !

enter image description here

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):

enter image description here