Swift framework depending on cocoa pod

前端 未结 3 750
眼角桃花
眼角桃花 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 20:50

    Thanks so much for sharing @Pasta and @Matt Quiros and it solved my problem. So Ok, I just want to share a bit more about my case and hopefully that will be helpful.

    Development environment

    Xcode Version 9.1 (9B55)

    Deploy iOS version: 10.0

    Problem:

    So I am working on a project named 'MyProject' where I imported 'Charts' library using CocoaPod. The same time, there is also a private framework 'MyFramework' imported in 'MyProject'. Here the problem is that I want to use 'Charts' in 'Myframework' and Xcode keeps telling me that 'Chart' library is unidentified.

    Solution:

    I closed 'MyProject' and opened 'MyFrameWork' and 'File' -> 'New' -> 'File...'. Create two config files and put them on the same folder level of '*.xcodeproj' file. One config file is called 'Pods-MyFramework.debug.xcconfig' and the other is called 'Pods-MyFramework.release.xcconfig'. (The file name could be anything but I am not sure whether the location of files matters). The following is file structure on disk and in my Xcode.

    Now, close 'MyFramework' project and open 'MyProject' project, in my Xcode the file structure is shown below. Expand the 'Pods' folder under 'MyProject' level. You will see some config files, copy their contents to the config files your just created in 'MyFramework' project, debug.config -> debug.config, release.config -> release.config.

    Then in one 'MyViewController' in 'MyFramewwork', I added 'import Charts' and just wanted to give it try on simulator and it ... passed. Yeah!! Then I added some code in the same VC to create a bar chart and ran successfully on real device and the bar chart showed on screen. Then I tried last step that @Pasta mentioned that adding 'Copy Files' option to 'Build Phases'of 'MyProject', it also ran successfully on real device. I removed again and it still works.

提交回复
热议问题