ios – 在主目标中包含pod,而不在WatchKit扩展中

前端之家收集整理的这篇文章主要介绍了ios – 在主目标中包含pod,而不在WatchKit扩展中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在当前项目中添加了WatchKit扩展.该项目使用 Cocoapods 0.36.1添加一些框架,但现在我想从WatchKit扩展项目中排除一些pod.

WatchKit扩展项目不需要我在我的正常目标中使用的很多框架,但是在改变我的Podfile后我无法使Cocoapods正常工作.

我用use_frameworks!在我的Podfile中,但在运行pod安装后,我收到以下消息:

  1. [!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all,please either set the base configurations of the target `HomeHandler` to `Pods/Target Support Files/Pods-HomeHandler/Pods-HomeHandler.debug.xcconfig` or include the `Pods/Target Support Files/Pods-HomeHandler/Pods-HomeHandler.debug.xcconfig` in your build configuration.
  2. [!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all,please either set the base configurations of the target `HomeHandler` to `Pods/Target Support Files/Pods-HomeHandler/Pods-HomeHandler.release.xcconfig` or include the `Pods/Target Support Files/Pods-HomeHandler/Pods-HomeHandler.release.xcconfig` in your build configuration.
  3. [!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all,please either set the base configurations of the target `HomeHandler WatchKit Extension` to `Pods/Target Support Files/Pods-HomeHandler WatchKit Extension/Pods-HomeHandler WatchKit Extension.debug.xcconfig` or include the `Pods/Target Support Files/Pods-HomeHandler WatchKit Extension/Pods-HomeHandler WatchKit Extension.debug.xcconfig` in your build configuration.
  4. [!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all,please either set the base configurations of the target `HomeHandler WatchKit Extension` to `Pods/Target Support Files/Pods-HomeHandler WatchKit Extension/Pods-HomeHandler WatchKit Extension.release.xcconfig` or include the `Pods/Target Support Files/Pods-HomeHandler WatchKit Extension/Pods-HomeHandler WatchKit Extension.release.xcconfig` in your build configuration.

我没有更改基本配置的任何设置,但我的3个目标中有2个具有正确的Pods.debug或Pods.release设置.没有基本配置的是WatchKit App.

我原来的Podfile

  1. platform :ios,'8.0'
  2. use_frameworks!
  3.  
  4. source 'https://github.com/artsy/Specs.git'
  5. source 'https://github.com/CocoaPods/Specs.git'
  6.  
  7. pod 'AFNetworking',:git => 'https://github.com/AFNetworking/AFNetworking.git'
  8. pod 'CocoaLumberjack','~> 2.0.0'
  9. pod 'MagicalRecord',:git => "https://github.com/magicalpanda/MagicalRecord.git"
  10. pod 'PureLayout'
  11. pod 'UAProgressView'
  12. pod 'UICKeyChainStore'
  13. pod 'XLForm',git: 'git@github.com:xmartlabs/XLForm.git'
  14. pod 'Classy',git: 'git@github.com:depl0y/Classy.git'
  15. pod 'Reveal-iOS-SDK',:configurations => ['Debug']
  16. pod 'JBChartView','~> 2.8.9'
  17. pod 'RFQuiltLayout'
  18. pod 'HUMSlider','~> 1.0'
  19. pod 'SwiftEventBus',:git => 'https://github.com/cesarferreira/SwiftEventBus.git'
  20.  
  21. post_install do |installer_representation|
  22. installer_representation.project.targets.each do |target|
  23. if target.name == "Pods-AFNetworking"
  24. target.build_configurations.each do |config|
  25. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)','AF_APP_EXTENSIONS=1']
  26. end
  27. end
  28. if target.name == "Pods-PureLayout"
  29. target.build_configurations.each do |config|
  30. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)','PURELAYOUT_APP_EXTENSIONS=1']
  31. end
  32. end
  33. end
  34. end

我改变了Podfile

这是我想从WatchKit项目中排除某些pod的地方.

  1. platform :ios,'8.0'
  2.  
  3. use_frameworks!
  4.  
  5. source 'https://github.com/artsy/Specs.git'
  6. source 'https://github.com/CocoaPods/Specs.git'
  7.  
  8. link_with "HomeHandler","HomeHandler WatchKit Extension"
  9.  
  10. pod 'AFNetworking',:git => "https://github.com/magicalpanda/MagicalRecord.git"
  11.  
  12. pod 'UICKeyChainStore'
  13.  
  14. target :HomeHandler do
  15. pod 'XLForm',git: 'git@github.com:xmartlabs/XLForm.git'
  16. pod 'UAProgressView'
  17. pod 'Classy',git: 'git@github.com:depl0y/Classy.git'
  18. pod 'Reveal-iOS-SDK',:configurations => ['Debug']
  19. pod 'JBChartView','~> 2.8.9'
  20. pod 'RFQuiltLayout'
  21. pod 'HUMSlider','~> 1.0'
  22. pod 'SwiftEventBus',:git => 'https://github.com/depl0y/SwiftEventBus.git'
  23. pod 'PureLayout'
  24. end
  25.  
  26. post_install do |installer_representation|
  27. installer_representation.project.targets.each do |target|
  28. if target.name == "Pods-AFNetworking"
  29. target.build_configurations.each do |config|
  30. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)','PURELAYOUT_APP_EXTENSIONS=1']
  31. end
  32. end
  33. end
  34. end

解决方法

CocoaPods输出的警告是由于两个CocoaPods目标试图链接到应用程序中的单个目标(不支持).

即,您有一个明确的目标HomeHandler,并且您使用link_with“HomeHandler”,“HomeHandler WatchKit Extension”将无名目标链接到HomeHandler.

我的建议是修改你的Podfile,看起来如下所示:

  1. platform :ios,'8.0'
  2. use_frameworks!
  3.  
  4. source 'https://github.com/artsy/Specs.git'
  5. source 'https://github.com/CocoaPods/Specs.git'
  6.  
  7. def shared_pods
  8. pod 'AFNetworking',:git => 'https://github.com/AFNetworking/AFNetworking.git'
  9. pod 'CocoaLumberjack','~> 2.0.0'
  10. pod 'MagicalRecord',:git => "https://github.com/magicalpanda/MagicalRecord.git"
  11. pod 'UICKeyChainStore'
  12. end
  13.  
  14. target 'HomeHandler' do
  15. shared_pods
  16. pod 'XLForm',:git => 'https://github.com/depl0y/SwiftEventBus.git'
  17. pod 'PureLayout'
  18. end
  19.  
  20. target 'HomeHandler WatchKit Extension' do
  21. shared_pods
  22. end

猜你在找的iOS相关文章