cocoapods-packager-tal 1.5.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop-cocoapods.yml +71 -0
  5. data/.rubocop.yml +38 -0
  6. data/.travis.yml +17 -0
  7. data/Gemfile +12 -0
  8. data/Gemfile.lock +131 -0
  9. data/LICENSE +22 -0
  10. data/README.md +42 -0
  11. data/Rakefile +29 -0
  12. data/cocoapods-packager.gemspec +22 -0
  13. data/lib/cocoapods-packager/builder.rb +409 -0
  14. data/lib/cocoapods-packager/framework.rb +66 -0
  15. data/lib/cocoapods-packager/mangle.rb +32 -0
  16. data/lib/cocoapods-packager/pod_utils.rb +324 -0
  17. data/lib/cocoapods-packager/spec_builder.rb +171 -0
  18. data/lib/cocoapods-packager/symbols.rb +42 -0
  19. data/lib/cocoapods-packager/tal_installer.rb +33 -0
  20. data/lib/cocoapods-packager/tal_target_validator.rb +62 -0
  21. data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
  22. data/lib/cocoapods_packager.rb +5 -0
  23. data/lib/cocoapods_plugin.rb +16 -0
  24. data/lib/pod/command/package.rb +240 -0
  25. data/scripts/lstconst.sh +9 -0
  26. data/scripts/lstsym.sh +8 -0
  27. data/spec/command/error_spec.rb +81 -0
  28. data/spec/command/package_spec.rb +420 -0
  29. data/spec/command/subspecs_spec.rb +30 -0
  30. data/spec/fixtures/Archs.podspec +13 -0
  31. data/spec/fixtures/Builder.podspec +25 -0
  32. data/spec/fixtures/CPDColors.podspec +19 -0
  33. data/spec/fixtures/FH.podspec +18 -0
  34. data/spec/fixtures/KFData.podspec +73 -0
  35. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  36. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
  37. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  39. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  40. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  41. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  42. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  43. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  44. data/spec/fixtures/LibraryDemo.podspec +14 -0
  45. data/spec/fixtures/LocalSources/LICENSE +0 -0
  46. data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
  47. data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
  48. data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
  49. data/spec/fixtures/NikeKit.podspec +19 -0
  50. data/spec/fixtures/OpenSans.podspec +18 -0
  51. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  58. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  59. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  60. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  61. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  62. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  63. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  64. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  65. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  66. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  67. data/spec/fixtures/PackagerTest/Podfile +10 -0
  68. data/spec/fixtures/PackagerTest/Podfile.lock +36 -0
  69. data/spec/fixtures/Weakly.podspec +13 -0
  70. data/spec/fixtures/a.podspec +19 -0
  71. data/spec/fixtures/foo-bar.podspec +19 -0
  72. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  73. data/spec/integration/project_spec.rb +70 -0
  74. data/spec/spec_helper.rb +79 -0
  75. data/spec/unit/pod/utils_spec.rb +58 -0
  76. data/spec/unit/specification/builder_spec.rb +62 -0
  77. data/spec/unit/specification/spec_builder_spec.rb +61 -0
  78. data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
  79. metadata +223 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c92587f1930e7c34ef172c8440559bcee6679afad3cc0a7fbbed95b8965526db
