Flipper: NameError - uninitialized constant Pod::Target::BuildType

Created on 5 Mar 2020  路  5Comments  路  Source: facebook/flipper

馃悰 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

```

Most helpful comment

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.

All 5 comments

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.

@priteshrnandgaonkar
Thank you for the solution. It saved my day

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 worked

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.

You saved my day <3

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.

Was this page helpful?
0 / 5 - 0 ratings