无法找到正确的方式来构建我自己的框架目标与我的主要应用程序目标
我决定将我的主项目分为两部分重用代码,在iOS小部件。无法找到正确的方式来构建我自己的框架目标与我的主要应用程序目标
所以我在我的xcworkspace(可可触摸框架)中创建了一个新的目标文件。 这两个目标都有一些共同的pod依赖关系,我无法确定正确的构建方式。
首先尝试:
在podfile,我指定需要荚两个目标,但是建立的时候,我有多个错误
类Foo实现在MyApp和MyFramework中。将使用两者之一。哪一个是未定义的。
第二个尝试:
然后我试图把框架的目标主要应用目标内(如与我们测试目标通常会做)
target 'MyApp' do
main_pods
app_pods
target 'MyFramework' do
inherit! :search_paths
target 'MyFrameworkTests' do
inherit! :search_paths
testing_pods
end
end
end
但随后的框架不会建因为它没有发现依赖关系 例如:
没有这样的模块Firebas Ë
注意:
建立我的主要目标,我已经先建立框架的目标,否则就没有找到“MyFramework”模块。当我建立主要目标时无法建立两者?
明白了,我有静态库框架依赖关系和iOS链接器不支持动态库的静态库依赖关系。
CF问题:https://github.com/CocoaPods/CocoaPods/issues/7126
我已经张贴在上述问题的解决方法通过Podfile解决它:
post_install do |installer|
sharedLibrary = installer.aggregate_targets.find { |aggregate_target| aggregate_target.name == 'Pods-SampleFramework' }
installer.aggregate_targets.each do |aggregate_target|
if aggregate_target.name == 'Pods-SampleApp'
aggregate_target.xcconfigs.each do |config_name, config_file|
sharedLibraryPodTargets = sharedLibrary.pod_targets
aggregate_target.pod_targets.select { |pod_target| sharedLibraryPodTargets.include?(pod_target) }.each do |pod_target|
pod_target.specs.each do |spec|
frameworkPaths = unless spec.attributes_hash['ios'].nil? then spec.attributes_hash['ios']['vendored_frameworks'] else spec.attributes_hash['vendored_frameworks'] end || Set.new
frameworkNames = Array(frameworkPaths).map(&:to_s).map do |filename|
extension = File.extname filename
File.basename filename, extension
end
frameworkNames.each do |name|
puts "Removing #{name} from OTHER_LDFLAGS"
config_file.frameworks.delete(name)
end
end
end
xcconfig_path = aggregate_target.xcconfig_path(config_name)
config_file.save_as(xcconfig_path)
end
end
end
end
我也有一个应用程序,我在一个单独的项目中创建了一个框架,但是在同一个工作区中。我使用pod获取所有外部库,并将其自己的框架嵌入到Xcode的Embedded Binaries
中,将其嵌入到应用程序的目标中。我Podfile看起来是这样的:
workspace 'MyApp'
abstract_target 'BasePods' do
use_frameworks!
pod 'Alamofire', '~> 4.4'
pod 'PromiseKit', '~> 4.1'
project '../MyAppProject/MyApp/MyApp.xcodeproj'
target 'MyApp'
target 'MyAppDevelopment'
end
target 'MyAppCore' do
use_frameworks!
pod 'Alamofire', '~> 4.4'
pod 'PromiseKit', '~> 4.1'
project '../MyAppProject/MyAppCore/MyAppCore.xcodeproj'
target 'MyAppCoreTests' do
inherit! :search_paths
end
end
这里会发生什么事我创建两个单独的吊舱的目标 - 一个用于应用程序,另一个用于框架。我将它们分开,因为它们驻留在不同的目录中。
我没有一个xcodeproj用于我的框架目标,当我创建两个豆荚目标时(cf:首先尝试在我的文章中),xcode表示存在重复(在两个目标中实现的类) –
似乎这个问题是关系到火力地堡,这是一个静态库,它没有做以及作为动态框架的依赖 –