cocoapods-catalyst-support 0.1.3 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1f833764d39773ee4e3e3b5be81215835fc8a3501cfd0f5000972dfd08afabc
4
- data.tar.gz: 7f822e9e33d5235bfdb455bfdb6e1f7e524d41a804c018621da5effcf2f99fa2
3
+ metadata.gz: 2142505718e484e2b6118079ea9518282e736339bfe460434f2e66c6f5010fe8
4
+ data.tar.gz: 11dde92e0e9cc17f90911c5cdb276bf299bd3428d8e6ded0918eee7641230fbd
5
5
  SHA512:
6
- metadata.gz: 6d006b28d1b79487861758c2b8ad660cc8b8b3b0e9b08b21568bff67c1579971d3711ebc490ab6e14c8c2bdcfab164c11de9c44e9ce9c3e30ebbcc6dad463c2e
7
- data.tar.gz: 49b0a82aaa39d7ee89285e467e26848fb11f57f48ac32bb8e5d03b9354c5ffc553dd47d0dcdd0edb4cd3c2374aa2a9d5a18fdd9d2c077e2874975e5c07792536
6
+ metadata.gz: 9c7c155c89f9858caa0c9affdcafa503d7ca916dc3a78eafaf1a22a1cca1203b17af3d5afbbc9624f7f407e678578941ecbd9a8e4bf4eb0f47e6e7986c2ed0b9
7
+ data.tar.gz: 0f06f4ef84fb5be114a7ac4e14532f7d05255714567e4245094630c33083c88f7d400597e4aa28fe0638b52a871744f2fc63a638b98797acc8c2b78d155ac418
@@ -1,3 +1,3 @@
1
1
  module CocoapodsCatalystSupport
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -36,7 +36,7 @@ module Pod
36
36
  pod_names_to_keep = recursive_dependencies(pod_names_to_keep)
37
37
  pod_targets_to_keep = pod_targets.filter do |pod| pod_names_to_keep.include? pod.module_name end # PodTarget
38
38
 
39
- pod_names_to_remove = recursive_dependencies(pod_names_to_remove).filter do |name| !pod_names_to_keep.include? name end
39
+ pod_names_to_remove = recursive_dependencies(pod_names_to_remove).filter do |name| !pod_names_to_keep.include? name end.to_set.to_a
40
40
  pod_targets_to_remove = pod_targets.filter do |pod| pod_names_to_remove.include? pod.module_name end # PodTarget
41
41
 
42
42
  loggs "\n#### Unsupported Libraries ####\n#{pod_names_to_remove}\n"
@@ -53,9 +53,7 @@ module Pod
53
53
  dependencies_to_remove = dependencies_to_remove + targets_to_remove.flat_map do |target| target.to_dependency end + pod_targets_to_remove.flat_map do |pod| pod.vendor_products + pod.frameworks end
54
54
  dependencies_to_remove = dependencies_to_remove.filter do |d| !dependencies_to_keep.include? d end
55
55
 
56
- ###### CATALYST NOT SUPPORTED LINKS ######
57
- unsupported_links = dependencies_to_remove.map do |d| d.link end.to_set.to_a
58
-
56
+ ###### CATALYST NOT SUPPORTED LINKS ######
59
57
  loggs "\n#### Unsupported dependencies ####\n"
60
58
  loggs "#{dependencies_to_remove.map do |d| d.name end.to_set.to_a }\n\n"
61
59
 
@@ -71,7 +69,7 @@ module Pod
71
69
 
72
70
  ###### OTHER LINKER FLAGS -> to iphone* ######
73
71
  loggs "#### Flagging unsupported libraries ####"
74
- pods_project.targets.filter do |target| target.platform_name == OSPlatform.ios.name end.each do |target| target.flag_libraries unsupported_links, keep_platform end
72
+ pods_project.targets.filter do |target| target.platform_name == OSPlatform.ios.name end.each do |target| target.flag_libraries dependencies_to_remove.to_set.to_a, keep_platform end
75
73
 
76
74
  ###### BUILD_PHASES AND DEPENDENCIES -> PLATFORM_FILTER 'ios' ######
77
75
  loggs "\n#### Filtering build phases ####"
@@ -14,27 +14,73 @@ module Xcodeproj::Project::Object
14
14
 
15
15
  ###### STEP 3 ######
16
16
  # If any unsupported library, then flag as platform-dependant for every build configuration
17
- def flag_libraries libraries, platform
17
+ def flag_libraries dependencies, platform
18
18
  loggs "\tTarget: #{name}"
19
- build_configurations.filter do |config| !config.base_configuration_reference.nil?
19
+
20
+ build_configurations.filter do |config|
21
+ !config.base_configuration_reference.nil?
20
22
  end.each do |config|
21
23
  loggs "\t\tScheme: #{config.name}"
22
24
  xcconfig_path = config.base_configuration_reference.real_path
23
25
  xcconfig = File.read(xcconfig_path)
