RealmSwift-1.2和iOS-9,基于iOS的WatchKit-Extension(全部在iPhone上)

时间:2015-09-30 21:23:17

标签: swift watchkit realm

使用iOS-9.01 / Swift-1.2 / RealmSwift-1.2 / XCode-7.0.1:

我尝试将我正在使用的AppleWatch-1.0应用程序更新到iOS9,仍然使用Swift-1.2并且仍然希望在IPHONE上运行AppleWatch-App(不是AppleWatch本身)。

首次在XCode7中打开时,不幸的是,该应用程序不再编译!我最终得到以下错误:

首次启动XCode7后错误消息(1)(应用程序在XCode6.4下运行正常):

Target 'Pods-MyApp WatchKit Extension' of project 'Pods' was rejected as an
implicit dependency for 'Pods_MyApp_WatchKit_Extension.framework' because it
doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator,
iphoneos'

该错误意味着什么???

我读了in another post,WatchKit-Extension的架构设置(即调试目标)需要设置不同

Base-SDK(在Build Settings / Architecture下)设置需要是什么?

首次启动后,Base-SDK默认设置为watchOS(如下面的第一张图所示)。但是,由于我想保留APP一个纯粹的iPhone-App,我认为,这个Base-SDK应该被设置为“最新的iOS(iOS 9.0)”。这是正确的吗?

enter image description here

将Base-SDK设置为“最新iOS(iOS 9.0)”后,“常规”选项卡会消失(参见下图)。所以我认为这也不正确?或者是吗?

enter image description here

不仅“常规”标签消失,而且还会出现另一个错误:

将Base-SDK更改为Latest-iOS(iOS 9.0)后出现错误消息(2):

target specifies product type 'com.apple.product-type.watchkit2-extension',
but there's no such product type for the 'iphonesimulator' platform

如果为Debug和Release发布不同的“支持的平台”(according to the suggestion of the other post),我将回到Error-message1

有关支持的平台设置的混合情况,请参见下图:

enter image description here

错误消息(1)现在又回来了....

Target 'Pods-MyApp WatchKit Extension' of project 'Pods' was rejected as an
implicit dependency for 'Pods_MyApp_WatchKit_Extension.framework' because it
doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator,
iphoneos'

问题仍然存在:为了使应用程序按预期工作,还有什么可做的? 对此有任何帮助表示赞赏!

此外,我的Cocoa Podfile如下所示:

xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '9.0'
inhibit_all_warnings!

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 'Realm', :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'swift-1.2'
      pod 'RealmSwift', :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'swift-1.2'
end

target 'MyApp' do
    shared_pods
end

target 'MyAppTests' do
    shared_pods
end

target 'MyApp WatchKit Extension' do
    platform :ios, '9.0'
    shared_pods
end

1 个答案:

答案 0 :(得分:3)

您正在使用Swift 1.2版本的Realms。 iOS 9使用Swift 2.0,所以我相信你只需要使用最新版本的Realms:

def shared_pods
      pod 'Realm'
      pod 'RealmSwift'
end