cocoapods-dylint 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9c0a644e9cd0acc1f2d7b1a020e135d48ce895e
4
- data.tar.gz: 5803803ba9c3ed40c1e64751d147c4d691ba6817
3
+ metadata.gz: 0d2609c2b1de4694fef7b74a647ea7884dde908b
4
+ data.tar.gz: 1cb3da2ac49a4d33c9dcf0f4213248743b6d2081
5
5
  SHA512:
6
- metadata.gz: fbe3ac62b834e9cf087eafbf1dcea50e5ab928315943fba504aeac2b1fea94a1ace3dc7386e7bd70b3c648f6349647caad46d4fc1ce1087ddcb3014d7daf7a46
7
- data.tar.gz: ad97a1b31e62ea5c470ef0b8d78149d5b686e7f33d9e4a75a155e55fba6793b1a09fa2cb09559e68c0dc7e1f526e8db0e66d37e75160b6de75d0a1d09f179473
6
+ metadata.gz: 49dc4defca16716a80da6f1db92217ca4e3f8535dc1ecccf848afd9d475d6fe5dc96fab80dcc07cd8110cefabbc42357b7e689877c4ebecd010f0df29ab51eee
7
+ data.tar.gz: 747e85b60a4665dc65d97aa28fc752de6d81bab6a82f7cbc98ca010c22f5cc8174f5501fc0aa25e64551c04a02417eee8bd2aa6e8ca5f2685d7f06c3b2a5f9b8
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency "cocoapods", '>= 1.3.1', '< 1.4.0'
21
22
  spec.add_development_dependency 'bundler', '~> 1.3'
22
23
  spec.add_development_dependency 'rake'
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsDylint
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/validator.rb CHANGED
@@ -14,10 +14,6 @@ module Pod
14
14
  class DyValidator
15
15
  include Config::Mixin
16
16
 
17
- # The default version of Swift to use when linting pods
18
- #
19
- DEFAULT_SWIFT_VERSION = '3.2'.freeze
20
-
21
17
  # @return [Specification::Linter] the linter instance from CocoaPods
22
18
  # Core.
23
19
  #
@@ -256,12 +252,7 @@ module Pod
256
252
  # @return [String] the SWIFT_VERSION to use for validation.
257
253
  #
258
254
  def swift_version
259
- return @swift_version unless @swift_version.nil?
260
- if (version = spec.swift_version) || (version = dot_swift_version)
261
- @swift_version = version.to_s
262
- else
263
- DEFAULT_SWIFT_VERSION
264
- end
255
+ @swift_version ||= dot_swift_version || '3.0'
265
256
  end
266
257
 
267
258
  # Set the SWIFT_VERSION that should be used to validate the pod.
@@ -277,10 +268,11 @@ module Pod
277
268
  swift_version_path.read.strip
278
269
  end
279
270
 
280
- # @return [Boolean] Whether any of the pod targets part of this validator use Swift or not.
271
+ # @return [String] A string representing the Swift version used during linting
272
+ # or nil, if Swift was not used.
281
273
  #
282
- def uses_swift?
283
- @installer.pod_targets.any?(&:uses_swift?)
274
+ def used_swift_version
275
+ swift_version if @installer.pod_targets.any?(&:uses_swift?)
284
276
  end
285
277
 
286
278
  #-------------------------------------------------------------------------#
@@ -307,7 +299,6 @@ module Pod
307
299
  validate_screenshots(spec)
308
300
  validate_social_media_url(spec)
309
301
  validate_documentation_url(spec)
310
- validate_source_url(spec)
311
302
 
312
303
  valid = spec.available_platforms.send(fail_fast ? :all? : :each) do |platform|
313
304
  UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
@@ -318,7 +309,7 @@ module Pod
318
309
  download_pod
319
310
  check_file_patterns
320
311
  install_pod
321
- validate_swift_version
312
+ validate_dot_swift_version
322
313
  add_app_project_import
323
314
  validate_vendored_dynamic_frameworks
324
315
  build_pod
@@ -394,50 +385,14 @@ module Pod
394
385
  validate_url(spec.documentation_url) if spec.documentation_url
395
386
  end
396
387
 
