解決pod私有庫發(fā)布時archs i386/x86_64 lint失敗的問題

問題描述

發(fā)布私有庫時,如果庫支持arch i386/x86_64,在執(zhí)行pod spec lint ...或者直接執(zhí)行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
終端執(zhí)行

gem which cocoapods

返回cocoapods.rb文件的路徑

/Users/XXXXXX/.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)的調(diào)用方法注掉即可

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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容