cocoapods-nepackage 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +4 -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 +145 -0
  9. data/LICENSE +22 -0
  10. data/README.md +42 -0
  11. data/Rakefile +29 -0
  12. data/cocoapods-nepackager.gemspec +23 -0
  13. data/lib/cocoapods-nepackager/builder.rb +304 -0
  14. data/lib/cocoapods-nepackager/framework.rb +66 -0
  15. data/lib/cocoapods-nepackager/mangle.rb +32 -0
  16. data/lib/cocoapods-nepackager/pod_utils.rb +245 -0
  17. data/lib/cocoapods-nepackager/spec_builder.rb +63 -0
  18. data/lib/cocoapods-nepackager/symbols.rb +42 -0
  19. data/lib/cocoapods-nepackager/user_interface/build_failed_report.rb +15 -0
  20. data/lib/cocoapods_nepackager.rb +5 -0
  21. data/lib/cocoapods_plugin.rb +8 -0
  22. data/lib/pod/command/nepackage.rb +180 -0
  23. data/scripts/lstconst.sh +9 -0
  24. data/scripts/lstsym.sh +8 -0
  25. data/spec/command/error_spec.rb +81 -0
  26. data/spec/command/package_spec.rb +420 -0
  27. data/spec/command/subspecs_spec.rb +30 -0
  28. data/spec/fixtures/Archs.podspec +13 -0
  29. data/spec/fixtures/Builder.podspec +25 -0
  30. data/spec/fixtures/CPDColors.podspec +19 -0
  31. data/spec/fixtures/FH.podspec +18 -0
  32. data/spec/fixtures/KFData.podspec +73 -0
  33. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  34. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
  35. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  36. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  37. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  39. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  40. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  41. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  42. data/spec/fixtures/LibraryDemo.podspec +14 -0
  43. data/spec/fixtures/LocalSources/LICENSE +0 -0
  44. data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
  45. data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
  46. data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
  47. data/spec/fixtures/NikeKit.podspec +19 -0
  48. data/spec/fixtures/OpenSans.podspec +18 -0
  49. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  50. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
  51. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  58. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  59. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  60. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  61. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  62. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  63. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  64. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  65. data/spec/fixtures/PackagerTest/Podfile +10 -0
  66. data/spec/fixtures/Weakly.podspec +13 -0
  67. data/spec/fixtures/a.podspec +19 -0
  68. data/spec/fixtures/foo-bar.podspec +19 -0
  69. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  70. data/spec/integration/project_spec.rb +70 -0
  71. data/spec/spec_helper.rb +79 -0
  72. data/spec/unit/pod/utils_spec.rb +58 -0
  73. data/spec/unit/specification/builder_spec.rb +62 -0
  74. data/spec/unit/specification/spec_builder_spec.rb +61 -0
  75. data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
  76. metadata +217 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4fec710486acf38c854ff935e3736398d43ab0629ab151f4dadae062d5f180ee
