【问题标题】:How to set the bundle identifier of a cocoapod如何设置 cocoapod 的捆绑标识符
【发布时间】:2016-03-12 03:42:32
【问题描述】:

对于我创建的 pod,cocoapod 将 org.cocoapods 设置为我的 pod 包标识符的前缀:

我希望能够设置自己的前缀,但我没有在 podspec 中找到任何选项来执行此操作。

有人知道这个选项是否存在吗?

问候。 塞巴斯蒂安。

【问题讨论】:

    标签: cocoapods bundle-identifier podspec


    【解决方案1】:

    您需要同时提供两者

    s.info_plist = { 'CFBundleIdentifier' => 'com.myorg.mylib' }

    s.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER': 'com.myorg.mylib' }

    【讨论】:

      【解决方案2】:

      this answer 有一个简单的方法

      Info.plist DSL 将包含在 1.8.0 版本中。

      设置包标识符:

      # in .podspec
      s.info_plist = {
        'CFBundleIdentifier' => 'com.myorg.mylib'
      }
      

      当前的 Cocoapods 版本是 1.8.0 beta2。我刚试过这个版本,它可以工作。但是如果你使用“pod trunk push”,就会出现一些错误信息“The Pod Specification没有通过验证”。也许我们需要等到 1.8.0 版本发布。

      【讨论】:

        【解决方案3】:

        您可以为您的开发 pod 提供自己的 plist 文件,如下所示:

        s.pod_target_xcconfig = {
          'INFOPLIST_FILE' => '${PODS_TARGET_SRCROOT}/Resources/YourPod-Info.plist'
        }
        

        那么您只需要在该 plist 中更改 Bundle identifier

        【讨论】:

          【解决方案4】:

          一种可能的解决方法是使用 post_install 处理程序。这是一个示例脚本:

          post_install do |installer|
          
            installer.project.targets.each do |target|
              target.build_configurations.each do |config|
                if config.name == 'BREnterprise'
                  config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution: The Carter Group LLC'
                  config.build_settings['PROVISIONING_PROFILE'] = '${BR_ENTERPRISE_PROVISIONING_PROFILE}'
                end
              end
            end
          
            # change bundle id of each pod to 'com.bottlerocketapps.*'
            bundle_id = 'com.bottlerocketapps'
          
            directory = installer.config.project_pods_root + 'Target Support Files/'
            Dir.foreach(directory) do |path|
          
              full_path = directory + path
              if File.directory?(full_path)
          
                info_plist_path = full_path + 'Info.plist'
                if File.exist?(info_plist_path)
          
                  text = File.read(info_plist_path)
                  new_contents = text.gsub('org.cocoapods', bundle_id)
                  File.open(info_plist_path, "w") {|file| file.puts new_contents }
                end
              end
            end
          end
          

          【讨论】:

            【解决方案5】:

            迄今为止,此选项不存在:https://github.com/CocoaPods/CocoaPods/issues/4632#issuecomment-162531257

            问候。 塞巴斯蒂安。

            【讨论】:

              猜你喜欢
              • 2015-03-23
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-05-28
              • 2015-01-26
              • 1970-01-01
              • 2012-04-10
              相关资源
              最近更新 更多