问题
I have a project with a subproject. Both the subproject and the main project must use Cocoapods to integrate a library which is seemingly impossible to integrate without Cocoapods. So I have Cocoapods set up for both the Main project and its subproject. The subproject builds in its generated workspace, but compiling the main project produces the following error: ld: library not found for -lPods-Subproject name-Library.
The only idea I have right now is that I should somehow get the subproject's Cocoapods repo to use the main project's name, so that when the subproject builds it will check for the same libraries as the main project's Cocoapods generates (presumably -lPods-Main Project Name-Library), which will have been created as part of the main project's build process.
How can I achieve this? Is there a better way to get the result I want?
回答1:
Try to write your podfile in that way:
workspace 'FinalWorkspace.xcworkspace'
xcodeproj 'MainWorkspace/MainWorkspace.xcodeproj'
xcodeproj 'SubWorkspace/SubWorkspace.xcodeproj'
target 'MainWorkspace' do
platform :ios, '8.0'
xcodeproj 'MainWorkspace/MainWorkspace.xcodeproj'
pod 'nameofpod1', '~> 1.1'
pod 'nameofpod2', '~> 2.2'
pod 'nameofpod3', '~> 3.3'
pod 'nameofpod4', '~> 4.4'
end
target 'SubWorkspace' do
platform :ios, '8.0'
xcodeproj 'SubWorkspace/SubWorkspace.xcodeproj'
pod 'nameofpod3', '~> 3.3'
end
And then run FinalWorkspace.xcworkspace.
来源:https://stackoverflow.com/questions/26394463/cocoapods-in-subproject