Swift framework depending on cocoa pod

前端 未结 3 746
眼角桃花
眼角桃花 2020-12-12 20:14

Using the newest version of cocoa pods (0.36) I am able to embed cocoa pods written in swift (e.g. Alamofire) into my swift project. Now I introduced a custom framework of m

3条回答
  •  鱼传尺愫
    2020-12-12 21:08

    For any newbies out there like me, this part in the question might confuse you:

    Adding the Pods.debug.xcconfig and the Pods.release.xcconfig file to the Configurations for the target of my own swift framework, in other words changing the build settings to do all the changes, that cocoa pods do to the build settings of my iOS App target, solves the problem.

    To do this:

    1. In your custom embedded framework's Xcode project, click on File > New > File... > iOS > Other > Configuration Settings File.

    2. Do the above twice. You may name the files Pods.release.xcconfig and Pods.debug.xcconfig, respectively.

    3. In your Project navigator, expand the Pods Xcode project > Target Support Files > Pods. You'll see that there are similarly named .xcconfig files there. Simply copy their contents to the file of the same name inside your custom embedded Swift framework.

    4. Click your Swift framework's Xcode project file, select the project target (the blue one, not the yellow toolbox one) > Info > Configurations.

    5. Expand the Debug and Release configurations. You'll likely see two targets under your Xcode project--the main framework target, and the test target. In the "Based on Configuration File" column, set the configuration files on the main target to be the Pods.debug and the Pods.release files that you created previously.

    enter image description here

    And then do @Pasta's answer.

    UPDATE

    If you're using your custom embedded Swift framework with other projects, this setup will break simply because other projects have different .xcconfig settings (the Pods' .framework may also be named differently).

    I resorted to just adding Alamofire as a git submodule within my framework. NOTE: Going the git submodule way requires you to add your custom framework to your main project's Embedded Frameworks, as well as the Alamofire.framework from inside your custom framework.

提交回复
热议问题