Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NoMethodError - undefined method `framework?' for true:TrueClass #254

Open
yangchenlarkin opened this issue May 6, 2020 · 11 comments
Open

Comments

@yangchenlarkin
Copy link

Command

/usr/local/bin/pod package HMIBaseline.podspec --dynamic --no-mangle --spec-sources=https://github.com/CocoaPods/Specs.git,git@gitlab.allride-ai.cn:infra/ios-common.git,https://artifactory.allride-ai.cn/artifactory/api/pods/cocoa-local --verbose

Report

  • What did you do?

pod package HMIBaseline.spec.

  • What did you expect to happen?

success

  • What happened instead?

i meet an error

Stack

   CocoaPods : 1.9.1
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15 (19A582a)
       Xcode : 11.3.1 (11C504)
         Git : git version 2.21.1 (Apple Git-122.3)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : ARSpecRepo - git - git@gitlab.allride-ai.cn:infra/ios-common.git @ b1f3805d2a766c9509bde74f4574270917dce669

               cocoa-local - file system
               master - git - https://github.com/CocoaPods/Specs.git @ 163b8a8c3e6980b42c623bc76f6b136f8c68d19c

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

Plugins

cocoapods-art         : 1.0.4
cocoapods-deintegrate : 1.0.4
cocoapods-packager    : 1.5.0
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

Error

NoMethodError - undefined method `framework?' for true:TrueClass
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/target.rb:112:in `build_as_framework?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:164:in `block (2 levels) in link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:159:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:159:in `block in link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:145:in `message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:158:in `link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:51:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb:204:in `install_file_references'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb:139:in `install_dynamic_pod'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:97:in `build_in_sandbox'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:113:in `block in build_package'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:112:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:112:in `build_package'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:80:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
@dnkoutso
Copy link

dnkoutso commented May 6, 2020

Need a sample app.

@yangchenlarkin
Copy link
Author

Need a sample app.

I just create a new project using:

pod lib create HMIApp-DemoApp

then I change the .podspec file to :

# Be sure to run `pod lib lint HMIApp-DemoApp.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'HMIApp-DemoApp'
  s.version          = '0.0.1'
  s.summary          = 'A short description of HMIApp-DemoApp.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/chen.yang/HMIApp-DemoApp'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'chen.yang' => 'chen.yang@allride.ai' }
  s.source           = { :git => 'git@gitlab.allride-ai.cn:infra/ios-lib/hmiapp-demoapp.git', :tag => s.version }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '11.0'

  s.source_files = 'HMIApp-DemoApp/Classes/**/*'
  
  # s.resource_bundles = {
  #   'HMIApp-DemoApp' => ['HMIApp-DemoApp/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

then I commit then tag then push to remote

when I tried to package the pod, I got the error:

Command

/usr/local/bin/pod package HMIApp-DemoApp.podspec --dynamic --no-mangle

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.9.1
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15 (19A582a)
       Xcode : 11.3.1 (11C504)
         Git : git version 2.21.1 (Apple Git-122.3)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : ARSpecRepo - git - git@gitlab.allride-ai.cn:infra/ios-common.git @ b1f3805d2a766c9509bde74f4574270917dce669

               cocoa-local - file system
               master - git - https://github.com/CocoaPods/Specs.git @ 163b8a8c3e6980b42c623bc76f6b136f8c68d19c

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

Plugins

cocoapods-art         : 1.0.4
cocoapods-deintegrate : 1.0.4
cocoapods-packager    : 1.5.0
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

Error

NoMethodError - undefined method `framework?' for true:TrueClass
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/target.rb:112:in `build_as_framework?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:164:in `block (2 levels) in link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:159:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:159:in `block in link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:145:in `message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:158:in `link_headers'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb:51:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb:204:in `install_file_references'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb:139:in `install_dynamic_pod'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:97:in `build_in_sandbox'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:113:in `block in build_package'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:112:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:112:in `build_package'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/pod/command/package.rb:80:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
~~~

@yangchenlarkin
Copy link
Author

I check the source code and I found these:

  • this is where the error happened

https://github.com/CocoaPods/CocoaPods/blob/b812daedb782a5d808807db327aa1d8c01852e09/lib/cocoapods/target.rb#L118

  • this is where the "true" value comes from:

dynamic_target = Pod::PodTarget.new(dynamic_sandbox, true, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)

  • but the definition of initialize method is :

https://github.com/CocoaPods/CocoaPods/blob/b812daedb782a5d808807db327aa1d8c01852e09/lib/cocoapods/target/pod_target.rb#L137

  • so maybe it should be a "build_type" instead of a "true"?

And how can I fix this problem and successfully package my pod?

@dnkoutso
Copy link

dnkoutso commented May 9, 2020

Oh this bug is under cocoapods-packager plug in probably not working with the latest version. Transferring to that repo.

@dnkoutso dnkoutso transferred this issue from CocoaPods/CocoaPods May 9, 2020
@lizuba
Copy link

lizuba commented Dec 3, 2020

Specify what you want like: Pod::BuildType.static_framework() or Pod::BuildType.static_library() and it can run continue

 def build_dynamic_target(dynamic_sandbox, static_installer, platform)
        spec_targets = static_installer.pod_targets.select do |target|
          target.name == @spec.name
        end
        static_target = spec_targets[0]

        file_accessors = create_file_accessors(static_target, dynamic_sandbox)

        archs = []
        buildy_type = Pod::BuildType.static_framework()
        dynamic_target = Pod::PodTarget.new(dynamic_sandbox, buildy_type, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)
        dynamic_target
      end

@BlueAirRL
Copy link

same question! resolved?

@changwuguo
Copy link

how to solve this problem?

@zhonglaoban
Copy link

same issue

@guzuqing
Copy link

@lizuba yes, The new version of cocoapods uses Pod::BuildType to represent the build type.

def self.dynamic_library
  new(:linkage => :dynamic, :packaging => :library)
end

# @return [BuildType] the build type for a static library
#
def self.static_library
  new(:linkage => :static, :packaging => :library)
end

# @return [BuildType] the build type for a dynamic framework
#
def self.dynamic_framework
  new(:linkage => :dynamic, :packaging => :framework)
end

# @return [BuildType] the build type for a static framework
#
def self.static_framework
  new(:linkage => :static, :packaging => :framework)
end

Just select the replacement you need.
for me ,choose the Pod::BuildType.dynamic_framework works well

@changwuguo
Copy link

@guzuqing
Is it adjusted like this??
image

@guzuqing
Copy link

@changwuguo 对的

objchris added a commit to objchris/cocoapods-packager that referenced this issue Dec 5, 2023
The new version of cocoapods uses Pod::BuildType to represent the build type.
@see CocoaPods#254
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants