cocoapods-swift-modular-headers 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/cocoapods-swift-modular-headers.gemspec +22 -0
- data/lib/cocoapods-swift-modular-headers/gem_version.rb +3 -0
- data/lib/cocoapods-swift-modular-headers/podfile_dsl.rb +36 -0
- data/lib/cocoapods-swift-modular-headers.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 280257edd8e55e7a467012888992447aa6451569a1351f63d31b16695855c253
|
4
|
+
data.tar.gz: 85514ce17badc2e765a725d93c38c92f7ba817437e9040ff912e02862cf8f95f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12fd59590c70cdfb4b2d238244206da45754672e41377df4dccd083375d2861dbfe10cb1bf754e99ea5598ada08e6effe2e9ab8f8a446a317cae2f00f76b40b1
|
7
|
+
data.tar.gz: a0eb05034d5d4e4780c7e91b87c243cfc80c8e6fb42d3ce577fddfad3f8fc1227eb20f4134201737994204000dbcc64056804fddf9fa847ba576513bd4e667f3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2024 Oskar Kwaśniewski <oskarkwasniewski@icloud.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# cocoapods-swift-modular-headers
|
2
|
+
|
3
|
+
Cocoapods plugin to automatically enable modular headers for dependencies of Swift pods.
|
4
|
+
|
5
|
+
## Demo
|
6
|
+
|
7
|
+
https://github.com/user-attachments/assets/f2713109-bb6d-42e1-a18d-f8546ddbb8bd
|
8
|
+
|
9
|
+
## Motivation
|
10
|
+
|
11
|
+
When using Swift pods, sometimes theird party dependencies are not built with modular headers enabled. This can cause issues when importing the module in Swift code. This plugin automatically enables modular headers for all dependencies of Swift pods.
|
12
|
+
|
13
|
+
It solves this issue:
|
14
|
+
|
15
|
+
```
|
16
|
+
The Swift pod `name` depends upon `Dependency`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
|
17
|
+
```
|
18
|
+
|
19
|
+
One of the workarounds is to either use static frameworks or enable modular headers globally in the Podfile. This plugin allows you to selectively enable modular headers for dependencies of Swift pods without enabling it globally.
|
20
|
+
|
21
|
+
You could also enable modular headers for a specific dependency by adding `:modular_headers => true` to the pod declaration. This plugin automates this process.
|
22
|
+
|
23
|
+
## How it works
|
24
|
+
|
25
|
+
The plugin hooks into the pre-install phase of the pod install command. It analyzes the pod dependencies and enables modular headers for all dependencies of Swift pods.
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Inside of your project's Gemfile add:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
gem 'cocoapods-swift-modular-headers', :git => 'git@github.com:okwasniewski/cocoapods-swift-modular-headers.git', branch: 'main'
|
33
|
+
```
|
34
|
+
|
35
|
+
Then run:
|
36
|
+
|
37
|
+
```
|
38
|
+
bundle install
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
Inside of your Podfile add:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
plugin 'cocoapods-swift-modular-headers'
|
47
|
+
|
48
|
+
# Above target declarations
|
49
|
+
apply_modular_headers_for_swift_dependencies()
|
50
|
+
```
|
51
|
+
|
52
|
+
And re-run the pod install command. The plugin will automatically enable modular headers for all dependencies of Swift pods.
|
53
|
+
|
54
|
+
If you already have some pre-install hooks, you can add the plugin to the existing hooks:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
plugin 'cocoapods-swift-modular-headers'
|
58
|
+
|
59
|
+
# Above target declarations
|
60
|
+
pre_install do |installer|
|
61
|
+
apply_modular_headers_for_swift_dependencies(installer)
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
For Expo projects, this can be automated by using Expo Config Plugins. (TODO)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-swift-modular-headers/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-swift-modular-headers'
|
8
|
+
spec.version = CocoapodsSwiftModularHeaders::VERSION
|
9
|
+
spec.authors = ['Oskar Kwaśniewski']
|
10
|
+
spec.email = ['oskarkwasniewski@icloud.com']
|
11
|
+
spec.description = 'Automatically enables modular headers for dependencies of Swift pods. Useful for React Native projects.'
|
12
|
+
spec.summary = 'Automatically enables modular headers for dependencies of Swift pods.'
|
13
|
+
spec.homepage = 'https://github.com/okwasniewski/cocoapods-swift-modular-headers'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '>= 2.3'
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cocoapods-core'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Podfile
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
def apply_modular_headers_for_swift_dependencies(installer = nil)
|
8
|
+
if installer.nil?
|
9
|
+
pre_install do |pre_installer|
|
10
|
+
_apply_modular_headers_for_swift_dependencies(pre_installer)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
_apply_modular_headers_for_swift_dependencies(installer)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private def _apply_modular_headers_for_swift_dependencies(installer)
|
18
|
+
Pod::UI.info "[Modular Headers] ".blue << "Enabling modular headers for Swift dependencies ✨"
|
19
|
+
installer.analysis_result.pod_targets.each do |spec|
|
20
|
+
if spec.dependent_targets.empty?
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
if spec.all_files.any? { |file| file.extname == '.swift' }
|
25
|
+
Pod::UI.info "[Modular Headers] ".blue << "Applying modular headers for #{spec}."
|
26
|
+
Pod::UI.info "[Modular Headers] ".blue << "Dependent targets: #{spec.dependent_targets}"
|
27
|
+
spec.dependent_targets.each do |target|
|
28
|
+
root_spec_name = target.name.partition('/').first
|
29
|
+
@current_target_definition.set_use_modular_headers_for_pod(root_spec_name, true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-swift-modular-headers/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-swift-modular-headers/podfile_dsl'
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-swift-modular-headers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oskar Kwaśniewski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
description: Automatically enables modular headers for dependencies of Swift pods.
|
28
|
+
Useful for React Native projects.
|
29
|
+
email:
|
30
|
+
- oskarkwasniewski@icloud.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- cocoapods-swift-modular-headers.gemspec
|
40
|
+
- lib/cocoapods-swift-modular-headers.rb
|
41
|
+
- lib/cocoapods-swift-modular-headers/gem_version.rb
|
42
|
+
- lib/cocoapods-swift-modular-headers/podfile_dsl.rb
|
43
|
+
- lib/cocoapods_plugin.rb
|
44
|
+
homepage: https://github.com/okwasniewski/cocoapods-swift-modular-headers
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.0.3.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Automatically enables modular headers for dependencies of Swift pods.
|
67
|
+
test_files: []
|