question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NameError - uninitialized constant Pod::Target::BuildType

See original GitHub issue

🐛 Bug Report

NameError - uninitialized constant Pod::Target::BuildType
Did you mean?  Pod::BuildType
/User/xxxxxx/app-ios/Podfile:53:in `build_type'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/target.rb:112:in `build_as_framework?'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:53:in `block (3 levels) in verify_no_duplicate_framework_and_library_names'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:53:in `select'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:53:in `block (2 levels) in verify_no_duplicate_framework_and_library_names'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:48:in `each_key'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:48:in `block in verify_no_duplicate_framework_and_library_names'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:47:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:47:in `verify_no_duplicate_framework_and_library_names'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer.rb:590:in `validate_targets'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/installer.rb:158:in `install!'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/command/install.rb:52:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/lib/cocoapods/command.rb:52:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.0/bin/pod:55:in `<top (required)>'
/usr/local/lib/ruby/gems/@/bin/pod:23:in `load'
/usr/local/lib/ruby/gems/@/bin/pod:23:in `<main>'

To Reproduce

Podfile

source 'https://github.com/aliyun/aliyun-specs.git'
source 'https://cdn.cocoapods.org/'
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
def shared_pods

    pod 'KeychainAccess'
    pod 'IQKeyboardManagerSwift'
    pod 'Magnetic'
    pod 'CHIPageControl'
    pod 'CHIPageControl/Aleppo'
    pod 'ReachabilitySwift'
    pod 'Disk'
    pod 'DynamicBlurView'
    pod 'R.swift'
    pod 'lottie-ios'
    pod 'PhraseApp'

    # push notifications
    pod 'Firebase/Core'
    pod 'Firebase/Messaging'

    # Remote config
    pod 'Firebase/RemoteConfig'
    # pod 'AlicloudPush', '~> 1.9.9'
    pod 'AlicloudPush'

    use_frameworks!
end

def setup_flipper
  pod 'FlipperKit'
  # Layout and network plugins are not yet supported for swift projects
  pod 'FlipperKit/FlipperKitLayoutComponentKitSupport'
  pod 'FlipperKit/SKIOSNetworkPlugin'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin'

  # If you use `use_frameworks!` in your Podfile,
  # uncomment the below $static_framework array and also
  # the pre_install section.  This will cause Flipper and
  # it's dependencies to be built as a static library and all other pods to
  # be dynamic.
  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
    'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if $static_framework.include?(pod.name)
        def pod.build_type;
          Pod::Target::BuildType.static_library
        end
      end
    end
   end


  # This post_install hook adds the -DFB_SONARKIT_ENABLED flag to OTHER_SWIFT_FLAGS, necessary to build swift target
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'YogaKit'
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.1'
        end
      end
    end
    file_name = Dir.glob("*.xcodeproj")[0]
    app_project = Xcodeproj::Project.open(file_name)
    app_project.native_targets.each do |target|
      if target.name.end_with? '-Flipper'
        target.build_configurations.each do |config|
          if (config.build_settings['OTHER_SWIFT_FLAGS'])
            unless config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED'
              puts 'Adding -DFB_SONARKIT_ENABLED ...'
              swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
              if swift_flags.split.last != '-Xcc'
                config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc'
              end
              config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED'
            end
          else
            puts 'OTHER_SWIFT_FLAGS does not exist thus assigning it to `$(inherited) -Xcc -DFB_SONARKIT_ENABLED`'
            config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -Xcc -DFB_SONARKIT_ENABLED'
          end
          app_project.save
        end
      end
      installer.pods_project.save
    end
  end
end

project 'abc.xcodeproj'



target 'abc-Dev-Flipper' do
    shared_pods
    pod 'Instabug'
    setup_flipper
end

target 'abc-Dev' do
    shared_pods
    pod 'Instabug'
end

Add then pod install

Expected Behavior

No error was thrown

Environment

Stack

   CocoaPods : 1.9.0
        Ruby : ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
    RubyGems : 3.0.6
        Host : Mac OS X 10.15.3 (19D76)
       Xcode : 11.3.1 (11C504)
         Git : git version 2.24.0
Ruby lib dir : /usr/local/Cellar/ruby/2.6.5/lib
Repositories : aliyun - git - https://github.com/aliyun/aliyun-specs.git @ 8211d77c019078f55a9f0353a8534e37cc74329a

               facebook - git - https://github.com/facebook/Sonar.git @ fa7f970266ff6353238d4d252c277433f88edc1e

               facebook-1 - git - https://github.com/facebook/flipper.git @ fa7f970266ff6353238d4d252c277433f88edc1e

               master - git - https://github.com/CocoaPods/Specs.git @ 5f76360bafa4c6ef03fcf7f820ada2ae2a58ad4b

               trunk - CDN - https://cdn.cocoapods.org/

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

50reactions
priteshrnandgaonkarcommented, Mar 8, 2020

Apologies for late reply.

With cocoapods 1.9.0 You will have to replace Pod::Target::BuildType.static_library with Pod::BuildType.static_library

Let me know if this solves the problem. I will update the docs.

0reactions
BellEraDevcommented, May 23, 2021

Apologies for late reply.

With cocoapods 1.9.0 You will have to replace Pod::Target::BuildType.static_library with Pod::BuildType.static_library

Let me know if this solves the problem. I will update the docs.

Thanks! this solves the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Resolve NameError: Uninitialized Constant in Ruby
The NameError: Uninitialized Constant error in Ruby is often raised when a given variable or constant is undefined or invalid.
Read more >
Ruby on Rails NameError: uninitialized constant
I just set up a new migration and model relationships, and in console when testing the relationship between tables I get the following...
Read more >
<NameError: uninitialized constant RSpec::Core ... - GitHub
GEM VERSIONS Rails 4.2.0 ruby 1.9.3p547 (2014-05-14) [x86_64-linux] ... Exception encountered: #<NameError: uninitialized constant ...
Read more >
Causes of Ruby NameError: Uninitialized Constant Error
The Ruby NameError: Uninitialized Constant error has several causes. Learn what they are and how to fix them with this helpful guide.
Read more >
The foreman logs are filled with errors related to "Backtrace for ...
... for 'unknown class Trend, ignoring' error (NameError): uninitialized constant Trend" after upgrading to Red Hat Satellite 6.11.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found