397
- # Performs validations related to the `source` -> `http` attribute (if exists)
398
- #
399
- def validate_source_url(spec)
400
- return if spec.source.nil? || spec.source[:http].nil?
401
- url = spec.source[:http]
402
- return if url.downcase.start_with?('https://')
403
- warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \
404
- 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
405
- 'This will be an error in future releases. Please update the URL to use https.')
406
- end
407
-
408
- # Performs validation for which version of Swift is used during validation.
409
- #
410
- # An error will be displayed if the user has provided a `swift_version` attribute within the podspec but is also
411
- # using either `--swift-version` parameter or a `.swift-version with a different Swift version.
412
- #
413
- # The user will be warned that the default version of Swift was used if the following things are true:
414
- # - The project uses Swift at all
415
- # - The user did not supply a Swift version via a parameter
416
- # - There is no `swift_version` attribute set within the specification
417
- # - There is no `.swift-version` file present either.
418
- #
419
- def validate_swift_version
420
- return unless uses_swift?
421
- spec_swift_version = spec.swift_version
422
- unless spec_swift_version.nil?
423
- message = nil
424
- if !dot_swift_version.nil? && dot_swift_version != spec_swift_version.to_s
425
- message = "Specification `#{spec.name}` specifies an inconsistent `swift_version` (`#{spec_swift_version}`) compared to the one present in your `.swift-version` file (`#{dot_swift_version}`). " \
426
- 'Please remove the `.swift-version` file which is now deprecated and only use the `swift_version` attribute within your podspec.'
427
- elsif !@swift_version.nil? && @swift_version != spec_swift_version.to_s
428
- message = "Specification `#{spec.name}` specifies an inconsistent `swift_version` (`#{spec_swift_version}`) compared to the one passed during lint (`#{@swift_version}`)."
429
- end
430
- unless message.nil?
431
- error('swift', message)
432
- return
433
- end
434
- end
435
- if @swift_version.nil? && spec_swift_version.nil? && dot_swift_version.nil?
436
- warning('swift',
437
- 'The validator used ' \
438
- "Swift #{DEFAULT_SWIFT_VERSION} by default because no Swift version was specified. " \
439
- 'To specify a Swift version during validation, add the `swift_version` attribute in your podspec. ' \
440
- 'Note that usage of the `--swift-version` parameter or a `.swift-version` file is now deprecated.')
388
+ def validate_dot_swift_version
389
+ if !used_swift_version.nil? && dot_swift_version.nil?
390
+ warning(:swift_version,
391
+ 'The validator for Swift projects uses ' \
392
+ 'Swift 3.0 by default, if you are using a different version of ' \
393
+ 'swift you can use a `.swift-version` file to set the version for ' \
394
+ "your Pod. For example to use Swift 2.3, run: \n" \
395
+ ' `echo "2.3" > .swift-version`')
441
396
  end
442
397
  end
443
398
 
@@ -475,11 +430,11 @@ module Pod
475
430
 
476
431
  def create_app_project
477
432
  app_project = Xcodeproj::Project.new(validation_dir + 'App.xcodeproj')
478
- Pod::Generator::AppTargetHelper.add_app_target(app_project, consumer.platform_name, deployment_target)
433
+ app_project.new_target(:application, 'App', consumer.platform_name, deployment_target)
479
434
  app_project.root_object.attributes['TargetAttributes'] = {app_project.targets[0].uuid => {"ProvisioningStyle" => "Manual"}}
480
435
  target = app_project.targets[0]
481
436
  info_plist_path = validation_dir + 'Info.plist'
482
- info_plist = Pod::Generator::InfoPlistFile.new('1.0', :ios, :appl)
437
+ info_plist = Pod::Generator::InfoPlistFile.new(target, :bundle_package_type => :appl)
483
438
  f = File.new(info_plist_path, 'w+')
484
439
  f.write(info_plist.generate)
485
440
  f.close
@@ -496,17 +451,64 @@ module Pod
496
451
 
497
452
  def add_app_project_import
498
453
  app_project = Xcodeproj::Project.open(validation_dir + 'App.xcodeproj')
499
- app_target = app_project.targets.first
500
454
  pod_target = @installer.pod_targets.find { |pt| pt.pod_name == spec.root.name }
501
- Pod::Generator::AppTargetHelper.add_app_project_import(app_project, app_target, pod_target, consumer.platform_name, use_frameworks)
502
- Pod::Generator::AppTargetHelper.add_swift_version(app_target, swift_version)
503
- Pod::Generator::AppTargetHelper.add_xctest_search_paths(app_target) if @installer.pod_targets.any? { |pt| pt.spec_consumers.any? { |c| c.frameworks.include?('XCTest') } }
455
+
456
+ source_file = write_app_import_source_file(pod_target)
457
+ source_file_ref = app_project.new_group('App', 'App').new_file(source_file)
458
+ app_target = app_project.targets.first
459
+ app_target.add_file_references([source_file_ref])
460
+ add_swift_version(app_target)
461
+ add_xctest(app_target) if @installer.pod_targets.any? { |pt| pt.spec_consumers.any? { |c| c.frameworks.include?('XCTest') } }
504
462
  app_project.save
