CocoaPods overwrites custom key/value pairs in the Info.plist

Created on 28 Jun 2018  ·  11Comments  ·  Source: CocoaPods/CocoaPods

Report

What did you do?

Create any kind of framework with podspec file, define custom value in the Info.plist, embed framework into any project and run pod install. After pod is fetched Info.plist file does not contain any of the custom values that were present in the Info.plist

Apple docs define that's possible to have custom values in Info.plist:

You can include your keys in your bundle’s information property list file if you want all of your keys stored in one place.

What did you expect to happen?

I would expect CocoaPods to preserve any kind of custom values stored in the Info.plist.

What happened instead?

Fetched framework Info.plist file did not contain custom key/value.

CocoaPods Environment

Stack

   CocoaPods : 1.5.3
        Ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    RubyGems : 2.7.6
        Host : Mac OS X 10.13.6 (17G39b)
       Xcode : 9.4.1 (9F2000)
         Git : git version 2.17.0
Ruby lib dir : /usr/local/Cellar/ruby/2.5.1/lib

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

Project that demonstrates the issue

Demo app that uses framework with custom key/value in the Info.plist can be found here:
https://github.com/ztepsa/demo-app

  • example app will crash as framework can't load version from the Info.plist

Demo framework that contains custom key/value in the Info.plist can be found here:
https://github.com/ztepsa/demo-framework

  • custom value in this case is the DemoSDKVersion found in the Info.plist

Most helpful comment

There is a PR open for the fix here https://github.com/CocoaPods/CocoaPods/pull/8432

All 11 comments

Thanks for the report!

Yes and no. By default CocoaPods creates an Info.plist for the target. You have to set s.pod_target_xcconfig = { 'INFOPLIST_FILE' => '${PODS_TARGET_SRCROOT}/path/to/Info.plist' }

But you might do get a bug which has been fixed on master https://github.com/CocoaPods/CocoaPods/issues/7530 that even if you do the above then CocoaPods will override the plist anyway.

You can try using master/SHA as 1.6.0.beta.1 is not yet released via bundler https://bundler.io/v1.12/git.html

Thanks for the fast response!

Edit: Check new comment below, I'll leave this one for reference.

I tried adding s.pod_target_xcconfig to the current podspec, after running pod install on 1.5.3 version I can observe same behaviour.

As you suggested I tried using master branch, and it's a bit different now Info.plist is missing from the Pod all together, here is the verbose log that shows how it looks now while it's running install:

    - Installing target `CryptoSwift` iOS 8.0
      - Generating module map file at `Pods/Target Support Files/CryptoSwift/CryptoSwift.modulemap`
      - Generating umbrella header at `Pods/Target Support Files/CryptoSwift/CryptoSwift-umbrella.h`
      - Generating Info.plist file at `Pods/Target Support Files/CryptoSwift/CryptoSwift-Info.plist`
      - Generating dummy source at `Pods/Target Support Files/CryptoSwift/CryptoSwift-dummy.m`

    - Installing target `Framework` iOS 10.0
      - Generating module map file at `Pods/Target Support Files/Framework/Framework.modulemap`
      - Generating umbrella header at `Pods/Target Support Files/Framework/Framework-umbrella.h`
      - Generating dummy source at `Pods/Target Support Files/Framework/Framework-dummy.m`

My Info.plist file is located at:

Project/Sources/Info.plist

and setup in podspec is:

s.pod_target_xcconfig = { 'INFOPLIST_FILE' => '${PODS_TARGET_SRCROOT}/Sources/Info.plist' }

I presume that now it's only issue with path, I tried couple of different combinations but they are not working. I'll update example framework so that setup is simpler and try it out once more.

Here's the update, both demo-app and demo-framework are now updated and working but I have few questions.

I understood that pod_target_xcconfig will copy the file in question and move it to the Pod under Supporting Files/Framework-Info.plist and link it properly in the project settings, but this seems to be wrong as INFOPLIST_FILE defines where the plist file is located and that's it.

If you check podspec file of the demo-framework 1.0.0-rc.5 I added this part so that plist files are actually copied.

s.source_files = 'Sources/*.{swift,h,m,plist}'

My question would be is there an option so that this is handled by CocoaPods automatically (or maybe some future plan) or I missed something? (e.g. s.info_plist = 'Sources/Info.plist')

Also to correct my statement from above, this kind of setup works ok with 1.5.3 version.

In another project I am experiencing same issues as noted in issue #7530. Resulting Pod has two Info.plist files, one is located in Sources and that one is original that was copied, another is in the Supporting Files and that one is linked as Info.plist in project settings.

Using master fixes this as Supporting Files/Info.plist is no longer generated and and proper plist is linked in project settings.

so @ztepsa is this still an issue? pod_target_xcconfig will only set the value in the xcconfig. If you want to maintain the file I think you can add it to preserve_paths

I havent understood if your issue is fixed on master and whether this issue should be closed or not.

Issue is fixed on master branch, so it can be closed 👍

Looks like this is still an issue for test_specs in 1.6.0b1

I Have the same issue with test_specs. I want to provide custom info plist for my test target, but
s.pod_target_xcconfig = { 'INFOPLIST_FILE' => '${PODS_TARGET_SRCROOT}/Sources/Info.plist' }
only works for main spec, not for the test one. Cocoapods modify INFOPLIST_FILE value of buildSettings inside Pods.xcodeproj overriding value from xcconfig.
May be there is a way to turn off this modification if INFOPLIST_FILE flag is specified in podspec?
Or is there a way to add custom fields in generated info.plist file?

@ignatovv please file a new issue with an example project if the issue is still present on the master branch.

There is a PR open for the fix here https://github.com/CocoaPods/CocoaPods/pull/8432

Was this page helpful?
0 / 5 - 0 ratings