菜鸟教程小白 发表于 2022-12-13 01:35:59

ios - 在项目的 podfile 中使用私有(private)框架(带有 pod)


                                            <p><p>我创建了一个使用多个 pod 的私有(private)框架。我现在想在也使用 Cocoapods 的项目中使用这个框架(它有一个 podspec 文件)。</p>

<p>我已经搜索了很多小时,但找不到有效的示例。我的用例是我正在创建多个应用程序,但是这些应用程序共享大量代码和 Assets ( Storyboard、文件等)。因此,框架包含所有这些通用组件,需要在每个应用目标中使用。</p>

<p>我目前有这个,但它不能正常工作:</p>

<pre><code>platform :ios, &#39;9.0&#39;
use_frameworks!
workspace &#39;Project.xcworkspace&#39;

def shared_pods
pod 1
pod 2
pod 3
end

target &#39;Target1&#39; do
shared_pods
end

target &#39;Target2&#39; do
shared_pods
end

target &#39;MyPrivateFramework&#39; do
project &#39;MyPrivateFrameworkDirectory/MyPrivateFramework.xcodeproj&#39;
shared_pods
end

target &#39;TestsTarget&#39; do
inherit! :search_paths
# Pods for testing
end
</code></pre>

<p>我收到的警告是:</p>

<pre><code>[!] 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).
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我通过仔细阅读此主题找到了答案:<a href="https://github.com/CocoaPods/CocoaPods/issues/6123" rel="noreferrer noopener nofollow">https://github.com/CocoaPods/CocoaPods/issues/6123</a>并与此处的示例项目进行比较:<a href="https://github.com/benasher44/CocoaPodsLibExample" rel="noreferrer noopener nofollow">https://github.com/benasher44/CocoaPodsLibExample</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在项目的 podfile 中使用私有(private)框架(带有 pod),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44231165/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44231165/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在项目的 podfile 中使用私有(private)框架(带有 pod)