【发布时间】:2015-12-07 21:06:41
【问题描述】:
我尝试为我的 ios 应用程序和 ios watch kit 使用一个框架 (Realm.framework)。 我尝试了很多方法,它们都不起作用。谁能给我一个例子,说明如何编写一个 pod 文件来在 ios app 和 watch app 之间共享一个框架?
在 pod 文件中没有任何监视扩展目标时,我收到一条错误消息:
Target 'Realm' of project 'Pods' was rejected as an implicit dependency for 'Realm.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Target 'RealmSwift' of project 'Pods' was rejected as an implicit dependency for 'RealmSwift.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Target 'Pods' of project 'Pods' was rejected as an implicit dependency for 'Pods.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
然后我在我的 pod 文件中添加了 watch 扩展的目标。这是我的 pod 文件:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
link_with 'myApp', 'myApp Watch Extension'
def shared_pods
pod 'RealmSwift'
end
target 'myApp' do
podspec :path => 'myapp.podspec'
pod 'SnapKit'
pod 'ChameleonFramework/Swift'
pod 'Google-Mobile-Ads-SDK'
shared_pods
end
target 'myApp Watch Extension' do
podspec :path => 'myapp.podspec'
platform :watchos, '2.0'
shared_pods
end
我运行它时出现“pod install”警告,但我的工作区无法运行。
2015-12-07 15:45:46.402 ruby[17042:4339468] warning: The file reference for "Realm.framework" is a member of multiple groups ("Products" and "Products"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.
2015-12-07 15:45:46.402 ruby[17042:4339468] warning: The file reference for "RealmSwift.framework" is a member of multiple groups ("Products" and "Products"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.
我的 Pods-myApp Watch Extension-Realm 文件中有很多错误。
我也尝试过像这样的 pod 文件:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'myApp', 'myApp Watch Extension'
def shared_pods
pod 'RealmSwift'
end
target 'myApp' do
podspec :path => 'myapp.podspec'
platform :ios, '8.0'
pod 'SnapKit'
pod 'ChameleonFramework/Swift'
pod 'Google-Mobile-Ads-SDK'
shared_pods
end
target 'myApp Watch Extension' do
podspec :path => 'myapp.podspec'
platform :watchos, '2.0'
shared_pods
end
然后我收到“[!] Targets with different platforms”错误。
在我的 podspec 中,我已经添加了行:
s.platform = :ios
s.platform = :ios, "8.0"
s.platform = :watchos
s.platform = :watchos, "2.0"
谁能告诉我应该怎么做?
【问题讨论】:
标签: ios cocoapods watchkit realm watchos-2