How to properly configure a subfile that has both a target infrastructure object and a target program that uses this structure

Having the following project structure:

  • The purpose of the application for the Xcode project (App.xcodeproj) depends on the target Framework environment, which is located on another Xcode project (Framework.xcodeproj).
  • The purpose of the application depends on the material pod
  • The framework goal depends on the AFNetworking subsystem.

Is this setup supported by CocoaPods?

My first attempt was to do something like this:

platform :ios, '9.0'
use_frameworks!

target 'App' do
  workspace 'App.xcworkspace'
  project 'App.xcodeproj'  
  pod 'Material'
end

target 'Framework' do
  workspace 'App.xcworkspace'
  project 'Framework/Framework.xcodeproj'
  pod 'AFNetworking'
end

But the application starts at startup with the following error:

dyld: Library not loaded: @rpath/AFNetworking.framework/AFNetworking

Referenced from: /Users/ruenzuo/Library/Developer/Xcode/DerivedData/App-aayvulxvruuarudtheuilepmmctk/Build/Products/Debug-iphonesimulator/Framework.framework/Framework

Reason: image not found

This makes sense because CocoaPods does not know that the application and the Framework are related. In fact, after installing pod, I get the following warning:

[!] The Podfile contains framework targets, for which the Podfile does not contain host targets (targets which embed the framework).
If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).

Framework , :

platform :ios, '9.0'

use_frameworks!

target 'App' do
  workspace 'App.xcworkspace'
  project 'App.xcodeproj'
  pod 'Material'
  target 'Framework' do
    workspace 'App.xcworkspace'
    project 'Framework/Framework.xcodeproj'
    pod 'AFNetworking'
  end
end

. , , :

platform :ios, '9.0'
use_frameworks!

target 'App' do
  workspace 'App.xcworkspace'
  project 'App.xcodeproj'
  pod 'Material'
  pod 'AFNetworking'
end

target 'Framework' do
  workspace 'App.xcworkspace'
  project 'Framework/Framework.xcodeproj'
  pod 'AFNetworking'
end

AFNetworking , - . , , , , , CocoaPods AFNetworking Framework.

- - ?

+6
1

, " " , :

Xcode screenshot

- CocoaPods "Target Dependencies" - , / "Link With Binary Libraries". Podfile :

project 'CocoapodsTest'

target 'CocoapodsTest' do
    pod 'AFNetworking'
end

target 'SampleLibrary' do
    pod 'Masonry'
end

pod install " " , , :

Xcode screenshot

0

Source: https://habr.com/ru/post/1016533/


All Articles