4
+ data.tar.gz: a9b079973373a8319622300f9c51170c6b5b997631e7d6cb388d635c38fe8fd6
5
+ SHA512:
6
+ metadata.gz: ee1ceea6f598b105ad0f4ca87e73a08b91df30dd7252c0726b64a16a416a916f695b8335644aff372eec48a0322b8fd3de136cc56f694ea6e055810c73de1b8a
7
+ data.tar.gz: 31b7f8d2574aab71e9fefd94630401cb56e378c75be0aa60ab0a82afeb43c64a86efdc91fb01751d76ceae3e40515da9ada123e5e9f6abb195acd61979601453
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,4 @@
1
+ coverage
2
+ pkg
3
+ .DS_Store
4
+ .bundle/
@@ -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,145 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-nepackager (1.5.0)
5
+ cocoapods (>= 1.7.3, < 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ CFPropertyList (3.0.3)
11
+ activesupport (5.2.4.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.7.0)
17
+ public_suffix (>= 2.0.2, < 5.0)
18
+ algoliasearch (1.27.5)
19
+ httpclient (~> 2.8, >= 2.8.3)
20
+ json (>= 1.5.1)
21
+ ast (2.2.0)
22
+ atomos (0.1.3)
23
+ bacon (1.2.0)
24
+ claide (1.0.3)
25
+ cocoapods (1.10.0)
26
+ addressable (~> 2.6)
27
+ claide (>= 1.0.2, < 2.0)
28
+ cocoapods-core (= 1.10.0)
29
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
30
+ cocoapods-downloader (>= 1.4.0, < 2.0)
31
+ cocoapods-plugins (>= 1.0.0, < 2.0)
32
+ cocoapods-search (>= 1.0.0, < 2.0)
33
+ cocoapods-trunk (>= 1.4.0, < 2.0)
34
+ cocoapods-try (>= 1.1.0, < 2.0)
35
+ colored2 (~> 3.1)
36
+ escape (~> 0.0.4)
37
+ fourflusher (>= 2.3.0, < 3.0)
38
+ gh_inspector (~> 1.0)
39
+ molinillo (~> 0.6.6)
40
+ nap (~> 1.0)
41
+ ruby-macho (~> 1.4)
42
+ xcodeproj (>= 1.19.0, < 2.0)
43
+ cocoapods-core (1.10.0)
44
+ activesupport (> 5.0, < 6)
45
+ addressable (~> 2.6)
46
+ algoliasearch (~> 1.0)
47
+ concurrent-ruby (~> 1.1)
48
+ fuzzy_match (~> 2.0.4)
49
+ nap (~> 1.0)
50
+ netrc (~> 0.11)
51
+ public_suffix
52
+ typhoeus (~> 1.0)
53
+ cocoapods-deintegrate (1.0.4)
54
+ cocoapods-downloader (1.4.0)
55
+ cocoapods-plugins (1.0.0)
56
+ nap
57
+ cocoapods-search (1.0.0)
58
+ cocoapods-trunk (1.5.0)
59
+ nap (>= 0.8, < 2.0)
60
+ netrc (~> 0.11)
61
+ cocoapods-try (1.2.0)
62
+ colored2 (3.1.2)
63
+ concurrent-ruby (1.1.7)
64
+ coveralls (0.8.21)
65
+ json (>= 1.8, < 3)
66
+ simplecov (~> 0.14.1)
67
+ term-ansicolor (~> 1.3)
68
+ thor (~> 0.19.4)
69
+ tins (~> 1.6)
70
+ docile (1.1.5)
71
+ escape (0.0.4)
72
+ ethon (0.12.0)
73
+ ffi (>= 1.3.0)
74
+ ffi (1.13.1)
75
+ fourflusher (2.3.1)
76
+ fuzzy_match (2.0.4)
77
+ gh_inspector (1.1.3)
78
+ httpclient (2.8.3)
79
+ i18n (1.8.5)
80
+ concurrent-ruby (~> 1.0)
81
+ json (2.1.0)
82
+ metaclass (0.0.4)
83
+ minitest (5.14.2)
84
+ mocha (1.2.1)
85
+ metaclass (~> 0.0.1)
86
+ mocha-on-bacon (0.2.3)
87
+ mocha (>= 0.13.0)
88
+ molinillo (0.6.6)
89
+ nanaimo (0.3.0)
90
+ nap (1.1.0)
91
+ netrc (0.11.0)
92
+ parser (2.3.0.6)
93
+ ast (~> 2.2)
94
+ powerpack (0.1.1)
95
+ prettybacon (0.0.2)
96
+ bacon (~> 1.2)
97
+ public_suffix (4.0.6)
98
+ rainbow (2.1.0)
99
+ rake (10.5.0)
100
+ rubocop (0.37.2)
101
+ parser (>= 2.3.0.4, < 3.0)
102
+ powerpack (~> 0.1)
103
+ rainbow (>= 1.99.1, < 3.0)
104
+ ruby-progressbar (~> 1.7)
105
+ unicode-display_width (~> 0.3)
106
+ ruby-macho (1.4.0)
107
+ ruby-progressbar (1.7.5)
108
+ simplecov (0.14.1)
109
+ docile (~> 1.1.0)
110
+ json (>= 1.8, < 3)
111
+ simplecov-html (~> 0.10.0)
112
+ simplecov-html (0.10.2)
113
+ term-ansicolor (1.6.0)
114
+ tins (~> 1.0)
115
+ thor (0.19.4)
116
+ thread_safe (0.3.6)
117
+ tins (1.16.3)
118
+ typhoeus (1.4.0)
119
+ ethon (>= 0.9.0)
120
+ tzinfo (1.2.8)
121
+ thread_safe (~> 0.1)
122
+ unicode-display_width (0.3.1)
123
+ xcodeproj (1.19.0)
124
+ CFPropertyList (>= 2.3.3, < 4.0)
125
+ atomos (~> 0.1.3)
126
+ claide (>= 1.0.2, < 2.0)
127
+ colored2 (~> 3.1)
128
+ nanaimo (~> 0.3.0)
129
+
130
+ PLATFORMS
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ bacon
135
+ bundler (~> 1.3)
136
+ coveralls
137
+ mocha
138
+ mocha-on-bacon
139
+ cocoapods-nepackager!
140
+ prettybacon
141
+ rake
142
+ rubocop
143
+
144
+ BUNDLED WITH
145
+ 1.16.2
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,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_nepackager.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-nepackage'
8
+ spec.version = Pod::NEPackager::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. XDF customization'
11
+ spec.homepage = 'https://github.com/CocoaPods/cocoapods-packager'
12
+ spec.license = 'MIT'
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "cocoapods", '>= 1.7.3', '< 2.0'
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,304 @@
1
+ module Pod
2
+ class NEBuilder
3
+ def initialize(source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps, includ_dependencies)
4
+ @source_dir = source_dir
5
+ @static_sandbox_root = static_sandbox_root
6
+ @dynamic_sandbox_root = dynamic_sandbox_root
7
+ @public_headers_root = public_headers_root
8
+ @spec = spec
9
+ @embedded = embedded
10
+ @mangle = mangle
11
+ @dynamic = dynamic
12
+ @config = config
13
+ @bundle_identifier = bundle_identifier
14
+ @exclude_deps = exclude_deps
15
+ @includ_dependencies = includ_dependencies
16
+ end
17
+
18
+ def build(platform, library)
19
+ if library
20
+ build_static_library(platform)
21
+ else
22
+ build_framework(platform)
23
+ end
24
+ end
25
+
26
+ def build_static_library(platform)
27
+ UI.puts("Building static library #{@spec} with configuration #{@config}")
28
+
29
+ defines = compile(platform)
30
+ build_sim_libraries(platform, defines)
31
+
32
+ platform_path = Pathname.new(platform.name.to_s)
33
+ platform_path.mkdir unless platform_path.exist?
34
+ build_library(platform, defines, platform_path + Pathname.new("lib#{@spec.name}.a"))
35
+ end
36
+
37
+ def build_framework(platform)
38
+ UI.puts("Building framework #{@spec} with configuration #{@config}")
39
+
40
+ defines = compile(platform)
41
+ build_sim_libraries(platform, defines)
42
+
43
+ if @dynamic
44
+ build_dynamic_framework(platform, defines, "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}")
45
+ else
46
+ create_framework(platform.name.to_s)
47
+ build_library(platform, defines, @fwk.versions_path + Pathname.new(@spec.name))
48
+ copy_headers
49
+ copy_license
50
+ end
51
+
52
+ copy_resources(platform)
53
+ end
54
+
55
+ def link_embedded_resources
56
+ target_path = @fwk.root_path + Pathname.new('Resources')
57
+ target_path.mkdir unless target_path.exist?
58
+
59
+ Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
60
+ resource = Pathname.new(resource).relative_path_from(target_path)
61
+ `ln -sf #{resource} #{target_path}`
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ def build_dynamic_framework(platform, defines, output)
68
+ UI.puts("Building dynamic Framework #{@spec} with configuration #{@config}")
69
+
70
+ if @bundle_identifier
71
+ defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
72
+ end
73
+
74
+ clean_directory_for_dynamic_build
75
+ if platform.name == :ios
76
+ build_dynamic_framework_for_ios(platform, defines, output)
77
+ else
78
+ build_dynamic_framework_for_mac(platform, defines, output)
79
+ end
80
+ end
81
+
82
+ def build_library(platform, defines, output)
83
+ static_libs = static_libs_in_sandbox
84
+
85
+ if platform.name == :ios
86
+ build_static_lib_for_ios(static_libs, defines, output)
87
+ else
88
+ build_static_lib_for_mac(static_libs, output)
89
+ end
90
+ end
91
+
92
+ def build_dynamic_framework_for_ios(platform, defines, output)
93
+ # Specify frameworks to link and search paths
94
+ linker_flags = static_linker_flags_in_sandbox
95
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
96
+
97
+ # Build Target Dynamic Framework for both device and Simulator
98
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
99
+ device_options = ios_build_options << ' -sdk iphoneos'
100
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
101
+
102
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
103
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
104
+
105
+ # Combine architectures
106
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
107
+
108
+ FileUtils.mkdir(platform.name.to_s)
109
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{platform.name}`
110
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{platform.name}`
111
+ end
112
+
113
+ def build_dynamic_framework_for_mac(platform, defines, _output)
114
+ # Specify frameworks to link and search paths
115
+ linker_flags = static_linker_flags_in_sandbox
116
+ defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
117
+
118
+ # Build Target Dynamic Framework for osx
119
+ defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
120
+ xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
121
+
122
+ FileUtils.mkdir(platform.name.to_s)
123
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{platform.name}`
124
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{platform.name}`
125
+ end
126
+
127
+ def build_sim_libraries(platform, defines)
128
+ if platform.name == :ios
129
+ xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
130
+ end
131
+ end
132
+
133
+ def build_static_lib_for_ios(static_libs, _defines, output)
134
+ return if static_libs.count == 0
135
+ `libtool -static -o #{@static_sandbox_root}/build/package.a #{static_libs.join(' ')}`
136
+
137
+ sim_libs = static_libs_in_sandbox('build-sim')
138
+ `libtool -static -o #{@static_sandbox_root}/build-sim/package.a #{sim_libs.join(' ')}`
139
+
140
+ `lipo #{@static_sandbox_root}/build/package.a #{@static_sandbox_root}/build-sim/package.a -create -output #{output}`
141
+ end
142
+
143
+ def build_static_lib_for_mac(static_libs, output)
144
+ return if static_libs.count == 0
145
+ `libtool -static -o #{output} #{static_libs.join(' ')}`
146
+ end
147
+
148
+ def build_with_mangling(platform, options)
149
+ UI.puts 'Mangling symbols'
150
+ defines = Symbols.mangle_for_pod_dependencies(@spec.name, @static_sandbox_root)
151
+ defines << ' ' << @spec.consumer(platform).compiler_flags.join(' ')
152
+
153
+ UI.puts 'Building mangled framework'
154
+ xcodebuild(defines, options)
155
+ defines
156
+ end
157
+
158
+ def clean_directory_for_dynamic_build
159
+ # Remove static headers to avoid duplicate declaration conflicts
160
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Public/#{@spec.name}")
161
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Private/#{@spec.name}")
162
+
163
+ # Equivalent to removing derrived data
164
+ FileUtils.rm_rf('Pods/build')
165
+ end
166
+
167
+ def compile(platform)
168
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
169
+ defines << ' ' << @spec.consumer(platform).compiler_flags.join(' ')
170
+
171
+ if platform.name == :ios
172
+ options = ios_build_options
173
+ end
174
+
175
+ xcodebuild(defines, options)
176
+
177
+ if @mangle
178
+ return build_with_mangling(platform, options)
179
+ end
180
+
181
+ defines
182
+ end
183
+
184
+ def copy_headers
185
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
186
+
187
+ Dir.glob("#{headers_source_root}/**/*.h").
188
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
189
+
190
+ # If custom 'module_map' is specified add it to the framework distribution
191
+ # otherwise check if a header exists that is equal to 'spec.name', if so
192
+ # create a default 'module_map' one using it.
193
+ if !@spec.module_map.nil?
194
+ module_map_file = "#{@static_sandbox_root}/#{@spec.name}/#{@spec.module_map}"
195
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
196
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
197
+ module_map = <<MAP
198
+ framework module #{@spec.name} {
199
+ umbrella header "#{@spec.name}.h"
200
+
201
+ export *
202
+ module * { export * }
203
+ }
204
+ MAP
205
+ end
206
+
207
+ unless module_map.nil?
208
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
209
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
210
+ end
211
+ end
212
+
213
+ def copy_license
214
+ license_file = @spec.license[:file] || 'LICENSE'
215
+ `cp "#{license_file}" .` if Pathname(license_file).exist?
216
+ end
217
+
218
+ def copy_resources(platform)
219
+ bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
220
+ if @dynamic
221
+ resources_path = "ios/#{@spec.name}.framework"
222
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
223
+ else
224
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
225
+ resources = expand_paths(@spec.consumer(platform).resources)
226
+ if resources.count == 0 && bundles.count == 0
227
+ @fwk.delete_resources
228
+ return
229
+ end
230
+ if resources.count > 0
231
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
232
+ end
233
+ end
234
+ end
235
+
236
+ def create_framework(platform)
237
+ @fwk = Framework::Tree.new(@spec.name, platform, @embedded)
238
+ @fwk.make
239
+ end
240
+
241
+ def dependency_count
242
+ count = @spec.dependencies.count
243
+
244
+ @spec.subspecs.each do |subspec|
245
+ count += subspec.dependencies.count
246
+ end
247
+
248
+ count
249
+ end
250
+
251
+ def expand_paths(path_specs)
252
+ path_specs.map do |path_spec|
253
+ Dir.glob(File.join(@source_dir, path_spec))
254
+ end
255
+ end
256
+
257
+ def static_libs_in_sandbox(build_dir = 'build')
258
+ if @exclude_deps
259
+ UI.puts 'Excluding dependencies'
260
+ lib_paths = Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
261
+ @includ_dependencies.map do |lib|
262
+ lib_paths.push("#{@static_sandbox_root}/#{build_dir}/lib#{lib}.a")
263
+ end
264
+ puts lib_paths
265
+ return lib_paths
266
+ else
267
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
268
+ end
269
+ end
270
+
271
+ def static_linker_flags_in_sandbox
272
+ linker_flags = static_libs_in_sandbox.map do |lib|
273
+ lib.slice!('lib')
274
+ lib_flag = lib.chomp('.a').split('/').last
275
+ "-l#{lib_flag}"
276
+ end
277
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
278
+ end
279
+
280
+ def ios_build_options
281
+ "ARCHS=\'x86_64 i386 arm64 armv7 armv7s\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
282
+ end
283
+
284
+ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
285
+ if defined?(Pod::DONT_CODESIGN)
286
+ args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
287
+ end
288
+
289
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
290
+ output = `#{command}`.lines.to_a
291
+
292
+ if $?.exitstatus != 0
293
+ puts UI::BuildFailedReport.report(command, output)
294
+
295
+ # Note: We use `Process.exit` here because it fires a `SystemExit`
296
+ # exception, which gives the caller a chance to clean up before the
297
+ # process terminates.
298
+ #
299
+ # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
300
+ Process.exit
301
+ end
302
+ end
303
+ end
304
+ end