505
463
  Xcodeproj::XCScheme.share_scheme(app_project.path, 'App')
506
464
  # Share the pods xcscheme only if it exists. For pre-built vendored pods there is no xcscheme generated.
507
465
  Xcodeproj::XCScheme.share_scheme(@installer.pods_project.path, pod_target.label) if shares_pod_target_xcscheme?(pod_target)
508
466
  end
509
467
 
468
+ def add_swift_version(app_target)
469
+ app_target.build_configurations.each do |configuration|
470
+ configuration.build_settings['SWIFT_VERSION'] = swift_version
471
+ end
472
+ end
473
+
474
+ def add_xctest(app_target)
475
+ app_target.build_configurations.each do |configuration|
476
+ search_paths = configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= '$(inherited)'
477
+ search_paths << ' "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
478
+ end
479
+ end
480
+
481
+ def write_app_import_source_file(pod_target)
482
+ language = pod_target.uses_swift? ? :swift : :objc
483
+
484
+ if language == :swift
485
+ source_file = validation_dir.+('App/main.swift')
486
+ source_file.parent.mkpath
487
+ import_statement = use_frameworks && pod_target.should_build? ? "import #{pod_target.product_module_name}\n" : ''
488
+ source_file.open('w') { |f| f << import_statement }
489
+ else
490
+ source_file = validation_dir.+('App/main.m')
491
+ source_file.parent.mkpath
492
+ import_statement = if use_frameworks && pod_target.should_build?
493
+ "@import #{pod_target.product_module_name};\n"
494
+ else
495
+ header_name = "#{pod_target.product_module_name}/#{pod_target.product_module_name}.h"
496
+ if pod_target.sandbox.public_headers.root.+(header_name).file?
497
+ "#import <#{header_name}>\n"
498
+ else
499
+ ''
500
+ end
501
+ end
502
+ source_file.open('w') do |f|
503
+ f << "@import Foundation;\n"
504
+ f << "@import UIKit;\n" if consumer.platform_name == :ios || consumer.platform_name == :tvos
505
+ f << "@import Cocoa;\n" if consumer.platform_name == :osx
506
+ f << "#{import_statement}int main() {}\n"
507
+ end
508
+ end
509
+ source_file
510
+ end
511
+
510
512
  # It creates a podfile in memory and builds a library containing the pod
511
513
  # for all available platforms with xcodebuild.
512
514
  #
@@ -515,24 +517,12 @@ module Pod
515
517
  perform_post_install_actions).each { |m| @installer.send(m) }
516
518
 
517
519
  deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)
518
- configure_pod_targets(@installer.aggregate_targets, deployment_target)
519
- @installer.pods_project.save
520
- end
521
-
522
- def configure_pod_targets(targets, deployment_target)
523
- targets.each do |target|
520
+ @installer.aggregate_targets.each do |target|
524
521
  target.pod_targets.each do |pod_target|
525
522
  next unless (native_target = pod_target.native_target)
526
523
  native_target.build_configuration_list.build_configurations.each do |build_configuration|
527
524
  (build_configuration.build_settings['OTHER_CFLAGS'] ||= '$(inherited)') << ' -Wincomplete-umbrella'
528
- build_configuration.build_settings['SWIFT_VERSION'] = (pod_target.swift_version || swift_version) if pod_target.uses_swift?
529
- end
530
- if pod_target.uses_swift?
531
- pod_target.test_native_targets.each do |test_native_target|
532
- test_native_target.build_configuration_list.build_configurations.each do |build_configuration|
533
- build_configuration.build_settings['SWIFT_VERSION'] = swift_version
534
- end
535
- end
525
+ build_configuration.build_settings['SWIFT_VERSION'] = swift_version if pod_target.uses_swift?
536
526
  end
537
527
  end
538
528
  if target.pod_targets.any?(&:uses_swift?) && consumer.platform_name == :ios &&
@@ -541,6 +531,7 @@ module Pod
541
531
  error('swift', 'Swift support uses dynamic frameworks and is therefore only supported on iOS > 8.') unless uses_xctest
542
532
  end
543
533
  end
534
+ @installer.pods_project.save
544
535
  end
545
536
 
546
537
  def validate_vendored_dynamic_frameworks
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dylint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 黄露洋
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocoapods
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 1.4.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 1.4.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: bundler
15
35
  requirement: !ruby/object:Gem::Requirement