Watchkit &Realm 0.92.3正式版

问题描述 投票:3回答:2

在Xcode 6.3和iOS10.10.3下集成新的Realm-DB (realm 0.92.3),基本上在iPhone上可以工作(在Apple-Watch上还不行)。在Watchkit(即Apple-Watch)下集成同样的realm-framework还不行。

RealmSwift.framework被集成(拖入)到Embedded-Binaries中,如以下所述 这里1这里2. 请看下面的截图。

enter image description here

当使用模拟器运行Watchkit-App时,出现以下错误。

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /Users/XXX/Library/Developer/CoreSimulator/Devices/3FE99-9-4C4C2/data/Containers/Bundle/Application/8B4-DF19F34-222973/MyApp.app/PlugIns/MyApp WatchKit Extension.appex/MyApp WatchKit Extension
  Reason: image not found
(lldb) 

还出了什么问题?

主应用程序的Framework-Search-Path已被设置,MyApp Watchkit Extension和MyApp Watchkit App的Framework-Search-Path未被设置。MyApp Watchkit Extension和MyApp Watchkit App的路径没有设置。设置它们并不能改变上述错误。还缺什么?

ios watchkit realm
2个回答
2
投票

我建议你用CocoaPods。

我也像你一样,用动态框架来做,但是当我试图用Xcode的Organizer来提交我的应用程序到iTunes Connect时,我不能,因为有嵌套的框架。Realm.framework是在RealmSwift.framework里面的,这对苹果来说是不行的。所以我试了又试,但什么也没帮上忙......

然后我使用CocoaPods,一切都能正常工作。

这里是CocoaPods的安装说明。

Install CocoaPods 0.37.1 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'RealmSwift' to your main and test targets.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!

1
投票

这个Podfile终于为我做到了(见下图)。在那之后,一切都正常了......要安装只需打开一个终端,进入你的App的文件夹(你放置Podfile的地方),然后输入

pod install

之后确保从现在开始打开 "MyApp.xcworkspace"(不再是 "MyApp.xcodeproj"),你就可以了!

这里是工作的podfile。

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!
link_with 'MyApp', 'MyApp WatchKit Extension'

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

target 'MyApp' do
    shared_pods
end

target 'MyAppTests' do
    shared_pods
end

target 'MyApp WatchKit Extension' do
    shared_pods
end
© www.soinside.com 2019 - 2024. All rights reserved.