24
-
26
+
27
+ other_ldflags = xcconfig.filter_lines do |line| line.include? 'OTHER_LDFLAGS = ' end.first || ''
28
+ header_search_paths = xcconfig.filter_lines do |line| line.include? 'HEADER_SEARCH_PATHS = ' end.first || ''
29
+ framework_search_paths = xcconfig.filter_lines do |line| line.include? 'FRAMEWORK_SEARCH_PATHS = ' end.first || ''
30
+ other_swift_flags = xcconfig.filter_lines do |line| line.include? 'OTHER_SWIFT_FLAGS = ' end.first || ''
31
+
32
+ new_other_ldflags = "OTHER_LDFLAGS[sdk=#{platform.sdk}] = $(inherited) -ObjC"
33
+ new_header_search_paths = "HEADER_SEARCH_PATHS[sdk=#{platform.sdk}] = $(inherited)"
34
+ new_framework_search_paths = "FRAMEWORK_SEARCH_PATHS[sdk=#{platform.sdk}] = $(inherited)"
35
+ new_other_swift_flags = "OTHER_SWIFT_FLAGS[sdk=#{platform.sdk}] = $(inherited) -D COCOAPODS"
36
+ new_xcconfig = xcconfig.gsub!(other_ldflags, '').gsub!(header_search_paths, '').gsub!(other_swift_flags, '').gsub!(framework_search_paths, '')
37
+
25
38
  changed = false
26
- libraries.each do |framework|
27
- if xcconfig.include? framework
28
- xcconfig.gsub!(framework, '')
29
- unless xcconfig.include? "OTHER_LDFLAGS[sdk=#{platform.sdk}]"
30
- changed = true
31
- xcconfig += "\nOTHER_LDFLAGS[sdk=#{platform.sdk}] = $(inherited) -ObjC "
39
+ dependencies.each do |dependency|
40
+ if other_ldflags.include? dependency.link
41
+ other_ldflags.gsub! dependency.link, ''
42
+ changed = true
43
+ new_other_ldflags += " #{dependency.link}"
44
+ end
45
+
46
+ regex = /(?<=[\s])([\"]*[\S]*#{Regexp.escape(dependency.name)}[\S]*[\"]*)(?=[\s]?)/
47
+ if header_search_paths.match? regex
48
+ to_replace = header_search_paths.scan(regex).flat_map do |m| m end.filter do |m| !m.nil? && !m.empty? end.each do |to_replace|
49
+ header_search_paths.gsub! to_replace, ''
50
+ new_header_search_paths += " #{to_replace}"
32
51
  end
33
- xcconfig += framework + ' '
52
+ changed = true
53
+ end
54
+
55
+ regex = /(?<=[\s])([\"][\S]*#{Regexp.escape(dependency.name)}[\S]*\")(?=[\s]?)/
56
+ if framework_search_paths.match? regex
57
+ to_replace = framework_search_paths.scan(regex).flat_map do |m| m end.filter do |m| !m.nil? && !m.empty? end.each do |to_replace|
58
+ framework_search_paths.gsub! to_replace, ''
59
+ new_framework_search_paths += " #{to_replace}"
60
+ end
61
+ changed = true
62
+ end
63
+
64
+ regex = /(?<=[\s])(-Xcc -[\S]*#{Regexp.escape(dependency.name)}[\S]*\")(?=[\s]?)/
65
+ if other_swift_flags.match? regex
66
+ to_replace = other_swift_flags.scan(regex).flat_map do |m| m end.filter do |m| !m.nil? && !m.empty? end.each do |to_replace|
67
+ other_swift_flags.gsub! to_replace, ''
68
+ new_other_swift_flags += " #{to_replace}"
69
+ end
70
+ changed = true
34
71
  end
35
72
  end
36
73
 
37
- File.open(xcconfig_path, "w") { |file| file << xcconfig }
74
+ if changed
75
+ new_xcconfig += "\n#{other_ldflags}\n#{framework_search_paths}\n#{header_search_paths}"
76
+ new_xcconfig += "\n#{new_other_ldflags}\n#{new_framework_search_paths}\n#{new_header_search_paths}"
77
+ if !other_swift_flags.empty?
78
+ new_xcconfig += "\n#{other_swift_flags}\n#{new_other_swift_flags}"
79
+ end
80
+ new_xcconfig.gsub! /\n+/, "\n"
81
+ new_xcconfig.gsub! /[ ]+/, " "
82
+ File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
83
+ end
38
84
  loggs "\t\t\t#{changed ? "Succeded" : "Nothing to flag"}"
39
85
  end
40
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-catalyst-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fermoya
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -96,7 +96,7 @@ homepage: https://github.com/fermoya/cocoapods-catalyst-support
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -111,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.0.3
115
- signing_key:
114
+ rubygems_version: 3.2.27
115
+ signing_key:
116
116
  specification_version: 4
117
117
  summary: Many libraries you may use for iOS won't compile for your macCatalyst App,
118
118
  thus, making porting your App to the Mac world more difficult than initially expected.