├── .gitignore ├── .rubocop.yml ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── cocoapods-pack.gemspec ├── endToEndPackMySample.sh ├── lib ├── cocoapods-pack │ ├── command.rb │ ├── command │ │ └── pack.rb │ ├── env_parser.rb │ ├── find_follow.rb │ ├── gem_version.rb │ ├── spec_generator.rb │ ├── xcode_builder.rb │ └── zip_file_generator.rb ├── cocoapods_pack.rb └── cocoapods_plugin.rb ├── local_pod.rb ├── packMySample.sh ├── samples ├── CLIConsumer │ ├── CLIConsumer.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── CLIConsumer.xcscheme │ ├── CLIConsumer.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── CLIConsumer │ │ ├── dummy.swift │ │ └── main.m │ ├── Podfile │ └── build.sh └── MySample │ ├── MIT │ ├── MySample.podspec │ ├── MySample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── MySample │ ├── Internal │ │ └── MySample_Internal.h │ ├── MyObjCInSwiftSample.swift │ ├── MySample.h │ ├── MySample.m │ └── MySwiftSample.swift │ ├── MySampleTests │ └── Info.plist │ ├── python │ ├── a.py │ └── subpython │ │ └── b.py │ └── resources │ ├── a.png │ └── lets │ └── go │ ├── nuts │ └── b.png │ └── runit.png └── spec ├── acceptance_spec.rb ├── env_parser_spec.rb ├── spec_generator_spec.rb ├── spec_helper.rb └── xcode_builder_spec.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | *.gem 5 | build 6 | tmp 7 | out 8 | samples/CLIConsumer/build 9 | samples/CLIConsumer/Pods 10 | samples/CLIConsumer/Podfile.lock 11 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | TargetRubyVersion: 2.5 3 | 4 | Naming/FileName: 5 | Exclude: 6 | - 'samples/MySample/MySample.podspec' 7 | 8 | Metrics/LineLength: 9 | Max: 336 10 | 11 | Metrics/BlockLength: 12 | Max: 1500 13 | 14 | Metrics/ClassLength: 15 | Enabled: false 16 | 17 | Metrics/MethodLength: 18 | Max: 100 19 | 20 | Metrics/CyclomaticComplexity: 21 | Enabled: false 22 | 23 | Metrics/PerceivedComplexity: 24 | Enabled: false 25 | 26 | Metrics/AbcSize: 27 | Enabled: false 28 | 29 | AssignmentInCondition: 30 | Enabled: false 31 | 32 | Style/Documentation: 33 | Enabled: false 34 | 35 | Metrics/ParameterLists: 36 | Enabled: false 37 | 38 | Lint/PercentStringArray: 39 | Exclude: 40 | - 'spec/xcode_builder_spec.rb' 41 | 42 | Layout/HeredocIndentation: 43 | Enabled: false 44 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | # Specify your gem's dependencies in cocoapods-pack.gemspec 6 | gemspec 7 | 8 | gem 'rubocop', '0.93.0' 9 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | cocoapods-pack (1.0.1) 5 | cocoapods (>= 1.10, < 2.0) 6 | rubyzip (~> 2.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | CFPropertyList (3.0.5) 12 | rexml 13 | activesupport (5.2.6) 14 | concurrent-ruby (~> 1.0, >= 1.0.2) 15 | i18n (>= 0.7, < 2) 16 | minitest (~> 5.1) 17 | tzinfo (~> 1.1) 18 | addressable (2.8.0) 19 | public_suffix (>= 2.0.2, < 5.0) 20 | algoliasearch (1.27.5) 21 | httpclient (~> 2.8, >= 2.8.3) 22 | json (>= 1.5.1) 23 | ast (2.4.2) 24 | atomos (0.1.3) 25 | claide (1.0.3) 26 | cocoapods (1.11.2) 27 | addressable (~> 2.8) 28 | claide (>= 1.0.2, < 2.0) 29 | cocoapods-core (= 1.11.2) 30 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 31 | cocoapods-downloader (>= 1.4.0, < 2.0) 32 | cocoapods-plugins (>= 1.0.0, < 2.0) 33 | cocoapods-search (>= 1.0.0, < 2.0) 34 | cocoapods-trunk (>= 1.4.0, < 2.0) 35 | cocoapods-try (>= 1.1.0, < 2.0) 36 | colored2 (~> 3.1) 37 | escape (~> 0.0.4) 38 | fourflusher (>= 2.3.0, < 3.0) 39 | gh_inspector (~> 1.0) 40 | molinillo (~> 0.8.0) 41 | nap (~> 1.0) 42 | ruby-macho (>= 1.0, < 3.0) 43 | xcodeproj (>= 1.21.0, < 2.0) 44 | cocoapods-core (1.11.2) 45 | activesupport (>= 5.0, < 7) 46 | addressable (~> 2.8) 47 | algoliasearch (~> 1.0) 48 | concurrent-ruby (~> 1.1) 49 | fuzzy_match (~> 2.0.4) 50 | nap (~> 1.0) 51 | netrc (~> 0.11) 52 | public_suffix (~> 4.0) 53 | typhoeus (~> 1.0) 54 | cocoapods-deintegrate (1.0.5) 55 | cocoapods-downloader (1.5.1) 56 | cocoapods-plugins (1.0.0) 57 | nap 58 | cocoapods-search (1.0.1) 59 | cocoapods-trunk (1.6.0) 60 | nap (>= 0.8, < 2.0) 61 | netrc (~> 0.11) 62 | cocoapods-try (1.2.0) 63 | coderay (1.1.3) 64 | colored2 (3.1.2) 65 | concurrent-ruby (1.1.9) 66 | diff-lcs (1.4.4) 67 | escape (0.0.4) 68 | ethon (0.15.0) 69 | ffi (>= 1.15.0) 70 | ffi (1.15.4) 71 | fourflusher (2.3.1) 72 | fuzzy_match (2.0.4) 73 | gh_inspector (1.1.3) 74 | httpclient (2.8.3) 75 | i18n (1.8.11) 76 | concurrent-ruby (~> 1.0) 77 | json (2.6.1) 78 | method_source (1.0.0) 79 | minitest (5.14.4) 80 | molinillo (0.8.0) 81 | nanaimo (0.3.0) 82 | nap (1.1.0) 83 | netrc (0.11.0) 84 | parallel (1.21.0) 85 | parser (3.0.3.1) 86 | ast (~> 2.4.1) 87 | pry (0.14.1) 88 | coderay (~> 1.1) 89 | method_source (~> 1.0) 90 | public_suffix (4.0.6) 91 | rainbow (3.0.0) 92 | rake (13.0.6) 93 | regexp_parser (2.2.0) 94 | rexml (3.2.5) 95 | rspec (3.10.0) 96 | rspec-core (~> 3.10.0) 97 | rspec-expectations (~> 3.10.0) 98 | rspec-mocks (~> 3.10.0) 99 | rspec-core (3.10.1) 100 | rspec-support (~> 3.10.0) 101 | rspec-expectations (3.10.1) 102 | diff-lcs (>= 1.2.0, < 2.0) 103 | rspec-support (~> 3.10.0) 104 | rspec-mocks (3.10.2) 105 | diff-lcs (>= 1.2.0, < 2.0) 106 | rspec-support (~> 3.10.0) 107 | rspec-support (3.10.3) 108 | rubocop (0.93.0) 109 | parallel (~> 1.10) 110 | parser (>= 2.7.1.5) 111 | rainbow (>= 2.2.2, < 4.0) 112 | regexp_parser (>= 1.8) 113 | rexml 114 | rubocop-ast (>= 0.6.0) 115 | ruby-progressbar (~> 1.7) 116 | unicode-display_width (>= 1.4.0, < 2.0) 117 | rubocop-ast (1.14.0) 118 | parser (>= 3.0.1.1) 119 | ruby-macho (2.5.1) 120 | ruby-progressbar (1.11.0) 121 | rubyzip (2.3.2) 122 | thread_safe (0.3.6) 123 | typhoeus (1.4.0) 124 | ethon (>= 0.9.0) 125 | tzinfo (1.2.9) 126 | thread_safe (~> 0.1) 127 | unicode-display_width (1.8.0) 128 | xcodeproj (1.21.0) 129 | CFPropertyList (>= 2.3.3, < 4.0) 130 | atomos (~> 0.1.3) 131 | claide (>= 1.0.2, < 2.0) 132 | colored2 (~> 3.1) 133 | nanaimo (~> 0.3.0) 134 | rexml (~> 3.2.4) 135 | 136 | PLATFORMS 137 | x86_64-darwin-20 138 | 139 | DEPENDENCIES 140 | activesupport (~> 5.0) 141 | bundler (~> 2.0) 142 | cocoapods-pack! 143 | pry (~> 0.10) 144 | rake (~> 13.0) 145 | rspec (~> 3.0) 146 | rubocop (= 0.93.0) 147 | 148 | BUNDLED WITH 149 | 2.2.29 150 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocoapods-pack 2 | 3 | A CocoaPods plugin that converts a given podspec into its binary version. 4 | 5 | For a given podspec, a zip file will be produced containing the binary representation of the original podspec sources. Each platform is packed as an `xcframework` within the zip file. Other attributes such as `resource_bundles` specified in the source podspec will also be packed. A binary podspec is also generated that can be published to a CocoaPods specs repo. 6 | 7 | You may choose to use `cocoapods-pack` as a packaging tool and write your own Swift Package Manager `Package.swift` file for the generated package instead. 8 | 9 | Finally, you may choose to write your own CocoaPods plugin that leverages `cocoapods-pack` to prebuild CocoaPods dependencies before integrating them into a project. 10 | 11 | 12 | ## Installation 13 | 14 | ``` 15 | gem install cocoapods-pack 16 | ``` 17 | 18 | ## Usage 19 | ``` 20 | $ pod pack SOURCE ARTIFACT_REPO_URL 21 | 22 | Converts the provided `SOURCE` into a binary version with each platform packed 23 | as an `xcframework`. The process includes installing a CocoaPods sandbox, 24 | building it for device and simulator using the 'Release' configuration, zipping 25 | the output and generating a new podspec that uses the `ARTIFACT_REPO_URL` 26 | provided as the source. The generated podspec is also validated. 27 | 28 | Options: 29 | 30 | --use-static-frameworks Produce a framework that wraps a 31 | static library from the source 32 | files. By default dynamic 33 | frameworks are used. 34 | --generate-module-map If specified, instead of using 35 | the default generated umbrella 36 | module map one will be generated 37 | based on the frameworks header 38 | dirs. 39 | --allow-warnings Lint validates even if warnings 40 | are present. 41 | --repo-update Force running `pod repo update` 42 | before install. 43 | --out-dir Optional directory to use to 44 | output results into. Defaults to 45 | current working directory. 46 | --skip-validation Skips linting the generated 47 | binary podspec. 48 | --skip-platforms Comma-delimited platforms to 49 | skip when creating a binary. 50 | --xcodebuild-opts Options to be passed through to 51 | xcodebuild. 52 | --use-json Use JSON for the generated 53 | binary podspec. 54 | --sources=https://github.com/artsy/Specs,master The sources from which to pull 55 | dependant pods (defaults to all 56 | available repos). Multiple 57 | sources must be comma-delimited. 58 | --allow-root Allows CocoaPods to run as root 59 | --silent Show nothing 60 | --verbose Show more debugging information 61 | --no-ansi Show output without ANSI codes 62 | --help Show help banner of specified 63 | command 64 | ``` 65 | 66 | ## Examples 67 | 68 | To run some of the examples in this repo make sure you run `bundle install` first. 69 | 70 | ``` 71 | bundle exec pod pack samples/MySample/MySample.podspec https://url/to/MySample.zip --out-dir=out 72 | ``` 73 | 74 | If you wish to skip a specific platform the source podspec provides: 75 | 76 | ``` 77 | bundle exec pod pack samples/MySample/MySample.podspec https://url/to/MySample.zip --skip-platforms=watchos --out-dir=out 78 | ``` 79 | 80 | Using static linking: 81 | 82 | ``` 83 | bundle exec pod pack samples/MySample/MySample.podspec https://url/to/MySample.zip --use-static-frameworks --out-dir=out 84 | ``` 85 | 86 | Additional `xcodebuild` options can be passed using `--xcodebuild-opts `, example: 87 | 88 | ``` 89 | bundle exec pod pack samples/MySample/MySample.podspec https://url/to/MySample.zip --use-static-frameworks --xcodebuild-opts=ENABLE_BITCODE=NO --out-dir=out 90 | ``` 91 | 92 | You may also specify a remote podspec without the need to clone its sources locally, for example: 93 | 94 | ``` 95 | bundle exec pod pack https://raw.githubusercontent.com/Alamofire/Alamofire/master/Alamofire.podspec https://url/to/Alamofire.zip --out-dir=out --allow-warnings 96 | ``` 97 | 98 | ## Developing 99 | 100 | Install Ruby >= 2.5.0 and set up with: 101 | 102 | ``` 103 | $ bundle 104 | ``` 105 | 106 | To run the unit tests use `rake`: 107 | 108 | ``` 109 | $ bundle exec rake spec 110 | ``` 111 | 112 | Or, for a more thorough output which include test names: 113 | 114 | ``` 115 | $ bundle exec rspec --format d 116 | ``` 117 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rspec/core/rake_task' 4 | require 'bundler/gem_tasks' 5 | 6 | RSpec::Core::RakeTask.new(:spec) 7 | 8 | task default: :spec 9 | -------------------------------------------------------------------------------- /cocoapods-pack.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | lib = File.expand_path('lib', __dir__) 4 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 5 | require 'cocoapods-pack/gem_version.rb' 6 | 7 | Gem::Specification.new do |spec| 8 | spec.name = 'cocoapods-pack' 9 | spec.version = CocoapodsPack::VERSION 10 | spec.authors = ['Square Inc.'] 11 | spec.license = 'Apache-2.0' 12 | spec.summary = 'Converts a source podspec into its binary form.' 13 | spec.description = <<~DESC 14 | A CocoaPods plugin that converts a given podspec into its binary version. 15 | For a given podspec, a zip file will be produced containing the binary representation of the original podspec sources. 16 | Each platform is packed as an `xcframework` within the zip file. 17 | Other attributes such as `resource_bundles` specified in the source podspec will also be packed. 18 | A binary podspec is also generated that can be published to a CocoaPods specs repo. 19 | DESC 20 | spec.homepage = 'https://github.com/square/cocoapods-pack' 21 | spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) 22 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 23 | spec.require_paths = ['lib'] 24 | 25 | spec.required_ruby_version = '>= 2.5.0' 26 | 27 | spec.add_dependency 'cocoapods', '>= 1.10', '< 2.0' 28 | spec.add_dependency 'rubyzip', '~> 2.0' 29 | 30 | spec.add_development_dependency 'activesupport', '~> 5.0' 31 | spec.add_development_dependency 'bundler', '~> 2.0' 32 | spec.add_development_dependency 'pry', '~> 0.10' 33 | spec.add_development_dependency 'rake', '~> 13.0' 34 | spec.add_development_dependency 'rspec', '~> 3.0' 35 | end 36 | -------------------------------------------------------------------------------- /endToEndPackMySample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Compiles and runs CLIConsumer mac app, which uses the MySample pod and ensures the binary version of MySample works end-to-end. 4 | 5 | set -e 6 | set -x 7 | 8 | rm -rf out/ 9 | echo Building MySample... 10 | bundle exec ruby local_pod.rb pack --allow-warnings samples/MySample/MySample.podspec --out-dir=out https://example.com --no-repo-update --use-static-frameworks --skip-platforms=watchos --skip-validation $@ 11 | 12 | echo Building CLIConsumer, which uses MySample pod 13 | ./samples/CLIConsumer/build.sh 14 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/command.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/command/pack' 20 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/command/pack.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/xcode_builder' 20 | require 'cocoapods-pack/spec_generator.rb' 21 | require 'cocoapods-pack/find_follow' 22 | require 'cocoapods-pack/zip_file_generator' 23 | require 'English' 24 | require 'set' 25 | 26 | module Pod 27 | class Command 28 | class Pack < Command 29 | include Pod::Config::Mixin 30 | include FindFollow 31 | 32 | LICENSE_GLOB_PATTERNS = Pod::Sandbox::FileAccessor::GLOB_PATTERNS[:license] 33 | CONCRETE_TARGET_NAME = 'Bin' 34 | 35 | XCArchive = Struct.new(:path, :podspec) do 36 | def dsym_paths 37 | Dir.glob(File.join(path, 'dSYMs', '*.dSYM')) 38 | end 39 | 40 | def bcsymbolmap_paths 41 | Dir.glob(File.join(path, 'BCSymbolMaps', '*.bcsymbolmap')) 42 | end 43 | 44 | def empty? 45 | Dir.empty?(File.join(path, 'Products')) 46 | end 47 | 48 | def modules_path 49 | "#{framework_path}/Modules" 50 | end 51 | 52 | def framework_path 53 | "#{path}/Products/Library/Frameworks/#{podspec.module_name}.framework" 54 | end 55 | end 56 | 57 | self.summary = 'An xcframework and podspec generator.' 58 | self.description = <<-DESC 59 | Converts the provided `SOURCE` into a binary version with each platform packed as an `xcframework`. 60 | The process includes installing a CocoaPods sandbox, building it for device and simulator using the 'Release' 61 | configuration, zipping the output and generating a new podspec that uses the `ARTIFACT_REPO_URL` provided as the 62 | source. The generated podspec is also validated. 63 | DESC 64 | 65 | self.arguments = [ 66 | CLAide::Argument.new('SOURCE', true), 67 | CLAide::Argument.new('ARTIFACT_REPO_URL', true) 68 | ] 69 | 70 | def self.options 71 | [ 72 | ['--use-static-frameworks', 'Produce a framework that wraps a static library from the source files. ' \ 73 | 'By default dynamic frameworks are used.'], 74 | ['--generate-module-map', 'If specified, instead of using the default generated umbrella module map one ' \ 75 | 'will be generated based on the frameworks header dirs.'], 76 | ['--allow-warnings', 'Lint validates even if warnings are present.'], 77 | ['--repo-update', 'Force running `pod repo update` before install.'], 78 | ['--out-dir', 'Optional directory to use to output results into. Defaults to current working directory.'], 79 | ['--skip-validation', 'Skips linting the generated binary podspec.'], 80 | ['--skip-platforms', 'Comma-delimited platforms to skip when creating a binary.'], 81 | ['--xcodebuild-opts', 'Options to be passed through to xcodebuild.'], 82 | ['--use-json', 'Use JSON for the generated binary podspec.'], 83 | ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependant pods ' \ 84 | '(defaults to all available repos). Multiple sources must be comma-delimited.'] 85 | ].concat(super) 86 | end 87 | 88 | def initialize(argv) 89 | @podspec_path = argv.shift_argument 90 | @artifact_repo_url = argv.shift_argument 91 | @allow_warnings = argv.flag?('allow-warnings', false) 92 | @repo_update = argv.flag?('repo-update', false) 93 | @generate_module_map = argv.flag?('generate-module-map', false) 94 | @use_static_frameworks = argv.flag?('use-static-frameworks', false) 95 | @skip_validation = argv.flag?('skip-validation', false) 96 | @xcodebuild_opts = argv.option('xcodebuild-opts') 97 | @out_dir = argv.option('out-dir', Dir.getwd) 98 | @skipped_platforms = argv.option('skip-platforms', '').split(',') 99 | @source_urls = argv.option('sources', Config.instance.sources_manager.all.map(&:url).join(',')).split(',') 100 | @use_json = argv.flag?('use-json', false) 101 | @build_settings_memoized = {} 102 | @sandbox_map = {} 103 | @project_files_dir = nil 104 | @project_zips_dir = nil 105 | super 106 | end 107 | 108 | def validate! 109 | super 110 | help! 'A podspec file is required.' unless @podspec_path 111 | help! 'Must supply an output directory.' unless @out_dir 112 | end 113 | 114 | def run 115 | podspec = Specification.from_file(podspec_to_pack) 116 | @project_files_dir = File.expand_path(File.join(@out_dir, 'files', podspec.name, podspec.version.to_s)) 117 | @project_zips_dir = File.expand_path(File.join(@out_dir, 'zips', podspec.name, podspec.version.to_s)) 118 | @artifact_repo_url ||= podspec.attributes_hash['artifact_repo_url'] 119 | FileUtils.mkdir_p(@project_files_dir) 120 | FileUtils.mkdir_p(@project_zips_dir) 121 | help! 'Must supply an artifact repo url.' unless @artifact_repo_url 122 | stage_dir = File.join(@project_files_dir, 'staged') 123 | FileUtils.rm_rf(stage_dir) 124 | FileUtils.mkdir_p(stage_dir) 125 | source_urls = @source_urls.map { |url| Config.instance.sources_manager.source_with_name_or_url(url) }.map(&:url) 126 | staged_sources = false 127 | available_platforms(podspec).each do |platform| 128 | linkage = @use_static_frameworks ? :static : :dynamic 129 | podfile = podfile_from_spec(platform, podspec, source_urls, linkage, @is_local) 130 | sandbox = install(podfile, platform, podspec) 131 | @sandbox_map[platform.name] = sandbox 132 | xcodebuild_out_dir = File.join(sandbox.root.to_s, 'xcodebuild') 133 | build(podspec, platform, sandbox, xcodebuild_out_dir) 134 | xcarchives = Dir.glob(File.join(xcodebuild_out_dir, '**', '*.xcarchive')).map do |path| 135 | XCArchive.new(path, podspec) 136 | end 137 | unless xcarchives.all?(&:empty?) 138 | stage_platform_xcframework(platform, sandbox, podspec, xcarchives, xcodebuild_out_dir, stage_dir) 139 | staged_sources = true 140 | end 141 | end 142 | stage_additional_artifacts(podspec, stage_dir) 143 | zip_output_path = pack(stage_dir, @project_zips_dir, podspec.name) 144 | binary_podspec = generate_binary_podspec(podspec, stage_dir, zip_output_path, staged_sources) 145 | validate_binary_podspec(binary_podspec) 146 | UI.message "Binary pod for #{podspec.name} created successfully!".green 147 | rescue XcodeBuilder::BuildError => e 148 | raise Informative, e 149 | end 150 | 151 | private 152 | 153 | def install(podfile, platform, podspec) 154 | UI.puts "\nInstalling #{podspec.name} for #{platform.name}...\n\n".yellow 155 | original_config = config.clone 156 | config.installation_root = Pathname.new(File.join(@project_files_dir, 'sandbox', platform.name.to_s)) 157 | 158 | sandbox = Sandbox.new(config.sandbox_root) 159 | 160 | installer = Installer.new(sandbox, podfile) 161 | installer.repo_update = @repo_update 162 | installer.use_default_plugins = false 163 | # noinspection RubyResolve 164 | installer.podfile.installation_options.integrate_targets = false 165 | # noinspection RubyResolve 166 | installer.podfile.installation_options.deterministic_uuids = false 167 | # noinspection RubyResolve 168 | installer.podfile.installation_options.warn_for_multiple_pod_sources = false 169 | installer.install! 170 | 171 | Config.instance = original_config 172 | sandbox 173 | end 174 | 175 | def build(podspec, platform, sandbox, xcodebuild_out_dir) 176 | xcode_builder(sandbox, xcodebuild_out_dir).build(platform.name, podspec.name) 177 | end 178 | 179 | def stage_platform_xcframework(platform, sandbox, podspec, xcarchives, xcodebuild_out_dir, stage_dir) 180 | target = podspec.name 181 | staged_platform_path = File.join(stage_dir, platform.name.to_s) 182 | UI.puts "Staging #{platform.name}-#{target} into #{staged_platform_path}...".yellow 183 | FileUtils.mkdir_p(staged_platform_path) 184 | 185 | if @generate_module_map 186 | type = type_from_platform(platform) 187 | settings = build_settings(sandbox, xcodebuild_out_dir, platform, target, type) 188 | module_name = settings['PRODUCT_MODULE_NAME'] 189 | file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(podspec.name), podspec.consumer(platform)) 190 | module_map_contents = module_map_contents_for_framework_header_dir(module_name, file_accessor) 191 | 192 | # Replace the generate module map by Xcode with the one we generated. 193 | xcarchives.each do |xcarchive| 194 | module_map = File.join(xcarchive.modules_path, 'module.modulemap') 195 | File.write(module_map, module_map_contents) 196 | end 197 | end 198 | 199 | xcframework_staged_output_path = File.join(staged_platform_path, "#{podspec.module_name}.xcframework") 200 | args = %w[xcodebuild -create-xcframework] 201 | xcarchives.each do |xcarchive| 202 | args << "-framework #{xcarchive.framework_path}" 203 | xcarchive.dsym_paths.each { |dsym_path| args << "-debug-symbols #{dsym_path}" } 204 | xcarchive.bcsymbolmap_paths.each { |bcsymbolmap_path| args << "-debug-symbols #{bcsymbolmap_path}" } 205 | end 206 | args << "-output #{xcframework_staged_output_path}" 207 | create_xcframework_cmd = args.join(' ') 208 | output, process_status = shellout(create_xcframework_cmd) 209 | return output if process_status.success? 210 | 211 | warn output 212 | raise Informative, "Failed to invoke create-xcframework command! Exit status: #{process_status.exitstatus}" 213 | end 214 | 215 | def stage_additional_artifacts(podspec, stage_dir) 216 | copy_vendored_frameworks(podspec, stage_dir) 217 | copy_vendored_libraries(podspec, stage_dir) 218 | copy_resource_bundles(podspec, stage_dir) 219 | copy_resources(podspec, stage_dir) 220 | copy_license(podspec, stage_dir) 221 | end 222 | 223 | def generate_binary_podspec(source_podspec, stage_dir, zip_output_path, staged_sources) 224 | name = source_podspec.name 225 | spec_generator = SpecGenerator.new(source_podspec, @artifact_repo_url, zip_output_path, staged_sources) 226 | available_platforms(source_podspec).each do |platform| 227 | type = type_from_platform(platform) 228 | sandbox = @sandbox_map[platform.name] 229 | xcodebuild_out_dir = File.join(sandbox.root.to_s, 'xcodebuild') 230 | settings = build_settings(sandbox, xcodebuild_out_dir, platform, name, type) 231 | spec_generator.add_platform(platform, "#{settings['PRODUCT_NAME']}.xcframework") 232 | end 233 | spec = spec_generator.generate 234 | if @use_json 235 | binary_spec_path = File.join(stage_dir, name + '.podspec.json') 236 | File.open(binary_spec_path, 'w') { |file| file.write(spec.to_pretty_json) } 237 | else 238 | binary_spec_path = File.join(stage_dir, name + '.podspec') 239 | File.open(binary_spec_path, 'w') { |file| file.write(spec_generator.generate_ruby_string) } 240 | end 241 | spec.instance_variable_set(:@defined_in_file, Pathname.new(binary_spec_path)) 242 | spec 243 | end 244 | 245 | def validate_binary_podspec(podspec) 246 | if @skip_validation 247 | UI.puts 'Skipping validation phase...'.yellow 248 | return 249 | end 250 | 251 | UI.puts "\nValidating generated binary podspec...\n\n".yellow 252 | validator = Pod::Validator.new(podspec, @source_urls) 253 | validator.quick = false 254 | validator.local = true 255 | validator.no_clean = false 256 | validator.fail_fast = true 257 | validator.allow_warnings = @allow_warnings 258 | validator.no_subspecs = true 259 | validator.only_subspec = false 260 | validator.use_frameworks = true 261 | validator.use_static_frameworks = @use_static_frameworks 262 | validator.validate 263 | raise Informative, "The binary spec did not pass validation, due to #{validator.failure_reason}." if validator.failure_reason 264 | end 265 | 266 | def pack(input_dir, output_dir, name) 267 | output_path = File.join(output_dir, "#{name}.zip") 268 | UI.puts "\nPacking #{input_dir} into #{output_path}...\n".green 269 | ZipFileGenerator.new(input_dir, output_path).write { |file| File.extname(file) == '.podspec' || File.symlink?(file) } 270 | output_path 271 | end 272 | 273 | def module_map_contents_for_framework_header_dir(framework_name, file_accessor) 274 | if header_mappings_dir = file_accessor.spec_consumer.header_mappings_dir 275 | header_mappings_dir = file_accessor.root + header_mappings_dir 276 | end 277 | 278 | headers = {} 279 | file_accessor.public_headers.each do |path| 280 | header = if header_mappings_dir 281 | path.relative_path_from(header_mappings_dir) 282 | else 283 | path.basename 284 | end 285 | header = header.to_s 286 | .sub(%r{\A\.?/?}, '') # remove preceding '.' or './' 287 | next if header.empty? 288 | 289 | parts = header.split('/') 290 | file_name = parts.pop unless path.directory? 291 | 292 | current_module = headers # start at the root 293 | while part = parts.shift 294 | # drill down to find / create the intermediary "submodules" 295 | current_module = (current_module[part] ||= {}) 296 | end 297 | current_module[file_name] = file_name if file_name 298 | end 299 | 300 | modules_str = '' 301 | handle = lambda { |m, prefix = '', i = 2| 302 | m.each do |k, v| 303 | k = v.split('.', 2).first if v.is_a? String 304 | modules_str << (' ' * i) << 'module ' << k.tr('-', '_') << ' {' << "\n" 305 | if v.is_a? String 306 | header = prefix.empty? ? v : "#{prefix}/#{v}" 307 | modules_str << (' ' * (i + 2)) << %(header "#{header}") << "\n" 308 | modules_str << (' ' * (i + 2)) << 'export *' << "\n" 309 | else 310 | nested_prefix = prefix.empty? ? k : "#{prefix}/#{k}" 311 | handle[v, nested_prefix, i + 2] 312 | end 313 | modules_str << (' ' * i) << '}' << "\n" 314 | end 315 | } 316 | handle[headers] 317 | 318 | "framework module #{framework_name} {\n#{modules_str.chomp}\n}\n" 319 | end 320 | 321 | def build_settings(sandbox, xcodebuild_out_dir, platform, target, type = nil) 322 | args = [sandbox, xcodebuild_out_dir, platform, target, type] 323 | value = @build_settings_memoized[args] 324 | if value.nil? 325 | value = xcode_builder(sandbox, xcodebuild_out_dir).build_settings(platform, target, type) 326 | @build_settings_memoized[args] = value 327 | end 328 | value 329 | end 330 | 331 | def xcode_builder(sandbox, xcodebuild_out_dir) 332 | XcodeBuilder.new(sandbox.project_path, @xcodebuild_opts, xcodebuild_out_dir, UI, config.verbose) 333 | end 334 | 335 | def copy_vendored_frameworks(podspec, stage_dir) 336 | copy_vendored_artifacts(podspec, 'vendored_frameworks', stage_dir) 337 | end 338 | 339 | def copy_vendored_libraries(podspec, stage_dir) 340 | copy_vendored_artifacts(podspec, 'vendored_libraries', stage_dir) 341 | end 342 | 343 | def copy_vendored_artifacts(podspec, attribute, stage_dir) 344 | platforms = Pod::Specification::DSL::PLATFORMS 345 | hash = podspec.attributes_hash 346 | globs = [Array(hash[attribute])] + platforms.map { |p| Array((hash[p.to_s] || {})[attribute]) } 347 | globs.flatten.to_set.each { |glob| stage_glob(glob, stage_dir) } 348 | end 349 | 350 | def copy_resource_bundles(podspec, stage_dir) 351 | resource_bundles = podspec.attributes_hash['resource_bundles'] 352 | return if resource_bundles.nil? 353 | 354 | resource_paths = [] 355 | resource_bundles.values.map { |globspec| Array(globspec) }.flatten.each do |glob| 356 | podspec_dir_relative_glob(glob, include_dirs: true).each do |file_path| 357 | if File.file?(file_path) 358 | resource_paths << file_path 359 | else 360 | resource_paths += Pod::Sandbox::PathList.new(Pathname(file_path)).glob('**/*') 361 | end 362 | end 363 | end 364 | resource_paths.uniq.each { |resource_path| stage_file(resource_path, stage_dir) } 365 | end 366 | 367 | def copy_resources(podspec, stage_dir) 368 | %w[preserve_paths resources].each { |attribute| transplant_tree_with_attribute(podspec, attribute, stage_dir) } 369 | end 370 | 371 | def transplant_tree_with_attribute(podspec, attribute, stage_dir) 372 | globs = Array(podspec.attributes_hash[attribute]) 373 | globs.to_set.each { |glob| stage_glob(glob, stage_dir) } 374 | end 375 | 376 | def copy_license(podspec, stage_dir) 377 | return if podspec.license[:text] 378 | 379 | license_spec = podspec.license[:file] 380 | license_file = license_spec ? File.join(podspec_dir, license_spec) : lookup_default_license_file 381 | return unless license_file 382 | 383 | stage_file(license_file, stage_dir) 384 | end 385 | 386 | def lookup_default_license_file 387 | podspec_dir_relative_glob(LICENSE_GLOB_PATTERNS).first 388 | end 389 | 390 | def stage_glob(glob, stage_dir) 391 | glob = File.join(glob, '**', '*') if File.directory?(File.join(podspec_dir, glob)) 392 | podspec_dir_relative_glob(glob).each { |file_path| stage_file(file_path, stage_dir) } 393 | end 394 | 395 | def podspec_dir_relative_glob(glob, options = {}) 396 | Pod::Sandbox::PathList.new(Pathname(podspec_dir)).glob(glob, options) 397 | end 398 | 399 | def stage_file(file_path, stage_dir) 400 | pathname = Pathname(file_path) 401 | 402 | relative_path_file = pathname.relative_path_from(Pathname(podspec_dir)).dirname.to_path 403 | raise Informative, "Bad Relative path #{relative_path_file}" if relative_path_file.start_with?('..') 404 | 405 | staged_folder = File.join(stage_dir, relative_path_file) 406 | FileUtils.mkdir_p(staged_folder) 407 | staged_file_path = File.join(staged_folder, pathname.basename) 408 | raise Informative, "File #{staged_file_path} already exists." if File.exist?(staged_file_path) 409 | 410 | FileUtils.copy_file(pathname.to_path, staged_file_path) 411 | end 412 | 413 | def podspec_dir 414 | File.expand_path(File.dirname(podspec_to_pack)) 415 | end 416 | 417 | def copy_headers(sandbox, target, stage_dir) 418 | header_path = File.join(sandbox.public_headers.root, target) 419 | cp_r_dereference(header_path, stage_dir) 420 | end 421 | 422 | def cp_r_dereference(src, dst) 423 | src_pn = Pathname.new(src) 424 | find_follow(src) do |path| 425 | relpath = Pathname.new(path).relative_path_from(src_pn).to_s 426 | dstpath = File.join(dst, relpath) 427 | 428 | if File.directory?(path) || (File.symlink?(path) && File.directory?(File.realpath(path))) 429 | FileUtils.mkdir_p(dstpath) 430 | else 431 | FileUtils.copy_file(path, dstpath) 432 | end 433 | end 434 | end 435 | 436 | def podfile_from_spec(platform, podspec, source_urls, linkage, local) 437 | Pod::Podfile.new do 438 | install!('cocoapods', warn_for_multiple_pod_sources: false) 439 | source_urls.each { |u| source(u) } 440 | use_frameworks!(linkage: linkage) 441 | platform(platform.name, platform.deployment_target) 442 | if local 443 | pod podspec.name, path: podspec.defined_in_file.to_s 444 | else 445 | pod podspec.name, podspec: podspec.defined_in_file.to_s 446 | end 447 | target CONCRETE_TARGET_NAME 448 | end 449 | end 450 | 451 | def podspec_to_pack 452 | @podspec_to_pack = begin 453 | path = @podspec_path 454 | if path =~ %r{https?://} 455 | require 'cocoapods/open-uri' 456 | output_path = podspecs_tmp_dir + File.basename(path) 457 | output_path.dirname.mkpath 458 | begin 459 | OpenURI.open_uri(path) do |io| 460 | output_path.open('w') { |f| f << io.read } 461 | end 462 | rescue StandardError => e 463 | raise Informative, "Downloading a podspec from `#{path}` failed: #{e}" 464 | end 465 | @is_local = false 466 | output_path 467 | elsif path =~ %r{file?://} 468 | require 'fileutils' 469 | require 'uri' 470 | output_path = podspecs_tmp_dir + File.basename(path) 471 | output_path.dirname.mkpath 472 | uri = URI(path) 473 | absolute_path = File.expand_path(File.join(uri.host, uri.path), Dir.pwd) 474 | FileUtils.cp absolute_path, output_path 475 | @is_local = false 476 | output_path 477 | elsif Pathname.new(path).directory? 478 | raise Informative, "Podspec specified in `#{path}` is a directory." 479 | else 480 | pathname = Pathname.new(path) 481 | raise Informative, "Unable to find a spec named `#{path}'." unless pathname.exist? && path.include?('.podspec') 482 | 483 | @is_local = true 484 | pathname 485 | end 486 | end 487 | end 488 | 489 | def podspecs_tmp_dir 490 | Pathname.new(Dir.tmpdir) + "CocoaPods-Bin/#{CocoapodsPack::VERSION}/Pack_podspec" 491 | end 492 | 493 | def type_from_platform(platform) 494 | return :simulator if platform == :ios 495 | return :simulator if platform == :watchos 496 | return :simulator if platform == :tvos 497 | 498 | nil 499 | end 500 | 501 | def available_platforms(podspec) 502 | return podspec.available_platforms if @skipped_platforms.empty? 503 | 504 | podspec.available_platforms.reject do |platform| 505 | @skipped_platforms.include? platform.string_name.gsub(/\s+/, '').downcase 506 | end 507 | end 508 | 509 | def shellout(command) 510 | output = `#{command}` 511 | [output, $CHILD_STATUS] 512 | end 513 | end 514 | end 515 | end 516 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/env_parser.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | module EnvParser 20 | def parse_env(output) 21 | Hash[*output.lines.select { |l| l.include?(' = ') }.map { |l| l.split(' =', 2) }.flatten.map(&:strip)] 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/find_follow.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Source: https://gist.github.com/akostadinov/05c2a976dc16ffee9cac 4 | 5 | # * ruby implementation of find that follows symbolic directory links 6 | # * tested on ruby 1.9.3, ruby 2.0 and jruby on Fedora 20 linux 7 | # * you can use Find.prune 8 | # * detect symlinks to dirs by path "/" suffix; does nothing with files so `symlink?` method is working fine 9 | # * depth first order 10 | # * detects cycles and raises an error 11 | # * raises on broken links 12 | # * uses recursion in the `do_find` proc when directory links are met (takes a lot of nested links until SystemStackError, that's practically never) 13 | # 14 | # * use like: find_follow(".") {|f| puts f} 15 | # 16 | # Copyright (c) 2014 Red Hat inc 17 | # 18 | # Permission is hereby granted, free of charge, to any person obtaining a copy 19 | # of this software and associated documentation files (the "Software"), to deal 20 | # in the Software without restriction, including without limitation the rights 21 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | # copies of the Software, and to permit persons to whom the Software is 23 | # furnished to do so, subject to the following conditions: 24 | # 25 | # The above copyright notice and this permission notice shall be included in 26 | # all copies or substantial portions of the Software. 27 | # 28 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | # THE SOFTWARE. 35 | 36 | require 'find' 37 | require 'pathname' 38 | 39 | module FindFollow 40 | def find_follow(*paths) 41 | block_given? || (return enum_for(__method__, *paths)) 42 | 43 | link_cache = {} 44 | link_resolve = lambda { |path| 45 | # puts "++ link_resolve: #{path}" # trace 46 | return link_cache[path] if link_cache[path] 47 | 48 | return link_cache[path] = Pathname.new(path).realpath.to_s 49 | } 50 | # this lambda should cleanup `link_cache` from unnecessary entries 51 | link_cache_reset = lambda { |path| 52 | # puts "++ link_cache_reset: #{path}" # trace 53 | # puts link_cache.to_s # trace 54 | link_cache.select! do |k, _v| 55 | path == k || k == '/' || path.start_with?(k + '/') 56 | end 57 | # puts link_cache.to_s # trace 58 | } 59 | link_is_recursive = lambda { |path| 60 | # puts "++ link_is_recursive: #{path}" # trace 61 | # the ckeck is useless if path is not a link but not our responsibility 62 | 63 | # we need to check full path for link cycles 64 | pn_initial = Pathname.new(path) 65 | unless pn_initial.absolute? 66 | # can we use `expand_path` here? Any issues with links? 67 | pn_initial = Pathname.new(File.join(Dir.pwd, path)) 68 | end 69 | 70 | # clear unnecessary cache 71 | link_cache_reset.call(pn_initial.to_s) 72 | 73 | link_dst = link_resolve.call(pn_initial.to_s) 74 | 75 | pn_initial.ascend do |pn| 76 | return { link: path, dst: pn } if pn != pn_initial && link_dst == link_resolve.call(pn.to_s) 77 | end 78 | 79 | return false 80 | } 81 | 82 | do_find = proc { |path| 83 | Find.find(path) do |result| 84 | if File.symlink?(result) && File.directory?(File.realpath(result)) 85 | if result[-1] == '/' 86 | # probably hitting https://github.com/jruby/jruby/issues/1895 87 | yield(result.dup) 88 | Dir.new(result).each do |subpath| 89 | do_find.call(result + subpath) unless ['.', '..'].include?(subpath) 90 | end 91 | elsif is_recursive = link_is_recursive.call(result) 92 | raise "cannot handle recursive links: #{is_recursive[:link]} => #{is_recursive[:dst]}" 93 | else 94 | do_find.call(result + '/') 95 | end 96 | else 97 | yield(result) 98 | end 99 | end 100 | } 101 | 102 | while path = paths.shift 103 | do_find.call(path) 104 | end 105 | end 106 | end 107 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/gem_version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | module CocoapodsPack 20 | VERSION = '1.0.1' 21 | end 22 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/spec_generator.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/gem_version' 20 | require 'set' 21 | require 'digest' 22 | 23 | class SpecGenerator 24 | ROOT_ATTRIBUTES = %w[name version summary license authors homepage description social_media_url 25 | docset_url documentation_url screenshots frameworks libraries requires_arc 26 | deployment_target xcconfig pod_target_xcconfig user_target_xcconfig source vendored_frameworks 27 | vendored_libraries resource_bundles resources preserve_paths cocoapods_version swift_versions].freeze 28 | PLATFORM_ATTRIBUTES = %w[frameworks libraries requires_arc xcconfig pod_target_xcconfig user_target_xcconfig].freeze 29 | 30 | attr_reader :podspec_path, :platforms, :artifact_repo_url, :staged_sources 31 | 32 | def initialize(source_podspec, artifact_repo_url, zip_output_path, staged_sources) 33 | @podspec_path = source_podspec 34 | @artifact_repo_url = artifact_repo_url 35 | @zip_output_path = zip_output_path 36 | @staged_sources = staged_sources 37 | @platforms = [] 38 | end 39 | 40 | def generate_ruby_string 41 | root_attributes = hash_to_dsl(@podspec_path.attributes_hash.merge('source' => artifact_repo_hash), ROOT_ATTRIBUTES) 42 | sections = [root_attributes] 43 | sections << dependency_section 44 | sections.push(*platforms_sections) 45 | sections_str = sections.reject(&:empty?).map do |section| 46 | section.map { |lines| lines + "\n" }.join('') 47 | end.join("\n") 48 | "#{header}\n#{open}\n#{sections_str}#{close}\n" 49 | end 50 | 51 | def generate 52 | Pod::Specification.from_string(generate_ruby_string, "#{@podspec_path.name}.podspec") 53 | end 54 | 55 | def add_platform(platform, executable_name) 56 | @platforms << [platform, executable_name] 57 | end 58 | 59 | private 60 | 61 | def platform_spec(platform, executable_name, has_one_platform) 62 | ordered_keys = %w[platform source_files header_mappings_dir module_map vendored_frameworks vendored_libraries] 63 | platform_attributes_hash = @podspec_path.attributes_hash[platform.name.to_s] || {} 64 | platform_vendored_frameworks = Array(platform_attributes_hash['vendored_frameworks']) 65 | platform_vendored_libraries = Array(platform_attributes_hash['vendored_libraries']) 66 | hash = platform_spec_hash(platform.name, executable_name, platform_vendored_frameworks, platform_vendored_libraries) 67 | platform_prefix = "#{platform.name}." 68 | platform_section = [] 69 | unless has_one_platform 70 | version = platform.deployment_target ? platform.deployment_target.version : nil 71 | platform_section << spec_line('deployment_target', version, platform_prefix) 72 | end 73 | platform_section.push(*hash_to_dsl(hash, ordered_keys, platform_prefix)) 74 | platform_section.push(*hash_to_dsl(platform_attributes_hash, PLATFORM_ATTRIBUTES, platform_prefix)) if platform_attributes_hash 75 | platform_section 76 | end 77 | 78 | def platform_spec_hash(platform_name, product_name, vendored_frameworks, vendored_libraries) 79 | platform_hash = {} 80 | platform_hash['vendored_frameworks'] ||= [] 81 | platform_hash['vendored_frameworks'] << "#{platform_name}/#{product_name}" if staged_sources 82 | platform_hash['vendored_frameworks'] += vendored_frameworks 83 | platform_hash['vendored_libraries'] = vendored_libraries 84 | platform_hash 85 | end 86 | 87 | def platforms_sections 88 | ret = [] 89 | has_one_platform = (@platforms.size == 1) 90 | if has_one_platform 91 | platform, = @platforms.first 92 | ret << [spec_line('platform', platform_spec_line(platform))] 93 | end 94 | ret.push(*@platforms.map { |p, e| platform_spec(p, e, has_one_platform) }) 95 | ret 96 | end 97 | 98 | def dependency_section 99 | @podspec_path.dependencies.map { |dependency| dependency_line(dependency) } 100 | end 101 | 102 | def platform_spec_line(platform) 103 | return [platform.symbolic_name] unless platform.deployment_target 104 | 105 | [platform.symbolic_name, platform.deployment_target.to_s] 106 | end 107 | 108 | def header 109 | "# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify." 110 | end 111 | 112 | def open 113 | 'Pod::Spec.new do |s|' 114 | end 115 | 116 | def close 117 | 'end' 118 | end 119 | 120 | def artifact_repo_hash 121 | { http: artifact_repo_url, sha256: Digest::SHA2.file(@zip_output_path).hexdigest } 122 | end 123 | 124 | def str(str) 125 | "'#{str.gsub(/\n/, '\n')}'" 126 | end 127 | 128 | def hash_to_dsl(hash, ordered_keys, extra_prefix = '') 129 | ret = [] 130 | ordered_keys.each do |k| 131 | v = hash[k] 132 | ret << spec_line(k, v, extra_prefix) unless v.nil? || v == [] 133 | end 134 | ret 135 | end 136 | 137 | def spec_line(key, value, extra_prefix = '') 138 | [' ', 's.', extra_prefix, key.to_s, ' = ', value_of(value)].join('') 139 | end 140 | 141 | def dependency_line(dependency) 142 | name = dependency.name 143 | reqstr = dependency.requirement.as_list.map { |s| value_of(s) }.join(', ') 144 | [' ', 's.dependency ', value_of(name), ', ', reqstr].join('') 145 | end 146 | 147 | def value_of(value) 148 | return str(quote_quotes(value)) if value.is_a?(String) 149 | return value.map { |x| value_of(x) }.join(', ') if value.is_a?(Array) 150 | 151 | quote_quotes(value.inspect) 152 | end 153 | 154 | def quote_quotes(str) 155 | str.gsub(/'/, "\\\\'") 156 | end 157 | end 158 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/xcode_builder.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/env_parser' 20 | require 'English' 21 | 22 | class XcodeBuilder 23 | include EnvParser 24 | attr_reader :xcodeproject_path, :xcodebuild_outdir, :user_interface 25 | 26 | class BuildError < StandardError; end 27 | private :user_interface 28 | 29 | def initialize(xcodeproject_path, xcodebuild_opts, xcodebuild_outdir, user_interface, verbose = false) 30 | @xcodeproject_path = xcodeproject_path 31 | @xcodebuild_opts = xcodebuild_opts 32 | @xcodebuild_outdir = xcodebuild_outdir 33 | @user_interface = user_interface 34 | @verbose = verbose 35 | end 36 | 37 | def build(platform, target, xcodebuild_args = nil) 38 | return build_ios(target, xcodebuild_args) if platform == :ios 39 | return build_osx(target, xcodebuild_args) if platform == :osx 40 | return build_watchos(target, xcodebuild_args) if platform == :watchos 41 | return build_tvos(target, xcodebuild_args) if platform == :tvos 42 | 43 | raise "Unknown platform: '#{platform}'" 44 | end 45 | 46 | def build_settings(platform, target, type = nil) 47 | return build_ios_settings(target, type) if platform == :ios 48 | return build_watchos_settings(target, type) if platform == :watchos 49 | return build_tvos_settings(target, type) if platform == :tvos 50 | 51 | build_osx_settings(target) if platform == :osx 52 | end 53 | 54 | private 55 | 56 | def verbose? 57 | @verbose 58 | end 59 | 60 | def build_ios(target, xcodebuild_args) 61 | user_interface.puts "\nBuilding #{target} for iOS...\n".yellow 62 | run(create_build_command(target, ios_sim_args, xcodebuild_args, :simulator)) 63 | run(create_build_command(target, ios_device_args, xcodebuild_args, :device)) 64 | user_interface.puts(+'iOS build successful.'.green << "\n\n") 65 | end 66 | 67 | def build_osx(target, xcodebuild_args) 68 | user_interface.puts "\nBuilding #{target} for macOS...\n".yellow 69 | run(create_build_command(target, macos_args, xcodebuild_args)) 70 | user_interface.puts(+'macOS build successful.'.green << "\n\n") 71 | end 72 | 73 | def build_watchos(target, xcodebuild_args) 74 | user_interface.puts "\nBuilding #{target} for watchOS...\n".yellow 75 | run(create_build_command(target, watchos_sim_args, xcodebuild_args, :simulator)) 76 | run(create_build_command(target, watchos_device_args, xcodebuild_args, :device)) 77 | user_interface.puts(+'watchOS build successful.'.green << "\n\n") 78 | end 79 | 80 | def build_tvos(target, xcodebuild_args) 81 | user_interface.puts "\nBuilding #{target} for tvOS...\n".yellow 82 | run(create_build_command(target, tvos_sim_args, xcodebuild_args, :simulator)) 83 | run(create_build_command(target, tvos_device_args, xcodebuild_args, :device)) 84 | user_interface.puts(+'tvOS build successful.'.green << "\n\n") 85 | end 86 | 87 | def build_ios_settings(target, type) 88 | type_args = args_for_ios_type(type) 89 | command = create_build_command(target, type_args, '-showBuildSettings', type) 90 | parse_build_settings(command) 91 | end 92 | 93 | def build_osx_settings(target) 94 | parse_build_settings(create_build_command(target, macos_args, '-showBuildSettings')) 95 | end 96 | 97 | def build_watchos_settings(target, type) 98 | type_args = args_for_watchos_type(type) 99 | command = create_build_command(target, type_args, '-showBuildSettings', type) 100 | parse_build_settings(command) 101 | end 102 | 103 | def build_tvos_settings(target, type) 104 | type_args = args_for_tvos_type(type) 105 | command = create_build_command(target, type_args, '-showBuildSettings', type) 106 | parse_build_settings(command) 107 | end 108 | 109 | def parse_build_settings(command) 110 | parse_env(run(command)) 111 | end 112 | 113 | def args_for_ios_type(type) 114 | return ios_device_args if type == :device 115 | return ios_sim_args if type == :simulator 116 | 117 | raise "Unknown type for iOS: '#{type}'" 118 | end 119 | 120 | def args_for_watchos_type(type) 121 | return watchos_device_args if type == :device 122 | return watchos_sim_args if type == :simulator 123 | 124 | raise "Unknown type for watchOS: '#{type}'" 125 | end 126 | 127 | def args_for_tvos_type(type) 128 | return tvos_device_args if type == :device 129 | return tvos_sim_args if type == :simulator 130 | 131 | raise "Unknown type for tvOS: '#{type}'" 132 | end 133 | 134 | def run(command) 135 | user_interface.puts command if verbose? 136 | output, process_status = shellout(command) 137 | user_interface.puts output if verbose? 138 | return output if process_status.success? 139 | 140 | warn output 141 | raise BuildError, "Failed to execute '#{command}'. Exit status: #{process_status.exitstatus}" 142 | end 143 | 144 | def shellout(command) 145 | output = `#{command}` 146 | [output, $CHILD_STATUS] 147 | end 148 | 149 | def create_build_command(target, sdk_args, xcodebuild_args, type = nil) 150 | args = [base_args(target), sdk_args] 151 | args << xcodebuild_args if !xcodebuild_args.nil? && !xcodebuild_args.strip.empty? 152 | args << @xcodebuild_opts unless @xcodebuild_opts.nil? 153 | args << 'archive' 154 | archive_path = +"-archivePath #{xcodebuild_outdir}/#{target}" 155 | archive_path << "-#{type}" if type 156 | archive_path << '.xcarchive' 157 | args << archive_path 158 | args.join(' ') 159 | end 160 | 161 | def base_args(target) 162 | "xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -project #{@xcodeproject_path}" \ 163 | " -scheme \"#{target}\" -configuration Release EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m" 164 | end 165 | 166 | def ios_sim_args 167 | '-destination "generic/platform=iOS Simulator"' 168 | end 169 | 170 | def ios_device_args 171 | '-destination "generic/platform=iOS"' 172 | end 173 | 174 | def macos_args 175 | '-destination "generic/platform=macOS"' 176 | end 177 | 178 | def watchos_sim_args 179 | '-destination "generic/platform=watchOS Simulator"' 180 | end 181 | 182 | def watchos_device_args 183 | '-destination "generic/platform=watchOS"' 184 | end 185 | 186 | def tvos_sim_args 187 | '-destination "generic/platform=tvOS Simulator"' 188 | end 189 | 190 | def tvos_device_args 191 | '-destination "generic/platform=tvOS"' 192 | end 193 | end 194 | -------------------------------------------------------------------------------- /lib/cocoapods-pack/zip_file_generator.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'zip' 20 | 21 | class ZipFileGenerator 22 | def initialize(input_dir, output_file) 23 | @input_dir = input_dir 24 | @output_file = output_file 25 | end 26 | 27 | def write(&skip_filter_block) 28 | entries = Dir.entries(@input_dir) 29 | entries.delete('.') 30 | entries.delete('..') 31 | begin 32 | io = Zip::File.open(@output_file, Zip::File::CREATE) 33 | write_entries(entries, '', io, &skip_filter_block) 34 | ensure 35 | io.close 36 | end 37 | end 38 | 39 | private 40 | 41 | def write_entries(entries, path, io, &skip_filter_block) 42 | entries.each do |e| 43 | zip_file_path = path == '' ? e : File.join(path, e) 44 | disk_file_path = File.join(@input_dir, zip_file_path) 45 | if File.directory?(disk_file_path) 46 | io.mkdir(zip_file_path) 47 | subdir = Dir.entries(disk_file_path) 48 | subdir.delete('.') 49 | subdir.delete('..') 50 | write_entries(subdir, zip_file_path, io, &skip_filter_block) 51 | elsif skip_filter_block.nil? || !yield(disk_file_path) 52 | io.get_output_stream(zip_file_path) { |f| f.write(IO.binread(disk_file_path)) } 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/cocoapods_pack.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/gem_version' 20 | -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Copyright 2021 Square, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require 'cocoapods-pack/command' 20 | -------------------------------------------------------------------------------- /local_pod.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'bundler/setup' 4 | require 'cocoapods' 5 | require 'cocoapods-pack/command' 6 | 7 | load Gem.bin_path('cocoapods', 'pod') 8 | -------------------------------------------------------------------------------- /packMySample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit 3 | set -o pipefail 4 | set -o nounset 5 | set -o xtrace 6 | 7 | rm -rf out/ 8 | bundle exec ruby local_pod.rb pack --verbose --allow-warnings samples/MySample/MySample.podspec --out-dir=out https://example.com --no-repo-update $@ 9 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 291F51BD1B99473000C165C6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 291F51BC1B99473000C165C6 /* main.m */; }; 11 | 98D5AC434BDFB8DC349A03E8 /* libPods-CLIConsumer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A0B26ABCDC5373425E080A5 /* libPods-CLIConsumer.a */; }; 12 | B7F77F712730B512006BDDEE /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7F77F702730B512006BDDEE /* dummy.swift */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 291F51B71B99473000C165C6 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = /usr/share/man/man1/; 20 | dstSubfolderSpec = 0; 21 | files = ( 22 | ); 23 | runOnlyForDeploymentPostprocessing = 1; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 0A0B26ABCDC5373425E080A5 /* libPods-CLIConsumer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CLIConsumer.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 291F51B91B99473000C165C6 /* CLIConsumer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CLIConsumer; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 291F51BC1B99473000C165C6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 31 | 5949E711176CA7D55DB1F878 /* Pods-CLIConsumer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CLIConsumer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CLIConsumer/Pods-CLIConsumer.debug.xcconfig"; sourceTree = ""; }; 32 | B7F77F702730B512006BDDEE /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dummy.swift; sourceTree = ""; }; 33 | DE58C87647762F5632373BB7 /* Pods-CLIConsumer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CLIConsumer.release.xcconfig"; path = "Pods/Target Support Files/Pods-CLIConsumer/Pods-CLIConsumer.release.xcconfig"; sourceTree = ""; }; 34 | /* End PBXFileReference section */ 35 | 36 | /* Begin PBXFrameworksBuildPhase section */ 37 | 291F51B61B99473000C165C6 /* Frameworks */ = { 38 | isa = PBXFrameworksBuildPhase; 39 | buildActionMask = 2147483647; 40 | files = ( 41 | 98D5AC434BDFB8DC349A03E8 /* libPods-CLIConsumer.a in Frameworks */, 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 291F51B01B99473000C165C6 = { 49 | isa = PBXGroup; 50 | children = ( 51 | 291F51BB1B99473000C165C6 /* CLIConsumer */, 52 | 291F51BA1B99473000C165C6 /* Products */, 53 | B1132EA3772BF84A49C06527 /* Pods */, 54 | 3EABA70547980806DD80EEF7 /* Frameworks */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | 291F51BA1B99473000C165C6 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 291F51B91B99473000C165C6 /* CLIConsumer */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | 291F51BB1B99473000C165C6 /* CLIConsumer */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 291F51BC1B99473000C165C6 /* main.m */, 70 | B7F77F702730B512006BDDEE /* dummy.swift */, 71 | ); 72 | path = CLIConsumer; 73 | sourceTree = ""; 74 | }; 75 | 3EABA70547980806DD80EEF7 /* Frameworks */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 0A0B26ABCDC5373425E080A5 /* libPods-CLIConsumer.a */, 79 | ); 80 | name = Frameworks; 81 | sourceTree = ""; 82 | }; 83 | B1132EA3772BF84A49C06527 /* Pods */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 5949E711176CA7D55DB1F878 /* Pods-CLIConsumer.debug.xcconfig */, 87 | DE58C87647762F5632373BB7 /* Pods-CLIConsumer.release.xcconfig */, 88 | ); 89 | name = Pods; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | 291F51B81B99473000C165C6 /* CLIConsumer */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = 291F51C01B99473000C165C6 /* Build configuration list for PBXNativeTarget "CLIConsumer" */; 98 | buildPhases = ( 99 | BBFE089FE74E2624933DD932 /* [CP] Check Pods Manifest.lock */, 100 | 291F51B51B99473000C165C6 /* Sources */, 101 | 291F51B61B99473000C165C6 /* Frameworks */, 102 | 291F51B71B99473000C165C6 /* CopyFiles */, 103 | AA1E501E9D675640906F463B /* [CP] Copy Pods Resources */, 104 | ); 105 | buildRules = ( 106 | ); 107 | dependencies = ( 108 | ); 109 | name = CLIConsumer; 110 | productName = CLIConsumer; 111 | productReference = 291F51B91B99473000C165C6 /* CLIConsumer */; 112 | productType = "com.apple.product-type.tool"; 113 | }; 114 | /* End PBXNativeTarget section */ 115 | 116 | /* Begin PBXProject section */ 117 | 291F51B11B99473000C165C6 /* Project object */ = { 118 | isa = PBXProject; 119 | attributes = { 120 | LastUpgradeCheck = 0640; 121 | ORGANIZATIONNAME = Example; 122 | TargetAttributes = { 123 | 291F51B81B99473000C165C6 = { 124 | CreatedOnToolsVersion = 6.4; 125 | LastSwiftMigration = 1250; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = 291F51B41B99473000C165C6 /* Build configuration list for PBXProject "CLIConsumer" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = English; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | English, 135 | en, 136 | ); 137 | mainGroup = 291F51B01B99473000C165C6; 138 | productRefGroup = 291F51BA1B99473000C165C6 /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | 291F51B81B99473000C165C6 /* CLIConsumer */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXShellScriptBuildPhase section */ 148 | AA1E501E9D675640906F463B /* [CP] Copy Pods Resources */ = { 149 | isa = PBXShellScriptBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | ); 153 | inputPaths = ( 154 | "${PODS_ROOT}/Target Support Files/Pods-CLIConsumer/Pods-CLIConsumer-resources.sh", 155 | "${PODS_ROOT}/../../../out/files/MySample/0.0.1/staged/resources/a.png", 156 | "${PODS_ROOT}/../../../out/files/MySample/0.0.1/staged/resources/lets/go/nuts/b.png", 157 | "${PODS_ROOT}/../../../out/files/MySample/0.0.1/staged/resources/lets/go/runit.png", 158 | ); 159 | name = "[CP] Copy Pods Resources"; 160 | outputPaths = ( 161 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/a.png", 162 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/b.png", 163 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/runit.png", 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | shellPath = /bin/sh; 167 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CLIConsumer/Pods-CLIConsumer-resources.sh\"\n"; 168 | showEnvVarsInLog = 0; 169 | }; 170 | BBFE089FE74E2624933DD932 /* [CP] Check Pods Manifest.lock */ = { 171 | isa = PBXShellScriptBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | ); 175 | inputPaths = ( 176 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 177 | "${PODS_ROOT}/Manifest.lock", 178 | ); 179 | name = "[CP] Check Pods Manifest.lock"; 180 | outputPaths = ( 181 | "$(DERIVED_FILE_DIR)/Pods-CLIConsumer-checkManifestLockResult.txt", 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | shellPath = /bin/sh; 185 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 186 | showEnvVarsInLog = 0; 187 | }; 188 | /* End PBXShellScriptBuildPhase section */ 189 | 190 | /* Begin PBXSourcesBuildPhase section */ 191 | 291F51B51B99473000C165C6 /* Sources */ = { 192 | isa = PBXSourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | B7F77F712730B512006BDDEE /* dummy.swift in Sources */, 196 | 291F51BD1B99473000C165C6 /* main.m in Sources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | /* End PBXSourcesBuildPhase section */ 201 | 202 | /* Begin XCBuildConfiguration section */ 203 | 291F51BE1B99473000C165C6 /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_MODULES = YES; 210 | CLANG_ENABLE_OBJC_ARC = YES; 211 | CLANG_WARN_BOOL_CONVERSION = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INT_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN_UNREACHABLE_CODE = YES; 219 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 220 | COPY_PHASE_STRIP = NO; 221 | DEBUG_INFORMATION_FORMAT = dwarf; 222 | ENABLE_STRICT_OBJC_MSGSEND = YES; 223 | GCC_C_LANGUAGE_STANDARD = gnu99; 224 | GCC_DYNAMIC_NO_PIC = NO; 225 | GCC_NO_COMMON_BLOCKS = YES; 226 | GCC_OPTIMIZATION_LEVEL = 0; 227 | GCC_PREPROCESSOR_DEFINITIONS = ( 228 | "DEBUG=1", 229 | "$(inherited)", 230 | ); 231 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 232 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 233 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 234 | GCC_WARN_UNDECLARED_SELECTOR = YES; 235 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 236 | GCC_WARN_UNUSED_FUNCTION = YES; 237 | GCC_WARN_UNUSED_VARIABLE = YES; 238 | MACOSX_DEPLOYMENT_TARGET = 10.10; 239 | MTL_ENABLE_DEBUG_INFO = YES; 240 | ONLY_ACTIVE_ARCH = YES; 241 | SDKROOT = macosx; 242 | }; 243 | name = Debug; 244 | }; 245 | 291F51BF1B99473000C165C6 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_MODULES = YES; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 256 | CLANG_WARN_EMPTY_BODY = YES; 257 | CLANG_WARN_ENUM_CONVERSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | COPY_PHASE_STRIP = NO; 263 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 264 | ENABLE_NS_ASSERTIONS = NO; 265 | ENABLE_STRICT_OBJC_MSGSEND = YES; 266 | GCC_C_LANGUAGE_STANDARD = gnu99; 267 | GCC_NO_COMMON_BLOCKS = YES; 268 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 269 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 270 | GCC_WARN_UNDECLARED_SELECTOR = YES; 271 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 272 | GCC_WARN_UNUSED_FUNCTION = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | MACOSX_DEPLOYMENT_TARGET = 10.10; 275 | MTL_ENABLE_DEBUG_INFO = NO; 276 | SDKROOT = macosx; 277 | }; 278 | name = Release; 279 | }; 280 | 291F51C11B99473000C165C6 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | baseConfigurationReference = 5949E711176CA7D55DB1F878 /* Pods-CLIConsumer.debug.xcconfig */; 283 | buildSettings = { 284 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 285 | CLANG_ENABLE_MODULES = YES; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 289 | SWIFT_VERSION = 5.0; 290 | }; 291 | name = Debug; 292 | }; 293 | 291F51C21B99473000C165C6 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | baseConfigurationReference = DE58C87647762F5632373BB7 /* Pods-CLIConsumer.release.xcconfig */; 296 | buildSettings = { 297 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 298 | CLANG_ENABLE_MODULES = YES; 299 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SWIFT_VERSION = 5.0; 302 | }; 303 | name = Release; 304 | }; 305 | /* End XCBuildConfiguration section */ 306 | 307 | /* Begin XCConfigurationList section */ 308 | 291F51B41B99473000C165C6 /* Build configuration list for PBXProject "CLIConsumer" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 291F51BE1B99473000C165C6 /* Debug */, 312 | 291F51BF1B99473000C165C6 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | 291F51C01B99473000C165C6 /* Build configuration list for PBXNativeTarget "CLIConsumer" */ = { 318 | isa = XCConfigurationList; 319 | buildConfigurations = ( 320 | 291F51C11B99473000C165C6 /* Debug */, 321 | 291F51C21B99473000C165C6 /* Release */, 322 | ); 323 | defaultConfigurationIsVisible = 0; 324 | defaultConfigurationName = Release; 325 | }; 326 | /* End XCConfigurationList section */ 327 | }; 328 | rootObject = 291F51B11B99473000C165C6 /* Project object */; 329 | } 330 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcodeproj/xcshareddata/xcschemes/CLIConsumer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer/dummy.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | -------------------------------------------------------------------------------- /samples/CLIConsumer/CLIConsumer/main.m: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | @import MySample; 3 | 4 | int main(int argc, const char * argv[]) { 5 | @autoreleasepool { 6 | NSString* str = MySample.new.print; 7 | printf("%s", [[@"Calling MySample: " stringByAppendingFormat: @"%@\n", str] UTF8String]); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /samples/CLIConsumer/Podfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | platform :osx, '10.10' 4 | 5 | target 'CLIConsumer' do 6 | platform :osx, '10.10' 7 | 8 | pod 'MySample', path: '../../out/files/MySample/0.0.1/staged/' 9 | end 10 | -------------------------------------------------------------------------------- /samples/CLIConsumer/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | cli_project_path=`dirname $0` 6 | 7 | rm -rf $cli_project_path/Pods/ $cli_project_path/build/ $cli_project_path/Podfile.lock 8 | 9 | pod install --project-directory=$cli_project_path --no-repo-update 10 | 11 | xcodebuild -workspace $cli_project_path/CLIConsumer.xcworkspace -scheme CLIConsumer -configuration Release -derivedDataPath $cli_project_path/build/ 12 | 13 | ./$cli_project_path/build/Build/Products/Release/CLIConsumer 14 | -------------------------------------------------------------------------------- /samples/MySample/MIT: -------------------------------------------------------------------------------- 1 | the bare string -------------------------------------------------------------------------------- /samples/MySample/MySample.podspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Pod::Spec.new do |s| 4 | s.name = 'MySample' 5 | s.version = '0.0.1' 6 | s.summary = 'A small summary on MySample library.' 7 | 8 | s.description = <<-DESC 9 | A longer description of MySample in Markdown format. 10 | 11 | * Think: Why did you write this? What is the focus? What does it do? 12 | * CocoaPods will be using this to generate tags, and improve search results. 13 | * Try to keep it short, snappy and to the point. 14 | * Finally, don't worry about the indent, CocoaPods strips it! 15 | DESC 16 | 17 | s.homepage = 'http://squareup.com/' 18 | s.cocoapods_version = '>= 1.0' 19 | 20 | s.license = { type: 'MIT', file: 'MIT' } 21 | 22 | s.author = { 'Square Inc.' => 'someemail@gmail.com' } 23 | 24 | s.ios.deployment_target = '9.0' 25 | s.osx.deployment_target = '10.10' 26 | s.watchos.deployment_target = '3.0' 27 | 28 | s.swift_version = '5.0' 29 | 30 | s.source = { git: 'local only', tag: s.version.to_s } 31 | 32 | s.source_files = 'MySample', 'MySample/**/*.{h,m,swift}' 33 | s.public_header_files = 'MySample/**/*.h' 34 | s.private_header_files = 'MySample/Internal/**/*.h' 35 | s.exclude_files = 'MySample/Exclude' 36 | 37 | s.ios.frameworks = 'iAd', 'SystemConfiguration', 'CoreTelephony', 'MobileCoreServices' 38 | 39 | s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SOMETHING=1' } 40 | s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SOMETHING=1' } 41 | 42 | s.resource = '**/*.png' 43 | 44 | s.preserve_paths = 'python/a.py', 'python/subpython/b.py' 45 | end 46 | -------------------------------------------------------------------------------- /samples/MySample/MySample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 293E92431B91185B006EDD86 /* MySample.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 293E92421B91185B006EDD86 /* MySample.h */; }; 11 | 293E92451B91185B006EDD86 /* MySample.m in Sources */ = {isa = PBXBuildFile; fileRef = 293E92441B91185B006EDD86 /* MySample.m */; }; 12 | 293E924B1B91185C006EDD86 /* libMySample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 293E923F1B91185B006EDD86 /* libMySample.a */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXContainerItemProxy section */ 16 | 293E924C1B91185C006EDD86 /* PBXContainerItemProxy */ = { 17 | isa = PBXContainerItemProxy; 18 | containerPortal = 293E92371B91185B006EDD86 /* Project object */; 19 | proxyType = 1; 20 | remoteGlobalIDString = 293E923E1B91185B006EDD86; 21 | remoteInfo = MySample; 22 | }; 23 | /* End PBXContainerItemProxy section */ 24 | 25 | /* Begin PBXCopyFilesBuildPhase section */ 26 | 293E923D1B91185B006EDD86 /* CopyFiles */ = { 27 | isa = PBXCopyFilesBuildPhase; 28 | buildActionMask = 2147483647; 29 | dstPath = "include/$(PRODUCT_NAME)"; 30 | dstSubfolderSpec = 16; 31 | files = ( 32 | 293E92431B91185B006EDD86 /* MySample.h in CopyFiles */, 33 | ); 34 | runOnlyForDeploymentPostprocessing = 0; 35 | }; 36 | /* End PBXCopyFilesBuildPhase section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 293E923F1B91185B006EDD86 /* libMySample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMySample.a; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 293E92421B91185B006EDD86 /* MySample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MySample.h; sourceTree = ""; }; 41 | 293E92441B91185B006EDD86 /* MySample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MySample.m; sourceTree = ""; }; 42 | 293E924A1B91185C006EDD86 /* MySampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MySampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 293E92501B91185C006EDD86 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 293E923C1B91185B006EDD86 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | 293E92471B91185C006EDD86 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 293E924B1B91185C006EDD86 /* libMySample.a in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 293E92361B91185B006EDD86 = { 66 | isa = PBXGroup; 67 | children = ( 68 | 293E92411B91185B006EDD86 /* MySample */, 69 | 293E924E1B91185C006EDD86 /* MySampleTests */, 70 | 293E92401B91185B006EDD86 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | 293E92401B91185B006EDD86 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 293E923F1B91185B006EDD86 /* libMySample.a */, 78 | 293E924A1B91185C006EDD86 /* MySampleTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | 293E92411B91185B006EDD86 /* MySample */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 293E92421B91185B006EDD86 /* MySample.h */, 87 | 293E92441B91185B006EDD86 /* MySample.m */, 88 | ); 89 | path = MySample; 90 | sourceTree = ""; 91 | }; 92 | 293E924E1B91185C006EDD86 /* MySampleTests */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 293E924F1B91185C006EDD86 /* Supporting Files */, 96 | ); 97 | path = MySampleTests; 98 | sourceTree = ""; 99 | }; 100 | 293E924F1B91185C006EDD86 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 293E92501B91185C006EDD86 /* Info.plist */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 293E923E1B91185B006EDD86 /* MySample */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 293E92531B91185C006EDD86 /* Build configuration list for PBXNativeTarget "MySample" */; 114 | buildPhases = ( 115 | 293E923B1B91185B006EDD86 /* Sources */, 116 | 293E923C1B91185B006EDD86 /* Frameworks */, 117 | 293E923D1B91185B006EDD86 /* CopyFiles */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = MySample; 124 | productName = MySample; 125 | productReference = 293E923F1B91185B006EDD86 /* libMySample.a */; 126 | productType = "com.apple.product-type.library.static"; 127 | }; 128 | 293E92491B91185C006EDD86 /* MySampleTests */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = 293E92561B91185C006EDD86 /* Build configuration list for PBXNativeTarget "MySampleTests" */; 131 | buildPhases = ( 132 | 293E92461B91185C006EDD86 /* Sources */, 133 | 293E92471B91185C006EDD86 /* Frameworks */, 134 | 293E92481B91185C006EDD86 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | 293E924D1B91185C006EDD86 /* PBXTargetDependency */, 140 | ); 141 | name = MySampleTests; 142 | productName = MySampleTests; 143 | productReference = 293E924A1B91185C006EDD86 /* MySampleTests.xctest */; 144 | productType = "com.apple.product-type.bundle.unit-test"; 145 | }; 146 | /* End PBXNativeTarget section */ 147 | 148 | /* Begin PBXProject section */ 149 | 293E92371B91185B006EDD86 /* Project object */ = { 150 | isa = PBXProject; 151 | attributes = { 152 | LastUpgradeCheck = 0640; 153 | ORGANIZATIONNAME = Example; 154 | TargetAttributes = { 155 | 293E923E1B91185B006EDD86 = { 156 | CreatedOnToolsVersion = 6.4; 157 | }; 158 | 293E92491B91185C006EDD86 = { 159 | CreatedOnToolsVersion = 6.4; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 293E923A1B91185B006EDD86 /* Build configuration list for PBXProject "MySample" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = 293E92361B91185B006EDD86; 171 | productRefGroup = 293E92401B91185B006EDD86 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | 293E923E1B91185B006EDD86 /* MySample */, 176 | 293E92491B91185C006EDD86 /* MySampleTests */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 293E92481B91185C006EDD86 /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXSourcesBuildPhase section */ 192 | 293E923B1B91185B006EDD86 /* Sources */ = { 193 | isa = PBXSourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | 293E92451B91185B006EDD86 /* MySample.m in Sources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | 293E92461B91185C006EDD86 /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin PBXTargetDependency section */ 210 | 293E924D1B91185C006EDD86 /* PBXTargetDependency */ = { 211 | isa = PBXTargetDependency; 212 | target = 293E923E1B91185B006EDD86 /* MySample */; 213 | targetProxy = 293E924C1B91185C006EDD86 /* PBXContainerItemProxy */; 214 | }; 215 | /* End PBXTargetDependency section */ 216 | 217 | /* Begin XCBuildConfiguration section */ 218 | 293E92511B91185C006EDD86 /* Debug */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 223 | CLANG_CXX_LIBRARY = "libc++"; 224 | CLANG_ENABLE_MODULES = YES; 225 | CLANG_ENABLE_OBJC_ARC = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 233 | CLANG_WARN_UNREACHABLE_CODE = YES; 234 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 235 | COPY_PHASE_STRIP = NO; 236 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 237 | ENABLE_STRICT_OBJC_MSGSEND = YES; 238 | GCC_C_LANGUAGE_STANDARD = gnu99; 239 | GCC_DYNAMIC_NO_PIC = NO; 240 | GCC_NO_COMMON_BLOCKS = YES; 241 | GCC_OPTIMIZATION_LEVEL = 0; 242 | GCC_PREPROCESSOR_DEFINITIONS = ( 243 | "DEBUG=1", 244 | "$(inherited)", 245 | ); 246 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 254 | MTL_ENABLE_DEBUG_INFO = YES; 255 | ONLY_ACTIVE_ARCH = YES; 256 | SDKROOT = iphoneos; 257 | }; 258 | name = Debug; 259 | }; 260 | 293E92521B91185C006EDD86 /* Release */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ALWAYS_SEARCH_USER_PATHS = NO; 264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 265 | CLANG_CXX_LIBRARY = "libc++"; 266 | CLANG_ENABLE_MODULES = YES; 267 | CLANG_ENABLE_OBJC_ARC = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_CONSTANT_CONVERSION = YES; 270 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 271 | CLANG_WARN_EMPTY_BODY = YES; 272 | CLANG_WARN_ENUM_CONVERSION = YES; 273 | CLANG_WARN_INT_CONVERSION = YES; 274 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | COPY_PHASE_STRIP = NO; 278 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 279 | ENABLE_NS_ASSERTIONS = NO; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu99; 282 | GCC_NO_COMMON_BLOCKS = YES; 283 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 284 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 285 | GCC_WARN_UNDECLARED_SELECTOR = YES; 286 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 287 | GCC_WARN_UNUSED_FUNCTION = YES; 288 | GCC_WARN_UNUSED_VARIABLE = YES; 289 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 290 | MTL_ENABLE_DEBUG_INFO = NO; 291 | SDKROOT = iphoneos; 292 | VALIDATE_PRODUCT = YES; 293 | }; 294 | name = Release; 295 | }; 296 | 293E92541B91185C006EDD86 /* Debug */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | OTHER_LDFLAGS = "-ObjC"; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SKIP_INSTALL = YES; 302 | }; 303 | name = Debug; 304 | }; 305 | 293E92551B91185C006EDD86 /* Release */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | OTHER_LDFLAGS = "-ObjC"; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | SKIP_INSTALL = YES; 311 | }; 312 | name = Release; 313 | }; 314 | 293E92571B91185C006EDD86 /* Debug */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 318 | FRAMEWORK_SEARCH_PATHS = ( 319 | "$(SDKROOT)/Developer/Library/Frameworks", 320 | "$(inherited)", 321 | ); 322 | GCC_PREPROCESSOR_DEFINITIONS = ( 323 | "DEBUG=1", 324 | "$(inherited)", 325 | ); 326 | INFOPLIST_FILE = MySampleTests/Info.plist; 327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | }; 330 | name = Debug; 331 | }; 332 | 293E92581B91185C006EDD86 /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 336 | FRAMEWORK_SEARCH_PATHS = ( 337 | "$(SDKROOT)/Developer/Library/Frameworks", 338 | "$(inherited)", 339 | ); 340 | INFOPLIST_FILE = MySampleTests/Info.plist; 341 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | }; 344 | name = Release; 345 | }; 346 | /* End XCBuildConfiguration section */ 347 | 348 | /* Begin XCConfigurationList section */ 349 | 293E923A1B91185B006EDD86 /* Build configuration list for PBXProject "MySample" */ = { 350 | isa = XCConfigurationList; 351 | buildConfigurations = ( 352 | 293E92511B91185C006EDD86 /* Debug */, 353 | 293E92521B91185C006EDD86 /* Release */, 354 | ); 355 | defaultConfigurationIsVisible = 0; 356 | defaultConfigurationName = Release; 357 | }; 358 | 293E92531B91185C006EDD86 /* Build configuration list for PBXNativeTarget "MySample" */ = { 359 | isa = XCConfigurationList; 360 | buildConfigurations = ( 361 | 293E92541B91185C006EDD86 /* Debug */, 362 | 293E92551B91185C006EDD86 /* Release */, 363 | ); 364 | defaultConfigurationIsVisible = 0; 365 | defaultConfigurationName = Release; 366 | }; 367 | 293E92561B91185C006EDD86 /* Build configuration list for PBXNativeTarget "MySampleTests" */ = { 368 | isa = XCConfigurationList; 369 | buildConfigurations = ( 370 | 293E92571B91185C006EDD86 /* Debug */, 371 | 293E92581B91185C006EDD86 /* Release */, 372 | ); 373 | defaultConfigurationIsVisible = 0; 374 | defaultConfigurationName = Release; 375 | }; 376 | /* End XCConfigurationList section */ 377 | }; 378 | rootObject = 293E92371B91185B006EDD86 /* Project object */; 379 | } 380 | -------------------------------------------------------------------------------- /samples/MySample/MySample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/MySample/MySample/Internal/MySample_Internal.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | -------------------------------------------------------------------------------- /samples/MySample/MySample/MyObjCInSwiftSample.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @objc public class MyObjCInSwiftSample: NSObject { 4 | 5 | @objc public var name: String? 6 | 7 | } 8 | -------------------------------------------------------------------------------- /samples/MySample/MySample/MySample.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | @interface MySample : NSObject 4 | 5 | - (NSString*)print; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /samples/MySample/MySample/MySample.m: -------------------------------------------------------------------------------- 1 | #import "MySample.h" 2 | #import "MySample_Internal.h" 3 | 4 | @implementation MySample 5 | 6 | - (NSString*)print { 7 | return @"it works!"; 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /samples/MySample/MySample/MySwiftSample.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class MySwiftSample { 4 | 5 | public var name: String? 6 | 7 | } 8 | -------------------------------------------------------------------------------- /samples/MySample/MySampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /samples/MySample/python/a.py: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /samples/MySample/python/subpython/b.py: -------------------------------------------------------------------------------- 1 | b 2 | -------------------------------------------------------------------------------- /samples/MySample/resources/a.png: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /samples/MySample/resources/lets/go/nuts/b.png: -------------------------------------------------------------------------------- 1 | b 2 | -------------------------------------------------------------------------------- /samples/MySample/resources/lets/go/runit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/square/cocoapods-pack/465bb20a2b5238bdd2c2dab8841d11a07ef7a072/samples/MySample/resources/lets/go/runit.png -------------------------------------------------------------------------------- /spec/acceptance_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rspec' 4 | require 'open3' 5 | 6 | describe 'End to end Mac app testing' do 7 | subject do 8 | script = './endToEndBinMySample.sh' 9 | script_dir = File.join(File.dirname(__FILE__), '../') 10 | Dir.chdir script_dir do 11 | Open3.capture2e([script, script]) 12 | end 13 | end 14 | 15 | let(:output) { subject.first } 16 | let(:status) { subject.last } 17 | 18 | xit 'compiles a mac app using cocoapods' do 19 | expect(output).to end_with("\nCalling MySample: MySample\n") 20 | expect(status).to be_success 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/env_parser_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rspec' 4 | require_relative '../lib/cocoapods-pack/env_parser' 5 | 6 | describe EnvParser do 7 | include EnvParser 8 | 9 | it 'can parse env variables into a hash' do 10 | build_settings = <<-BUILDSETTINGS 11 | LD_NO_PIE = NO 12 | LD_QUOTE_LINKER_ARGUMENTS_FOR_COMPILER_DRIVER = YES 13 | LINK_FILE_LIST_normal_i386 = 14 | BUILDSETTINGS 15 | hash = { 'LD_NO_PIE' => 'NO', 'LD_QUOTE_LINKER_ARGUMENTS_FOR_COMPILER_DRIVER' => 'YES' } 16 | expect(parse_env(build_settings)).to eq hash 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/spec_generator_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require 'ostruct' 5 | require 'tempfile' 6 | require_relative '../lib/cocoapods-pack/spec_generator' 7 | 8 | describe_with_private_methods SpecGenerator do 9 | def source_spec(opts = {}) 10 | fixed_root = { 11 | name: 'MySample', 12 | dependencies: [], 13 | attributes_hash: { 'name' => 'MySample' }.merge(opts[:attributes_hash] || {}) 14 | } 15 | OpenStruct.new(fixed_root.merge(opts[:root] || {})) 16 | end 17 | 18 | context 'for dynamic frameworks' do 19 | let(:use_frameworks) { true } 20 | temp_file = Tempfile.new('MySample.zip') 21 | 22 | it 'generates a ruby podspec' do 23 | artifact_repo_url = 'http://example.com/MySample.zip' 24 | spec = SpecGenerator.new source_podspec, artifact_repo_url, temp_file, true 25 | expect(spec.generate_ruby_string).to eq(expected_output) 26 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 27 | end 28 | 29 | it 'works with multiple platforms' do 30 | source_podspec = source_spec 31 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 32 | spec.add_platform(Pod::Platform.new(:ios, '8.0'), 'MySample.xcframework') 33 | spec.add_platform(Pod::Platform.new(:osx), 'MySample.xcframework') 34 | spec.add_platform(Pod::Platform.new(:watchos, '3.0'), 'MySample.xcframework') 35 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 36 | Pod::Spec.new do |s| 37 | s.name = 'MySample' 38 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 39 | 40 | s.ios.deployment_target = '8.0' 41 | s.ios.vendored_frameworks = 'ios/MySample.xcframework' 42 | 43 | s.osx.deployment_target = nil 44 | s.osx.vendored_frameworks = 'osx/MySample.xcframework' 45 | 46 | s.watchos.deployment_target = '3.0' 47 | s.watchos.vendored_frameworks = 'watchos/MySample.xcframework' 48 | end 49 | ) 50 | expect(spec.generate_ruby_string).to eq(expected_output) 51 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 52 | end 53 | 54 | it 'works with a single platform' do 55 | source_podspec = source_spec 56 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 57 | spec.add_platform(Pod::Platform.new(:ios), 'MySample.xcframework') 58 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 59 | Pod::Spec.new do |s| 60 | s.name = 'MySample' 61 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 62 | 63 | s.platform = :ios 64 | 65 | s.ios.vendored_frameworks = 'ios/MySample.xcframework' 66 | end 67 | ) 68 | expect(spec.generate_ruby_string).to eq(expected_output) 69 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 70 | end 71 | 72 | it 'works with dependencies' do 73 | source_podspec = source_spec(root: { dependencies: [Pod::Dependency.new('Dependency1', ['~> 1.0']), 74 | Pod::Dependency.new('Dependency2', ['>= 0']), 75 | Pod::Dependency.new('Dependency3', ['>= 0', '< 2.0'])] }) 76 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 77 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 78 | Pod::Spec.new do |s| 79 | s.name = 'MySample' 80 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 81 | 82 | s.dependency 'Dependency1', '~> 1.0' 83 | s.dependency 'Dependency2', '>= 0' 84 | s.dependency 'Dependency3', '< 2.0', '>= 0' 85 | end 86 | ) 87 | expect(spec.generate_ruby_string).to eq(expected_output) 88 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 89 | end 90 | 91 | it 'works with vendored_libraries' do 92 | source_podspec = source_spec(attributes_hash: { 'vendored_libraries' => ['lib1.a', 'lib2.a'] }) 93 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 94 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 95 | Pod::Spec.new do |s| 96 | s.name = 'MySample' 97 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 98 | s.vendored_libraries = 'lib1.a', 'lib2.a' 99 | end 100 | ) 101 | expect(spec.generate_ruby_string).to eq(expected_output) 102 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 103 | end 104 | 105 | it 'works with platform vendored_libraries' do 106 | source_podspec = source_spec(attributes_hash: { 'ios' => { 'vendored_libraries' => 'ioslib.a' } }) 107 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 108 | spec.add_platform(Pod::Platform.new(:ios), 'MySample.xcframework') 109 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 110 | Pod::Spec.new do |s| 111 | s.name = 'MySample' 112 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 113 | 114 | s.platform = :ios 115 | 116 | s.ios.vendored_frameworks = 'ios/MySample.xcframework' 117 | s.ios.vendored_libraries = 'ioslib.a' 118 | end 119 | ) 120 | expect(spec.generate_ruby_string).to eq(expected_output) 121 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 122 | end 123 | 124 | it 'works with vendored_frameworks' do 125 | source_podspec = source_spec(attributes_hash: { 'vendored_frameworks' => ['lib1.framework', 'lib2.framework'] }) 126 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 127 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 128 | Pod::Spec.new do |s| 129 | s.name = 'MySample' 130 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 131 | s.vendored_frameworks = 'lib1.framework', 'lib2.framework' 132 | end 133 | ) 134 | expect(spec.generate_ruby_string).to eq(expected_output) 135 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 136 | end 137 | 138 | it 'works with platform vendored_frameworks' do 139 | source_podspec = source_spec(attributes_hash: { 'ios' => { 'vendored_frameworks' => 'ioslib.framework' } }) 140 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 141 | spec.add_platform(Pod::Platform.new(:ios), 'MySample.xcframework') 142 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 143 | Pod::Spec.new do |s| 144 | s.name = 'MySample' 145 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 146 | 147 | s.platform = :ios 148 | 149 | s.ios.vendored_frameworks = 'ios/MySample.xcframework', 'ioslib.framework' 150 | end 151 | ) 152 | expect(spec.generate_ruby_string).to eq(expected_output) 153 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 154 | end 155 | 156 | it 'works with glob paths' do 157 | source_podspec = source_spec(attributes_hash: { 'ios' => { 'vendored_libraries' => '*.a' } }) 158 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 159 | spec.add_platform(Pod::Platform.new(:ios), 'MySample.xcframework') 160 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 161 | Pod::Spec.new do |s| 162 | s.name = 'MySample' 163 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 164 | 165 | s.platform = :ios 166 | 167 | s.ios.vendored_frameworks = 'ios/MySample.xcframework' 168 | s.ios.vendored_libraries = '*.a' 169 | end 170 | ) 171 | expect(spec.generate_ruby_string).to eq(expected_output) 172 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 173 | end 174 | 175 | it 'works with resources' do 176 | source_podspec = source_spec(attributes_hash: { 'resources' => ['a.png'], 'preserve_paths' => ['script.sh', 'run.sh'] }) 177 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 178 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 179 | Pod::Spec.new do |s| 180 | s.name = 'MySample' 181 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 182 | s.resources = 'a.png' 183 | s.preserve_paths = 'script.sh', 'run.sh' 184 | end 185 | ) 186 | expect(spec.generate_ruby_string).to eq(expected_output) 187 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 188 | end 189 | 190 | xit 'works with module maps and static libraries' do 191 | source_podspec = source_spec(root: { module_map: 'module.modulemap' }) 192 | spec = SpecGenerator.new source_podspec, 'url/MySample.zip', temp_file, true 193 | spec.add_platform(Pod::Platform.new(:ios, '7.0'), 'MySample.xcframework') 194 | expected_output = %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 195 | Pod::Spec.new do |s| 196 | s.name = 'MySample' 197 | s.source = {:http=>"url/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 198 | 199 | s.platform = :ios, '7.0' 200 | 201 | s.ios.module_map = 'ios/include/module.modulemap' 202 | s.ios.vendored_frameworks = 'ios/MySample.xcframework' 203 | end 204 | ) 205 | expect(spec.generate_ruby_string).to eq(expected_output) 206 | expect(spec.generate.to_pretty_json).to eq(Pod::Specification.from_string(expected_output, 'name.podspec').to_pretty_json) 207 | end 208 | end 209 | 210 | let :source_podspec do 211 | description = <<-DESCRIPTION 212 | A longer description of MySample in Markdown format. 213 | It's lines. 214 | DESCRIPTION 215 | source_spec(attributes_hash: { 'name' => 'MySample', 216 | 'version' => '0.0.1', 217 | 'summary' => 'A short description of MySample.', 218 | 'description' => description, 219 | 'homepage' => 'http://squareup.com/', 220 | 'license' => 221 | { 'type' => 'MIT', 222 | 'text' => "Copyright 2012\nPermission is granted to...\n" }, 223 | 'authors' => { 'Jack Dorsey' => 'notsoeasytogivethisaway@gmail.com' }, 224 | 'swift_versions' => '5.0', 225 | 'platforms' => { 'ios' => nil }, 226 | 'source' => { 'git' => 'local only', 'tag' => '0.0.1' }, 227 | 'source_files' => ['MySample', 'MySample/**/*.{h,m,swift}'], 228 | 'exclude_files' => 'MySample/Exclude', 229 | 'artifact_repo_url' => 'http://example.com/my.zip' }) 230 | end 231 | 232 | let :expected_output do 233 | %(# Generated by cocoapods-pack #{CocoapodsPack::VERSION} - Do not manually modify. 234 | Pod::Spec.new do |s| 235 | s.name = 'MySample' 236 | s.version = '0.0.1' 237 | s.summary = 'A short description of MySample.' 238 | s.license = {"type"=>"MIT", "text"=>"Copyright 2012\\nPermission is granted to...\\n"} 239 | s.authors = {"Jack Dorsey"=>"notsoeasytogivethisaway@gmail.com"} 240 | s.homepage = 'http://squareup.com/' 241 | s.description = 'A longer description of MySample in Markdown format.\\nIt\\'s lines.\\n' 242 | s.source = {:http=>"http://example.com/MySample.zip", :sha256=>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} 243 | s.swift_versions = '5.0' 244 | end 245 | ) 246 | end 247 | end 248 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'bundler/setup' 4 | require 'pp' 5 | require 'rspec' 6 | require 'cocoapods' 7 | 8 | module Kernel 9 | # Like describe, but makes all private/protected instance methods of the clazz public 10 | def describe_with_private_methods(clazz, *additional_desc, &block) 11 | if clazz.is_a?(Module) 12 | methods = clazz.private_instance_methods(false) + clazz.protected_methods(false) 13 | clazz.send(:public, *methods) 14 | end 15 | describe(clazz, *additional_desc, &block) 16 | end 17 | end 18 | 19 | module Pod 20 | # Disable the wrapping so the output is deterministic in the tests. 21 | # 22 | UI.disable_wrap = true 23 | 24 | # Redirects the messages to an internal store. 25 | # 26 | module UI 27 | @output = '' 28 | @warnings = '' 29 | 30 | class << self 31 | attr_accessor :output 32 | attr_accessor :warnings 33 | 34 | def puts(message = '') 35 | @output << "#{message}\n" 36 | end 37 | 38 | def warn(message = '', _actions = []) 39 | @warnings << "#{message}\n" 40 | end 41 | 42 | def print(message) 43 | @output << message 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/xcode_builder_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require_relative '../lib/cocoapods-pack/xcode_builder' 5 | 6 | describe_with_private_methods XcodeBuilder do 7 | let(:xcodebuild_opts) { nil } 8 | 9 | subject do 10 | ui = spy 11 | XcodeBuilder.new('xcodeproject_path', xcodebuild_opts, 'xcodebuild_outdir', ui) 12 | end 13 | 14 | it 'breaks when giving a bad platform' do 15 | expect { subject.build(:windows, 'target') }.to raise_error("Unknown platform: 'windows'") 16 | end 17 | 18 | it 'raises BuildError if shellout fails' do 19 | expect { subject.build(:windows, 'target') }.to raise_error("Unknown platform: 'windows'") 20 | end 21 | 22 | it 'breaks with unknown type' do 23 | builder = subject 24 | mock_status = instance_double(Process::Status, success?: false, exitstatus: 42) 25 | allow(builder).to receive(:warn) 26 | allow(builder).to receive(:shellout).and_return(['error stderr', mock_status]) 27 | expected_error_message = "Failed to execute 'xcodebuild this will totally fail'. Exit status: 42" 28 | expect { builder.run('xcodebuild this will totally fail') }.to raise_error(XcodeBuilder::BuildError, expected_error_message) 29 | end 30 | 31 | it 'executes xcodebuild in shell for osx' do 32 | builder = subject 33 | allow(builder).to receive(:run) 34 | builder.build(:osx, 'PodsTarget') 35 | expect(builder).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 36 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 37 | -project xcodeproject_path 38 | -scheme "PodsTarget" 39 | -configuration Release 40 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 41 | -destination "generic/platform=macOS" 42 | archive 43 | -archivePath xcodebuild_outdir/PodsTarget.xcarchive].join(' ')) 44 | end 45 | 46 | it 'executes xcodebuild in shell for ios' do 47 | builder = subject 48 | allow(builder).to receive(:run) 49 | builder.build(:ios, 'PodsTarget') 50 | expect(builder).to have_received(:run).twice 51 | expect(builder).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 52 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 53 | -project xcodeproject_path 54 | -scheme "PodsTarget" 55 | -configuration Release 56 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 57 | -destination "generic/platform=iOS Simulator" 58 | archive 59 | -archivePath xcodebuild_outdir/PodsTarget-simulator.xcarchive].join(' ')) 60 | expect(builder).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 61 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 62 | -project xcodeproject_path 63 | -scheme "PodsTarget" 64 | -configuration Release 65 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 66 | -destination "generic/platform=iOS" 67 | archive 68 | -archivePath xcodebuild_outdir/PodsTarget-device.xcarchive].join(' ')) 69 | end 70 | 71 | it 'executes xcodebuild in shell for watchos' do 72 | builder = subject 73 | allow(builder).to receive(:run) 74 | builder.build(:watchos, 'PodsTarget') 75 | expect(builder).to have_received(:run).twice 76 | expect(builder).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 77 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 78 | -project xcodeproject_path 79 | -scheme "PodsTarget" 80 | -configuration Release 81 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 82 | -destination "generic/platform=watchOS Simulator" 83 | archive 84 | -archivePath xcodebuild_outdir/PodsTarget-simulator.xcarchive].join(' ')) 85 | expect(builder).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 86 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 87 | -project xcodeproject_path 88 | -scheme "PodsTarget" 89 | -configuration Release 90 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 91 | -destination "generic/platform=watchOS" 92 | archive 93 | -archivePath xcodebuild_outdir/PodsTarget-device.xcarchive].join(' ')) 94 | end 95 | 96 | context 'with non-nil xcodebuild_opts' do 97 | let(:xcodebuild_opts) { 'CODE_SIGNING_REQUIRED=NO' } 98 | it 'passes xcodebuild_opts to xcodebuild' do 99 | allow(subject).to receive(:run) 100 | subject.build(:osx, 'PodsTarget') 101 | expect(subject).to have_received(:run).with(%w[xcodebuild ONLY_ACTIVE_ARCH=NO SKIP_INSTALL=NO 102 | BUILD_LIBRARY_FOR_DISTRIBUTION=YES 103 | -project xcodeproject_path 104 | -scheme "PodsTarget" 105 | -configuration Release 106 | EXCLUDED_SOURCE_FILE_NAMES=*-dummy.m 107 | -destination "generic/platform=macOS" 108 | CODE_SIGNING_REQUIRED=NO 109 | archive 110 | -archivePath xcodebuild_outdir/PodsTarget.xcarchive].join(' ')) 111 | end 112 | end 113 | end 114 | --------------------------------------------------------------------------------