4
+ data.tar.gz: 7aa946fd8abcc75ae01e912db3d7f5fb87261f036da22f47d52c53802f07d751
5
+ SHA512:
6
+ metadata.gz: 54da3a6df8f713d65156e0124f7b43d621d7237e0dc2dd40ab6d8d41615834bd3460a4e49397da32f8f0ead9558d6ec680812fbb52ae0315f73dd10f861e760f
7
+ data.tar.gz: 5958f5ec0dd548cf1bc068ec3679ac9bf9b586da7fe13b83d726be29aa3899b3d36c61f3a9bb7dd102af0be133de7dc2059769d89a82840ffe4435a36016e6fb
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,5 @@
1
+ coverage
2
+ pkg
3
+ .DS_Store
4
+ .bundle/
5
+ *.gem
@@ -0,0 +1,71 @@
1
+ AllCops:
2
+ Include:
3
+ - Rakefile
4
+ - Gemfile
5
+ - ./*.gemspec
6
+ Exclude:
7
+ - spec/fixtures/**/*
8
+ - vendor/**/*
9
+
10
+ # At the moment not ready to be used
11
+ # https://github.com/bbatsov/rubocop/issues/947
12
+ Documentation:
13
+ Enabled: false
14
+
15
+ #- CocoaPods -----------------------------------------------------------------#
16
+
17
+ # We adopted raise instead of fail.
18
+ SignalException:
19
+ EnforcedStyle: only_raise
20
+
21
+ # They are idiomatic
22
+ AssignmentInCondition:
23
+ Enabled: false
24
+
25
+ # Allow backticks
26
+ AsciiComments:
27
+ Enabled: false
28
+
29
+ # Indentation clarifies logic branches in implementations
30
+ IfUnlessModifier:
31
+ Enabled: false
32
+
33
+ # No enforced convention here.
34
+ SingleLineBlockParams:
35
+ Enabled: false
36
+
37
+ # We only add the comment when needed.
38
+ Encoding:
39
+ Enabled: false
40
+
41
+ #- CocoaPods support for Ruby 1.8.7 ------------------------------------------#
42
+
43
+ HashSyntax:
44
+ EnforcedStyle: hash_rockets
45
+
46
+ Lambda:
47
+ Enabled: false
48
+
49
+ DotPosition:
50
+ EnforcedStyle: trailing
51
+
52
+ #- CocoaPods specs -----------------------------------------------------------#
53
+
54
+ # Allow for `should.match /regexp/`.
55
+ AmbiguousRegexpLiteral:
56
+ Exclude:
57
+ - spec/**/*
58
+
59
+ # Allow `object.should == object` syntax.
60
+ Void:
61
+ Exclude:
62
+ - spec/**/*
63
+
64
+ ClassAndModuleChildren:
65
+ Exclude:
66
+ - spec/**/*
67
+
68
+ UselessComparison:
69
+ Exclude:
70
+ - spec/**/*
71
+
@@ -0,0 +1,38 @@
1
+ inherit_from:
2
+ - .rubocop-cocoapods.yml
3
+
4
+ #- Core -----------------------------------------------------------------------
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - spec/**/*
9
+ - spec/fixtures/**/*
10
+ - vendor/**/*
11
+
12
+ Style/Tab:
13
+ Enabled: false
14
+
15
+ LineLength:
16
+ Enabled: false
17
+
18
+ ClassLength:
19
+ Enabled: false
20
+
21
+ MethodLength:
22
+ Enabled: false
23
+
24
+ Metrics/AbcSize:
25
+ Enabled: false
26
+
27
+ Metrics/CyclomaticComplexity:
28
+ Enabled: false
29
+
30
+ Metrics/PerceivedComplexity:
31
+ Enabled: false
32
+
33
+ Metrics/ParameterLists:
34
+ Enabled: false
35
+
36
+ Style/SpecialGlobalVars:
37
+ EnforcedStyle: use_perl_names
38
+
@@ -0,0 +1,17 @@
1
+ osx_image: xcode10.1
2
+ language: objective-c
3
+ cache: bundler
4
+
5
+ before_install:
6
+ - bundle install
7
+ - bundle exec pod repo update --silent
8
+
9
+ env:
10
+ - TASK=rubocop
11
+ - TASK="rake spec:unit"
12
+ - TASK="rake spec:integration"
13
+ - TASK="rake spec:command"
14
+
15
+ script:
16
+ - bundle exec $TASK
17
+
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'bacon'
7
+ gem 'mocha-on-bacon'
8
+ gem 'mocha'
9
+ gem 'prettybacon'
10
+ gem 'coveralls', :require => false
11
+ gem 'rubocop'
12
+ end
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-packager-tal (1.5.0.10)
5
+ cocoapods (>= 1.5.3, < 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ CFPropertyList (3.0.0)
11
+ activesupport (4.2.11.1)
12
+ i18n (~> 0.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ ast (2.4.0)
17
+ atomos (0.1.3)
18
+ bacon (1.2.0)
19
+ claide (1.0.2)
20
+ cocoapods (1.5.3)
21
+ activesupport (>= 4.0.2, < 5)
22
+ claide (>= 1.0.2, < 2.0)
23
+ cocoapods-core (= 1.5.3)
24
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
25
+ cocoapods-downloader (>= 1.2.0, < 2.0)
26
+ cocoapods-plugins (>= 1.0.0, < 2.0)
27
+ cocoapods-search (>= 1.0.0, < 2.0)
28
+ cocoapods-stats (>= 1.0.0, < 2.0)
29
+ cocoapods-trunk (>= 1.3.0, < 2.0)
30
+ cocoapods-try (>= 1.1.0, < 2.0)
31
+ colored2 (~> 3.1)
32
+ escape (~> 0.0.4)
33
+ fourflusher (~> 2.0.1)
34
+ gh_inspector (~> 1.0)
35
+ molinillo (~> 0.6.5)
36
+ nap (~> 1.0)
37
+ ruby-macho (~> 1.1)
38
+ xcodeproj (>= 1.5.7, < 2.0)
39
+ cocoapods-core (1.5.3)
40
+ activesupport (>= 4.0.2, < 6)
41
+ fuzzy_match (~> 2.0.4)
42
+ nap (~> 1.0)
43
+ cocoapods-deintegrate (1.0.4)
44
+ cocoapods-downloader (1.2.2)
45
+ cocoapods-plugins (1.0.0)
46
+ nap
47
+ cocoapods-search (1.0.0)
48
+ cocoapods-stats (1.1.0)
49
+ cocoapods-trunk (1.3.1)
50
+ nap (>= 0.8, < 2.0)
51
+ netrc (~> 0.11)
52
+ cocoapods-try (1.1.0)
53
+ colored2 (3.1.2)
54
+ concurrent-ruby (1.1.5)
55
+ coveralls (0.8.23)
56
+ json (>= 1.8, < 3)
57
+ simplecov (~> 0.16.1)
58
+ term-ansicolor (~> 1.3)
59
+ thor (>= 0.19.4, < 2.0)
60
+ tins (~> 1.6)
61
+ docile (1.3.2)
62
+ escape (0.0.4)
63
+ fourflusher (2.0.1)
64
+ fuzzy_match (2.0.4)
65
+ gh_inspector (1.1.3)
66
+ i18n (0.9.5)
67
+ concurrent-ruby (~> 1.0)
68
+ jaro_winkler (1.5.3)
69
+ json (2.2.0)
70
+ metaclass (0.0.4)
71
+ minitest (5.11.3)
72
+ mocha (1.9.0)
73
+ metaclass (~> 0.0.1)
74
+ mocha-on-bacon (0.2.3)
75
+ mocha (>= 0.13.0)
76
+ molinillo (0.6.6)
77
+ nanaimo (0.2.6)
78
+ nap (1.1.0)
79
+ netrc (0.11.0)
80
+ parallel (1.17.0)
81
+ parser (2.6.3.0)
82
+ ast (~> 2.4.0)
83
+ prettybacon (0.0.2)
84
+ bacon (~> 1.2)
85
+ rainbow (3.0.0)
86
+ rake (12.3.2)
87
+ rubocop (0.73.0)
88
+ jaro_winkler (~> 1.5.1)
89
+ parallel (~> 1.10)
90
+ parser (>= 2.6)
91
+ rainbow (>= 2.2.2, < 4.0)
92
+ ruby-progressbar (~> 1.7)
93
+ unicode-display_width (>= 1.4.0, < 1.7)
94
+ ruby-macho (1.4.0)
95
+ ruby-progressbar (1.10.1)
96
+ simplecov (0.16.1)
97
+ docile (~> 1.1)
98
+ json (>= 1.8, < 3)
99
+ simplecov-html (~> 0.10.0)
100
+ simplecov-html (0.10.2)
101
+ term-ansicolor (1.7.1)
102
+ tins (~> 1.0)
103
+ thor (0.20.3)
104
+ thread_safe (0.3.6)
105
+ tins (1.21.1)
106
+ tzinfo (1.2.5)
107
+ thread_safe (~> 0.1)
108
+ unicode-display_width (1.6.0)
109
+ xcodeproj (1.11.0)
110
+ CFPropertyList (>= 2.3.3, < 4.0)
111
+ atomos (~> 0.1.3)
112
+ claide (>= 1.0.2, < 2.0)
113
+ colored2 (~> 3.1)
114
+ nanaimo (~> 0.2.6)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ bacon
121
+ bundler (~> 1.3)
122
+ cocoapods-packager-tal!
123
+ coveralls
124
+ mocha
125
+ mocha-on-bacon
126
+ prettybacon
127
+ rake
128
+ rubocop
129
+
130
+ BUNDLED WITH
131
+ 1.17.3
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ This project is licensed under the MIT license.
2
+
3
+ Copyright (c) 2014 Kyle Fuller, Boris Bügling and CocoaPods Dev Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # CocoaPods Packager
2
+
3
+ [![Build Status](http://img.shields.io/travis/CocoaPods/cocoapods-packager/master.svg?style=flat)](https://travis-ci.org/CocoaPods/cocoapods-packager)
4
+ [![Coverage Status](https://img.shields.io/coveralls/CocoaPods/cocoapods-packager.svg)](https://coveralls.io/r/CocoaPods/cocoapods-packager?branch=master)
5
+ [![Gem Version](http://img.shields.io/gem/v/cocoapods-packager.svg?style=flat)](http://badge.fury.io/rb/cocoapods-packager)
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/CocoaPods/cocoapods-packager.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-packager)
7
+
8
+ CocoaPods plugin which allows you to generate a framework or static library from a podspec.
9
+
10
+ This plugin is for CocoaPods *developers*, who need to distribute their Pods not only via CocoaPods, but also as frameworks or static libraries for people who do not use Pods.
11
+
12
+ ## Why should I use Pods if I'm targeting developers who don't use Pods?
13
+
14
+ There are still a number of advantages to developing against a `podspec`, even if your public distribution is closed-source:
15
+
16
+ 1. You can easily use the Pod in-house in an open-source style. This makes step-by-step debugging and multi-project development a breeze.
17
+ 2. You can pull in third-party dependencies using CocoaPods. (CocoaPods Packager is even capable of mangling symbols to improve compatibility with any symbols that might appear in the integrating app.)
18
+ 3. You can declaratively specify build settings (e.g. frameworks, compiler flags) in your `podspec`. This is easier to maintain and replicate than build settings embedded in your Xcode project.
19
+
20
+ ## Installation
21
+
22
+ ```sh
23
+ $ gem install cocoapods-packager
24
+ ```
25
+
26
+ or add a line to your Gemfile:
27
+
28
+ ```ruby
29
+ gem "cocoapods-packager"
30
+ ```
31
+
32
+ then run `bundle install`.
33
+
34
+ This installs Packager as a CocoaPods plugin.
35
+
36
+ ## Usage
37
+
38
+ ```bash
39
+ $ pod package KFData.podspec
40
+ ```
41
+
42
+ See also `pod --help`.
@@ -0,0 +1,29 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ namespace :spec do
8
+ desc 'Runs the unit specs'
9
+ task :unit do
10
+ sh "bundle exec bacon #{specs('unit/**')}"
11
+ end
12
+
13
+ desc 'Runs the integration specs'
14
+ task :integration do
15
+ sh "bundle exec bacon #{specs('integration/**')}"
16
+ end
17
+
18
+ desc 'Runs the command specs'
19
+ task :command do
20
+ sh "bundle exec bacon #{specs('command/**')}"
21
+ end
22
+
23
+ desc 'Runs all the specs'
24
+ task :all do
25
+ sh "bundle exec bacon #{specs('**')}"
26
+ end
27
+ end
28
+
29
+ task :default => 'spec:all'
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_packager.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-packager-tal'
8
+ spec.version = Pod::Packager::VERSION
9
+ spec.authors = ['Kyle Fuller', 'Boris Bügling']
10
+ spec.summary = 'CocoaPods plugin which allows you to generate a framework or static library from a podspec.'
11
+ spec.homepage = 'https://github.com/Minlison/cocoapods-packager.git'
12
+ spec.license = 'MIT'
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "cocoapods", '>= 1.5.3', '< 2.0'
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,409 @@
1
+ module Pod
2
+ class Builder
3
+ def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps, xcconfig=nil)
4
+ @platform = platform
5
+ @static_installer = static_installer
6
+ @source_dir = source_dir
7
+ @static_sandbox_root = static_sandbox_root
8
+ @dynamic_sandbox_root = dynamic_sandbox_root
9
+ @public_headers_root = public_headers_root
10
+ @spec = spec
11
+ @embedded = embedded
12
+ @mangle = mangle
13
+ @dynamic = dynamic
14
+ @config = config
15
+ @xcconfig = xcconfig
16
+ @bundle_identifier = bundle_identifier
17
+ @exclude_deps = exclude_deps
18
+
19
+ @file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
20
+ end
21
+
22
+ def build(package_type)
23
+ case package_type
24
+ when :static_library
25
+ build_static_library
26
+ when :static_framework
27
+ build_static_framework
28
+ when :dynamic_framework
29
+ build_dynamic_framework
30
+ end
31
+ end
32
+
33
+ def build_static_library
34
+ UI.puts("Building static library #{@spec} with configuration #{@config}")
35
+
36
+ defines = compile
37
+ build_sim_libraries(defines)
38
+
39
+ platform_path = Pathname.new(@platform.name.to_s)
40
+ platform_path.mkdir unless platform_path.exist?
41
+
42
+ output = platform_path + "lib#{@spec.name}.a"
43
+
44
+ if @platform.name == :ios
45
+ build_static_library_for_ios(output)
46
+ else
47
+ build_static_library_for_mac(output)
48
+ end
49
+ end
50
+
51
+ def build_static_framework
52
+ UI.puts("Building static framework #{@spec} with configuration #{@config}")
53
+
54
+ defines = compile
55
+ build_sim_libraries(defines)
56
+
57
+ create_framework
58
+ output = @fwk.versions_path + Pathname.new(@spec.name)
59
+
60
+ if @platform.name == :ios
61
+ build_static_library_for_ios(output)
62
+ else
63
+ build_static_library_for_mac(output)
64
+ end
65
+
66
+ copy_headers
67
+ copy_license
68
+ copy_resources
69
+ end
70
+
71
+ def link_embedded_resources
72
+ target_path = @fwk.root_path + Pathname.new('Resources')
73
+ target_path.mkdir unless target_path.exist?
74
+
75
+ Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
76
+ resource = Pathname.new(resource).relative_path_from(target_path)
77
+ `ln -sf #{resource} #{target_path}`
78
+ end
79
+ end
80
+
81
+ def build_dynamic_framework
82
+ UI.puts("Building dynamic framework #{@spec} with configuration #{@config}")
83
+
84
+ defines = compile
85
+ build_sim_libraries(defines)
86
+
87
+ if @bundle_identifier
88
+ defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
89
+ end
90
+
91
+ output = "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}"
92
+
93
+ clean_directory_for_dynamic_build
94
+ if @platform.name == :ios
95
+ build_dynamic_framework_for_ios(defines, output)
96
+ else
97
+ build_dynamic_framework_for_mac(defines, output)
98
+ end
99
+
100
+ copy_resources
101
+ end
102
+
103
+ def build_dynamic_framework_for_ios(defines, output)
104
+ # Specify frameworks to link and search paths
105
+ linker_flags = static_linker_flags_in_sandbox
106
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
107
+
108
+ # Build Target Dynamic Framework for both device and Simulator
109
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
110
+ device_options = ios_build_options << ' -sdk iphoneos'
111
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
112
+
113
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
114
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
115
+
116
+ # Combine architectures
117
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
118
+
119
+ FileUtils.mkdir(@platform.name.to_s)
120
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
121
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
122
+ end
123
+
124
+ def build_dynamic_framework_for_mac(defines, _output)
125
+ # Specify frameworks to link and search paths
126
+ linker_flags = static_linker_flags_in_sandbox
127
+ defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
128
+
129
+ # Build Target Dynamic Framework for osx
130
+ defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
131
+ xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
132
+
133
+ FileUtils.mkdir(@platform.name.to_s)
134
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
135
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
136
+ end
137
+
138
+ def build_sim_libraries(defines)
139
+ if @platform.name == :ios
140
+ xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
141
+ end
142
+ end
143
+
144
+ def build_static_library_for_ios(output)
145
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
146
+ libs = ios_architectures.map do |arch|
147
+ library = "#{@static_sandbox_root}/build/package-#{arch}.a"
148
+ `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
149
+ library
150
+ end
151
+
152
+ `lipo -create -output #{output} #{libs.join(' ')}`
153
+ end
154
+
155
+ def build_static_library_for_mac(output)
156
+ static_libs = static_libs_in_sandbox + vendored_libraries
157
+ `libtool -static -o #{output} #{static_libs.join(' ')}`
158
+ end
159
+
160
+ def build_with_mangling(options)
161
+ UI.puts 'Mangling symbols'
162
+ defines = Symbols.mangle_for_pod_dependencies(@spec.name, @static_sandbox_root)
163
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
164
+
165
+ UI.puts 'Building mangled framework'
166
+ xcodebuild(defines, options)
167
+ defines
168
+ end
169
+
170
+ def clean_directory_for_dynamic_build
171
+ # Remove static headers to avoid duplicate declaration conflicts
172
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Public/#{@spec.name}")
173
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Private/#{@spec.name}")
174
+
175
+ # Equivalent to removing derrived data
176
+ FileUtils.rm_rf('Pods/build')
177
+ end
178
+
179
+ def compile
180
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
181
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
182
+
183
+ if @platform.name == :ios
184
+ options = ios_build_options
185
+ end
186
+
187
+ xcodebuild(defines, options)
188
+
189
+ if @mangle
190
+ return build_with_mangling(options)
191
+ end
192
+
193
+ defines
194
+ end
195
+
196
+ def copy_headers
197
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
198
+
199
+ Dir.glob("#{headers_source_root}/**/*.h").
200
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
201
+
202
+ # If custom 'module_map' is specified add it to the framework distribution
203
+ # otherwise check if a header exists that is equal to 'spec.name', if so
204
+ # create a default 'module_map' one using it.
205
+ if !@spec.module_map.nil?
206
+ module_map_file = @file_accessors.flat_map(&:module_map).first
207
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
208
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
209
+ module_map = <<MAP
210
+ framework module #{@spec.name} {
211
+ umbrella header "#{@spec.name}.h"
212
+
213
+ export *
214
+ module * { export * }
215
+ }
216
+ MAP
217
+ end
218
+
219
+ unless module_map.nil?
220
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
221
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
222
+ end
223
+ end
224
+
225
+ def copy_license
226
+ license_file = @spec.license[:file] || 'LICENSE'
227
+ license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
228
+ FileUtils.cp(license_file, '.') if license_file.exist?
229
+ end
230
+
231
+ def copy_vendored_libs
232
+
233
+ if @dynamic
234
+ else
235
+ vendored_frameworks = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
236
+ expand_paths(spec.consumer(@platform).vendored_frameworks)
237
+ end.compact.uniq
238
+
239
+ if vendored_frameworks.count > 0
240
+ vendored_frameworks_path = "ios"
241
+ if !File.exist?(vendored_frameworks_path)
242
+ FileUtils.mkdir_p vendored_frameworks_path
243
+ end
244
+ `cp -rp #{vendored_frameworks.join(' ')} #{vendored_frameworks_path}`
245
+ end
246
+
247
+ vendored_libraries = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
248
+ expand_paths(spec.consumer(@platform).vendored_libraries)
249
+ end.compact.uniq
250
+
251
+ if vendored_libraries.count > 0
252
+ vendored_libraries_path = "ios"
253
+ if !File.exist?(vendored_libraries_path)
254
+ FileUtils.mkdir_p vendored_libraries_path
255
+ end
256
+ `cp -rp #{vendored_libraries.join(' ')} #{vendored_libraries_path}`
257
+ end
258
+ end
259
+ end
260
+
261
+ def copy_resources
262
+ copy_vendored_libs
263
+ bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
264
+ if @dynamic
265
+ resources_path = "ios/#{@spec.name}.framework"
266
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
267
+ else
268
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
269
+ dependency_names = @static_installer.podfile.dependencies.map(&:name)
270
+ resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
271
+ if (dependency_names & [spec.name, @spec.name]).any?
272
+ expand_paths(spec.consumer(@platform).resources)
273
+ end
274
+ end.compact.uniq
275
+ if resources.count > 0
276
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
277
+ end
278
+ end
279
+ end
280
+
281
+ def create_framework
282
+ @fwk = Framework::Tree.new(@spec.name, @platform.name.to_s, @embedded)
283
+ @fwk.make
284
+ end
285
+
286
+ def dependency_count
287
+ count = @spec.dependencies.count
288
+
289
+ @spec.subspecs.each do |subspec|
290
+ count += subspec.dependencies.count
291
+ end
292
+
293
+ count
294
+ end
295
+
296
+ def expand_paths(path_specs)
297
+ path_specs.map do |path_spec|
298
+ Dir.glob(File.join(@source_dir, path_spec))
299
+ end
300
+ end
301
+
302
+ def static_libs_in_sandbox(build_dir = 'build')
303
+ if @exclude_deps
304
+ UI.puts 'Excluding dependencies'
305
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
306
+ else
307
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
308
+ end
309
+ end
310
+
311
+ def vendored_libraries
312
+ if @vendored_libraries
313
+ @vendored_libraries
314
+ end
315
+ file_accessors = if @exclude_deps
316
+ @file_accessors
317
+ else
318
+ @static_installer.pod_targets.flat_map(&:file_accessors)
319
+ end
320
+ libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || []
321
+ libs += file_accessors.flat_map(&:vendored_static_libraries)
322
+ @vendored_libraries = libs.compact.map(&:to_s)
323
+ @vendored_libraries
324
+ end
325
+
326
+ def static_linker_flags_in_sandbox
327
+ linker_flags = static_libs_in_sandbox.map do |lib|
328
+ lib.slice!('lib')
329
+ lib_flag = lib.chomp('.a').split('/').last
330
+ "-l#{lib_flag}"
331
+ end
332
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
333
+ end
334
+
335
+ def ios_build_options
336
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
337
+ end
338
+
339
+ def ios_architectures
340
+ archs = %w(x86_64 i386 arm64 armv7 armv7s)
341
+ vendored_libraries.each do |library|
342
+ archs = `lipo -info #{library}`.split & archs
343
+ end
344
+ archs
345
+ end
346
+
347
+ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
348
+ if defined?(Pod::DONT_CODESIGN)
349
+ args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
350
+ end
351
+ #
352
+ command = "xcodebuild #{defines} #{args}"
353
+ command += " CONFIGURATION_BUILD_DIR=#{build_dir} GENERATE_MASTER_OBJECT_FILE=NO"
354
+
355
+ if @dynamic
356
+ archive_path = "#{build_dir}/archive/#{config}"
357
+ if !File.exist?(archive_path)
358
+ FileUtils.mkdir_p(archive_path)
359
+ end
360
+ command += " -archivePath #{archive_path}/#{target}.xcarchive"
361
+
362
+ dsym_path = "#{build_dir}/dsym/#{config}"
363
+ if !File.exist?(dsym_path)
364
+ FileUtils.mkdir_p(dsym_path)
365
+ end
366
+ command += " DEBUG_INFORMATION_FORMAT=\"dwarf-with-dsym\""
367
+ command += " DWARF_DSYM_FOLDER_PATH=#{dsym_path}"
368
+ command += " DWARF_DSYM_FILE_NAME=#{target}.dSYM"
369
+
370
+ driver_path = "#{build_dir}/driver/#{config}"
371
+ if !File.exist?(driver_path)
372
+ FileUtils.mkdir_p(driver_path)
373
+ end
374
+ command += " -derivedDataPath=#{driver_path}"
375
+ end
376
+
377
+ command += " clean build -configuration #{config}"
378
+ command += " -target #{target}"
379
+ command += " -UseNewBuildSystem=NO"
380
+
381
+ if !@xcconfig.nil? && File.exist?(@xcconfig)
382
+ command += " -xcconfig #{@xcconfig}"
383
+ end
384
+
385
+ command += " -project #{project_root}/Pods.xcodeproj"
386
+
387
+
388
+ command += " 2>&1"
389
+ puts "===== build command ======"
390
+ puts command
391
+ puts "===== build command ======"
392
+ # command = "xcodebuild #{defines} #{args} GENERATE_MASTER_OBJECT_FILE=YES CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
393
+ # command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj > #{Dir.pwd}/build.log 2>&1"
394
+
395
+ output = `#{command}`.lines.to_a
396
+
397
+ if $?.exitstatus != 0
398
+ puts UI::BuildFailedReport.report(command, output)
399
+
400
+ # Note: We use `Process.exit` here because it fires a `SystemExit`
401
+ # exception, which gives the caller a chance to clean up before the
402
+ # process terminates.
403
+ #
404
+ # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
405
+ Process.exit
406
+ end
407
+ end
408
+ end
409
+ end