cocoapods-gd 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 (75) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +131 -0
  4. data/LICENSE +22 -0
  5. data/README.md +42 -0
  6. data/Rakefile +29 -0
  7. data/cocoapods-gd.gemspec +22 -0
  8. data/lib/cocoapods-gd.rb +5 -0
  9. data/lib/cocoapods-gd/builder.rb +393 -0
  10. data/lib/cocoapods-gd/framework.rb +66 -0
  11. data/lib/cocoapods-gd/install_frameworks.rb +77 -0
  12. data/lib/cocoapods-gd/mangle.rb +32 -0
  13. data/lib/cocoapods-gd/pod_utils.rb +246 -0
  14. data/lib/cocoapods-gd/podfile_env.rb +26 -0
  15. data/lib/cocoapods-gd/spec_builder.rb +72 -0
  16. data/lib/cocoapods-gd/symbols.rb +42 -0
  17. data/lib/cocoapods-gd/uploader.rb +70 -0
  18. data/lib/cocoapods-gd/user_interface/build_failed_report.rb +15 -0
  19. data/lib/cocoapods_plugin.rb +10 -0
  20. data/lib/pod/command/gd.rb +185 -0
  21. data/scripts/lstconst.sh +9 -0
  22. data/scripts/lstsym.sh +8 -0
  23. data/spec/command/error_spec.rb +81 -0
  24. data/spec/command/gd_spec.rb +420 -0
  25. data/spec/command/subspecs_spec.rb +30 -0
  26. data/spec/fixtures/Archs.podspec +13 -0
  27. data/spec/fixtures/Builder.podspec +25 -0
  28. data/spec/fixtures/CPDColors.podspec +19 -0
  29. data/spec/fixtures/FH.podspec +18 -0
  30. data/spec/fixtures/KFData.podspec +73 -0
  31. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  32. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
  33. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  34. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  35. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  36. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  37. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  39. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  40. data/spec/fixtures/LibraryDemo.podspec +14 -0
  41. data/spec/fixtures/LocalSources/LICENSE +0 -0
  42. data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
  43. data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
  44. data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
  45. data/spec/fixtures/NikeKit.podspec +19 -0
  46. data/spec/fixtures/OpenSans.podspec +18 -0
  47. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  48. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
  49. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  50. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  51. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  58. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  59. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  60. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  61. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  62. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  63. data/spec/fixtures/PackagerTest/Podfile +10 -0
  64. data/spec/fixtures/PackagerTest/Podfile.lock +36 -0
  65. data/spec/fixtures/Weakly.podspec +13 -0
  66. data/spec/fixtures/a.podspec +19 -0
  67. data/spec/fixtures/foo-bar.podspec +19 -0
  68. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  69. data/spec/integration/project_spec.rb +70 -0
  70. data/spec/spec_helper.rb +79 -0
  71. data/spec/unit/pod/utils_spec.rb +58 -0
  72. data/spec/unit/specification/builder_spec.rb +62 -0
  73. data/spec/unit/specification/spec_builder_spec.rb +61 -0
  74. data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
  75. metadata +217 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5f42f504fd6a2564ff180b2887201cda6efef5a093aebe5daaffcf036bd75db9
