解决pod私有库发布时archs i386/x86_64 lint失败的问题

问题描述

发布私有库时,如果库支持arch i386/x86_64,在执行pod spec lint ...或者直接执行pod repo push ...时,通常会报下面的错误,部分terminal信息如下:

The following build commands failed:
        Ld /Users/someone/Library/Developer/Xcode/DerivedData/App-gavlycpgugozzpabewwnvvizmsua/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App normal x86_64
    (1 failure)
   Testing with `xcodebuild`. 
 -> sdk_release (1.0.0)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
    - NOTE  | [iOS] xcodebuild:  clang: error: linker command failed with exit code 1 (use -v to see invocation)
......

[!] The `sdk_release.podspec` specification does not validate.

引起的原因

可参考
https://github.com/CocoaPods/CocoaPods/issues/5854
https://github.com/CocoaPods/CocoaPods/issues/5472
https://stackoverflow.com/questions/36618252/cocoapods-podspec-push-without-build-simulator-architecture

解决方案

一 追加option --skip-import-validation

pod repo push privSpecs xxxxxx.podspec --allow-warnings --skip-import-validation
pod spec lint  xxxxxx.podspec --skip-import-validation

--skip-import-validation的描述可参见
https://guides.cocoapods.org/terminal/commands.html#pod_spec_lint

二修改validator.rb

在本地Cocoapods的安装目录下找到文件validator.rb
终端执行

gem which cocoapods

返回cocoapods.rb文件的路径

/Users/yxlong/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.5.3/lib/cocoapods.rb

在和cocoapods.rb同级的目录下存在Folder "/cocoapods/"validator.rb即在它里面。

MacBook-Pro:cocoapods user$ ls
command         gem_version.rb      sandbox
command.rb      generator       sandbox.rb
config.rb       hooks_manager.rb    sources_manager.rb
core_overrides.rb   installer       target
downloader      installer.rb        target.rb
downloader.rb       open-uri.rb     user_interface
executable.rb       project.rb      user_interface.rb
external_sources    resolver        validator.rb
external_sources.rb resolver.rb

打开validator.rb,找到验证方法xcodebuild(action, scheme, configuration)的调用方法注掉即可

def xcodebuild(action, scheme, configuration)
      require 'fourflusher'
      command = %W(clean #{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration})
      case consumer.platform_name
      when :osx, :macos
        command += %w(CODE_SIGN_IDENTITY=)
      when :ios
        command += %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)
        command += Fourflusher::SimControl.new.destination(:oldest, 'iOS', deployment_target)
      when :watchos
        command += %w(CODE_SIGN_IDENTITY=- -sdk watchsimulator)
        command += Fourflusher::SimControl.new.destination(:oldest, 'watchOS', deployment_target)
      when :tvos
        command += %w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator)
        command += Fourflusher::SimControl.new.destination(:oldest, 'tvOS', deployment_target)
      end

      # 注掉此处代码
#      begin
#        _xcodebuild(command, true)
#      rescue => e
#        message = 'Returned an unsuccessful exit code.'
#        message += ' You can use `--verbose` for more information.' unless config.verbose?
#        error('xcodebuild', message)
#        e.message
#      end
end

你可能感兴趣的:(解决pod私有库发布时archs i386/x86_64 lint失败的问题)