4
+ data.tar.gz: ac0a4628f51ba7e00a8c21b780eb68ed2e2ba21ebcecbe1389790f388a2187bf
5
+ SHA512:
6
+ metadata.gz: 494214649db2ef58d7086e605a4f7e8bdd31ee1059bc968a7ad29bc8ae3591c7c58180a8499745faabd00da558ddd7497436a5aca9ab7a82966b9ac782f28a2a
7
+ data.tar.gz: b706a58beb2324cf7c4912173e5d36960e2e377fd9f4c0e7413f919838c1dd8d8fdd072f462ade2f8e8f0060a96c9d6defb6796baa5e6f7fa949e322914876d1
data/Gemfile ADDED
@@ -0,0 +1,13 @@
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
+ gem 'rubyzip'
13
+ end
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-gd (0.0.1)
5
+ cocoapods (>= 1.7.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.2.0)
17
+ atomos (0.1.3)
18
+ bacon (1.2.0)
19
+ claide (1.0.2)
20
+ cocoapods (1.7.3)
21
+ activesupport (>= 4.0.2, < 5)
22
+ claide (>= 1.0.2, < 2.0)
23
+ cocoapods-core (= 1.7.3)
24
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
25
+ cocoapods-downloader (>= 1.2.2, < 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.1, < 2.0)
30
+ cocoapods-try (>= 1.1.0, < 2.0)
31
+ colored2 (~> 3.1)
32
+ escape (~> 0.0.4)
33
+ fourflusher (>= 2.3.0, < 3.0)
34
+ gh_inspector (~> 1.0)
35
+ molinillo (~> 0.6.6)
36
+ nap (~> 1.0)
37
+ ruby-macho (~> 1.4)
38
+ xcodeproj (>= 1.10.0, < 2.0)
39
+ cocoapods-core (1.7.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.21)
56
+ json (>= 1.8, < 3)
57
+ simplecov (~> 0.14.1)
58
+ term-ansicolor (~> 1.3)
59
+ thor (~> 0.19.4)
60
+ tins (~> 1.6)
61
+ docile (1.1.5)
62
+ escape (0.0.4)
63
+ fourflusher (2.3.1)
64
+ fuzzy_match (2.0.4)
65
+ gh_inspector (1.1.3)
66
+ i18n (0.9.5)
67
+ concurrent-ruby (~> 1.0)
68
+ json (2.1.0)
69
+ metaclass (0.0.4)
70
+ minitest (5.11.3)
71
+ mocha (1.2.1)
72
+ metaclass (~> 0.0.1)
73
+ mocha-on-bacon (0.2.3)
74
+ mocha (>= 0.13.0)
75
+ molinillo (0.6.6)
76
+ nanaimo (0.2.6)
77
+ nap (1.1.0)
78
+ netrc (0.11.0)
79
+ parser (2.3.0.6)
80
+ ast (~> 2.2)
81
+ powerpack (0.1.1)
82
+ prettybacon (0.0.2)
83
+ bacon (~> 1.2)
84
+ rainbow (2.1.0)
85
+ rake (10.5.0)
86
+ rubocop (0.37.2)
87
+ parser (>= 2.3.0.4, < 3.0)
88
+ powerpack (~> 0.1)
89
+ rainbow (>= 1.99.1, < 3.0)
90
+ ruby-progressbar (~> 1.7)
91
+ unicode-display_width (~> 0.3)
92
+ ruby-macho (1.4.0)
93
+ ruby-progressbar (1.7.5)
94
+ rubyzip (2.3.0)
95
+ simplecov (0.14.1)
96
+ docile (~> 1.1.0)
97
+ json (>= 1.8, < 3)
98
+ simplecov-html (~> 0.10.0)
99
+ simplecov-html (0.10.2)
100
+ term-ansicolor (1.6.0)
101
+ tins (~> 1.0)
102
+ thor (0.19.4)
103
+ thread_safe (0.3.6)
104
+ tins (1.16.3)
105
+ tzinfo (1.2.5)
106
+ thread_safe (~> 0.1)
107
+ unicode-display_width (0.3.1)
108
+ xcodeproj (1.10.0)
109
+ CFPropertyList (>= 2.3.3, < 4.0)
110
+ atomos (~> 0.1.3)
111
+ claide (>= 1.0.2, < 2.0)
112
+ colored2 (~> 3.1)
113
+ nanaimo (~> 0.2.6)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ bacon
120
+ bundler
121
+ cocoapods-gd!
122
+ coveralls
123
+ mocha
124
+ mocha-on-bacon
125
+ prettybacon
126
+ rake
127
+ rubocop
128
+ rubyzip
129
+
130
+ BUNDLED WITH
131
+ 2.1.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 Gd
2
+
3
+ [![Build Status](http://img.shields.io/travis/CocoaPods/cocoapods-gd/master.svg?style=flat)](https://travis-ci.org/CocoaPods/cocoapods-gd)
4
+ [![Coverage Status](https://img.shields.io/coveralls/CocoaPods/cocoapods-gd.svg)](https://coveralls.io/r/CocoaPods/cocoapods-gd?branch=master)
5
+ [![Gem Version](http://img.shields.io/gem/v/cocoapods-gd.svg?style=flat)](http://badge.fury.io/rb/cocoapods-gd)
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/CocoaPods/cocoapods-gd.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-gd)
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 Gd 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-gd
24
+ ```
25
+
26
+ or add a line to your Gemfile:
27
+
28
+ ```ruby
29
+ gem "cocoapods-gd"
30
+ ```
31
+
32
+ then run `bundle install`.
33
+
34
+ This installs Gd as a CocoaPods plugin.
35
+
36
+ ## Usage
37
+
38
+ ```bash
39
+ $ pod gd 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-gd.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-gd'
8
+ spec.version = Pod::Gd::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/CocoaPods/cocoapods-gd'
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.7.3', '< 2.0'
19
+
20
+ spec.add_development_dependency "bundler"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,5 @@
1
+ module Pod
2
+ module Gd
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,393 @@
1
+ module Pod
2
+ class GDBuilder
3
+ def initialize(platform, static_installer, source_dir, static_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
4
+ @platform = platform
5
+ @static_installer = static_installer
6
+ @source_dir = source_dir
7
+ @static_sandbox_root = static_sandbox_root
8
+ @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
+ @bundle_identifier = bundle_identifier
16
+ @exclude_deps = exclude_deps
17
+ @file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
18
+ end
19
+
20
+ def build(gd_type)
21
+ case gd_type
22
+ when :static_library
23
+ build_static_library
24
+ when :static_framework
25
+ build_static_framework
26
+ when :dynamic_framework
27
+ build_dynamic_framework
28
+ end
29
+ end
30
+
31
+ def build_static_library
32
+ UI.puts("Building static library #{@spec} with configuration #{@config}")
33
+
34
+ defines = compile
35
+ build_sim_libraries(defines)
36
+
37
+ platform_path = Pathname.new(@platform.name.to_s)
38
+ platform_path.mkdir unless platform_path.exist?
39
+
40
+ output = platform_path + "lib#{@spec.name}.a"
41
+
42
+ if @platform.name == :ios
43
+ build_static_library_for_ios(output)
44
+ else
45
+ build_static_library_for_mac(output)
46
+ end
47
+ end
48
+
49
+ def build_static_framework
50
+ UI.puts("Building static framework #{@spec} with configuration #{@config} with path #{Dir.pwd}")
51
+
52
+ defines = compile
53
+ build_sim_libraries(defines)
54
+ create_framework
55
+ output = @fwk.versions_path + Pathname.new(@spec.name)
56
+
57
+ if @platform.name == :ios
58
+ build_static_library_for_ios(output)
59
+ else
60
+ build_static_library_for_mac(output)
61
+ end
62
+
63
+ copy_headers
64
+ copy_license
65
+ copy_resources
66
+ end
67
+
68
+ def link_embedded_resources
69
+ target_path = @fwk.root_path + Pathname.new('Resources')
70
+ target_path.mkdir unless target_path.exist?
71
+
72
+ Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
73
+ resource = Pathname.new(resource).relative_path_from(target_path)
74
+ `ln -sf #{resource} #{target_path}`
75
+ end
76
+ end
77
+
78
+ def build_dynamic_framework
79
+ # UI.puts("Building dynamic framework #{@spec} with configuration #{@config}")
80
+
81
+ # defines = compile
82
+ # build_sim_libraries(defines)
83
+
84
+ # if @bundle_identifier
85
+ # defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
86
+ # end
87
+
88
+ # output = "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}"
89
+
90
+ # # clean_directory_for_dynamic_build
91
+ # if @platform.name == :ios
92
+ # build_dynamic_framework_for_ios(defines, output)
93
+ # else
94
+ # build_dynamic_framework_for_mac(defines, output)
95
+ # end
96
+
97
+ # copy_resources
98
+ end
99
+
100
+ def build_dynamic_framework_for_ios(defines, output)
101
+ # Specify frameworks to link and search paths
102
+ linker_flags = static_linker_flags_in_sandbox
103
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
104
+
105
+ # Build Target Dynamic Framework for both device and Simulator
106
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\" FRAMEWORK_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
107
+ device_options = ios_build_options << ' -sdk iphoneos'
108
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, "#{@dynamic_sandbox_root}")
109
+
110
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
111
+
112
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, "#{@dynamic_sandbox_root}")
113
+
114
+ # Combine architectures
115
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
116
+
117
+ FileUtils.mkdir(@platform.name.to_s)
118
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
119
+ # `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
120
+ end
121
+
122
+ def build_dynamic_framework_for_mac(defines, _output)
123
+ # Specify frameworks to link and search paths
124
+ linker_flags = static_linker_flags_in_sandbox
125
+ defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
126
+
127
+ # Build Target Dynamic Framework for osx
128
+ defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
129
+ xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
130
+
131
+ FileUtils.mkdir(@platform.name.to_s)
132
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
133
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
134
+ end
135
+
136
+ def build_sim_libraries(defines)
137
+ if @platform.name == :ios
138
+ xcodebuild(defines, "-sdk iphonesimulator OTHER_CFLAGS='-fembed-bitcode -Qunused-arguments'", 'build-sim')
139
+ end
140
+ end
141
+
142
+ def build_static_library_for_ios(output)
143
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
144
+ static_libs = static_libs.find_all{|n| n.include? "#{@spec.name}"}
145
+
146
+ libs = ios_architectures.map do |arch|
147
+ library = "#{@static_sandbox_root}/build/gd-#{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_PodGd_#{@spec.name}'"
181
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
182
+
183
+ if @platform.name == :ios
184
+ options = ios_build_options
185
+ end
186
+ xcodebuild(defines, options)
187
+
188
+ if @mangle
189
+ return build_with_mangling(options)
190
+ end
191
+
192
+ defines
193
+ end
194
+
195
+ def copy_headers
196
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
197
+ Dir.glob("#{headers_source_root}/**/*.h").
198
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
199
+
200
+ swift_path="#{Dir.pwd}/Pods/build/Swift Compatibility Header/#{@spec.name}-Swift.h"
201
+ if File.exist?("#{swift_path}")
202
+ FileUtils.cp("#{swift_path}", "#{Dir.pwd}/ios/#{@spec.name}.framework/Headers/#{@spec.name}-Swift.h")
203
+
204
+ modules_path = "#{Dir.pwd}/ios/#{@spec.name}.framework/Modules"
205
+ FileUtils.mkdir_p(modules_path) unless File.exists?(modules_path)
206
+ FileUtils.cp_r("#{Dir.pwd}/Pods/build/#{@spec.name}.swiftmodule/.", "#{modules_path}/#{@spec.name}.swiftmodule")
207
+ FileUtils.cp_r("#{Dir.pwd}/Pods/build-sim/#{@spec.name}.swiftmodule/.", "#{modules_path}/#{@spec.name}.swiftmodule")
208
+ modulemap = <<MAP
209
+ framework module #{@spec.name} {
210
+ umbrella header "#{@spec.name}-umbrella.h"
211
+
212
+ export *
213
+ module * { export * }
214
+ }
215
+ module #{@spec.name}.Swift {
216
+ header "#{@spec.name}-Swift.h"
217
+ requires objc
218
+ }
219
+ MAP
220
+
221
+ File.write("#{modules_path}/module.modulemap", modulemap)
222
+ else
223
+ # If custom 'module_map' is specified add it to the framework distribution
224
+ # otherwise check if a header exists that is equal to 'spec.name', if so
225
+ # create a default 'module_map' one using it.
226
+ if !@spec.module_map.nil?
227
+ module_map_file = @file_accessors.flat_map(&:module_map).first
228
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
229
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
230
+ module_map = <<MAP
231
+ framework module #{@spec.name} {
232
+ umbrella header "#{@spec.name}.h"
233
+
234
+ export *
235
+ module * { export * }
236
+ }
237
+ MAP
238
+ end
239
+
240
+ unless module_map.nil?
241
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
242
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
243
+ end
244
+ end
245
+ end
246
+
247
+ def copy_license
248
+ license_file = @spec.license[:file] || 'LICENSE'
249
+ license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
250
+ FileUtils.cp(license_file, '.') if license_file.exist?
251
+ end
252
+
253
+ def copy_resources
254
+ bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
255
+ if @dynamic
256
+ resources_path = "ios/#{@spec.name}.framework"
257
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
258
+ else
259
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
260
+ resources = expand_paths(@spec.consumer(@platform).resources)
261
+ if resources.count == 0 && bundles.count == 0
262
+ @fwk.delete_resources
263
+ return
264
+ end
265
+ if resources.count > 0
266
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
267
+ end
268
+
269
+ bundle_path="#{Dir.pwd}/ios/#{@spec.name}.framework/Resources/#{@spec.name}.bundle"
270
+ if File.exist?(bundle_path)
271
+ FileUtils.mv(bundle_path, "#{Dir.pwd}/ios/#{@spec.name}.bundle")
272
+ end
273
+ end
274
+ end
275
+
276
+ def create_framework
277
+ @fwk = Framework::Tree.new(@spec.name, @platform.name.to_s, @embedded)
278
+ @fwk.make
279
+ end
280
+
281
+ def dependency_count
282
+ count = @spec.dependencies.count
283
+
284
+ @spec.subspecs.each do |subspec|
285
+ count += subspec.dependencies.count
286
+ end
287
+
288
+ count
289
+ end
290
+
291
+ def expand_paths(path_specs)
292
+ path_specs.map do |path_spec|
293
+ Dir.glob(File.join(@source_dir, path_spec))
294
+ end
295
+ end
296
+
297
+ def static_libs_in_sandbox(build_dir = 'build')
298
+ if @exclude_deps
299
+ UI.puts 'Excluding dependencies'
300
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
301
+ else
302
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
303
+ end
304
+ end
305
+
306
+ def vendored_libraries
307
+ if @vendored_libraries
308
+ @vendored_libraries
309
+ end
310
+ file_accessors = if @exclude_deps
311
+ @file_accessors
312
+ else
313
+ @static_installer.pod_targets.flat_map(&:file_accessors)
314
+ end
315
+ libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || []
316
+ libs += file_accessors.flat_map(&:vendored_static_libraries)
317
+ @vendored_libraries = libs.compact.map(&:to_s)
318
+ @vendored_libraries
319
+ end
320
+
321
+ def static_linker_flags_in_sandbox
322
+ linker_flags = static_libs_in_sandbox.map do |lib|
323
+ lib.slice!('lib')
324
+ lib_flag = lib.chomp('.a').split('/').last
325
+ "-l#{lib_flag}"
326
+ end
327
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-gd' }
328
+ end
329
+
330
+ def ios_build_options
331
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
332
+ end
333
+
334
+ def copy_modulemap
335
+ path="#{Dir.pwd}/Pods/Headers/Public/"
336
+ FileUtils.mkdir_p(path) unless File.exists?(path)
337
+ list=Dir.entries("#{path}")
338
+
339
+ list.each_index do |x|
340
+ if list[x].include?(".")
341
+ else
342
+ modulemap_soure_dir = "#{path}#{list[x]}/#{list[x]}"
343
+
344
+ directory_name = "#{Dir.pwd}/build/Release-iphoneos/#{list[x]}"
345
+ FileUtils.mkdir_p(directory_name) unless File.exists?(directory_name)
346
+ modulemap_target_dir = "#{directory_name}/#{list[x]}"
347
+
348
+ directory_iphonesimulator = "#{Dir.pwd}/build/Release-iphonesimulator/#{list[x]}"
349
+ FileUtils.mkdir_p(directory_iphonesimulator) unless File.exists?(directory_iphonesimulator)
350
+ modulemap_target_iphonesimulator = "#{directory_iphonesimulator}/#{list[x]}"
351
+
352
+ if File.exist?("#{modulemap_soure_dir}.modulemap")
353
+ FileUtils.cp("#{modulemap_soure_dir}.modulemap", "#{modulemap_target_dir}.modulemap")
354
+ FileUtils.cp("#{modulemap_soure_dir}.modulemap", "#{modulemap_target_iphonesimulator}.modulemap")
355
+ end
356
+
357
+ if File.exist?("#{modulemap_soure_dir}-umbrella.h")
358
+ FileUtils.cp("#{modulemap_soure_dir}-umbrella.h", "#{modulemap_target_dir}-umbrella.h")
359
+ FileUtils.cp("#{modulemap_soure_dir}-umbrella.h", "#{modulemap_target_iphonesimulator}-umbrella.h")
360
+ end
361
+ end
362
+ end
363
+ end
364
+
365
+ def ios_architectures
366
+ archs = %w(x86_64 i386 arm64 armv7 armv7s)
367
+ vendored_libraries.each do |library|
368
+ archs = `lipo -info #{library}`.split & archs
369
+ end
370
+ archs
371
+ end
372
+
373
+ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-gd', project_root = @static_sandbox_root, config = @config)
374
+ if defined?(Pod::DONT_CODESIGN)
375
+ args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
376
+ end
377
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -UseModernBuildSystem=NO -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
378
+ copy_modulemap
379
+ output = `#{command}`.lines.to_a
380
+
381
+ if $?.exitstatus != 0
382
+ puts UI::BuildFailedReport.report(command, output)
383
+
384
+ # Note: We use `Process.exit` here because it fires a `SystemExit`
385
+ # exception, which gives the caller a chance to clean up before the
386
+ # process terminates.
387
+ #
388
+ # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
389
+ Process.exit
390
+ end
391
+ end
392
+ end
393
+ end