Skip to content

Commit d659070

Browse files
authored
fix: Always copy 'app.json' (#138)
1 parent 518cca5 commit d659070

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Lint/UnusedMethodArgument:
1313
Metrics/AbcSize:
1414
Enabled: false
1515

16+
Metrics/BlockLength:
17+
Enabled: false
18+
1619
Metrics/ClassLength:
1720
Enabled: false
1821

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ SPEC CHECKSUMS:
353353
React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad
354354
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
355355
ReactTestApp-DevSupport: 1aee56d5c69fe4a4f4d5be0cbd3f22f5326d70fd
356-
ReactTestApp-Resources: 6d92ddc0b2da071656efa3b828d8ad341b3cbb1d
356+
ReactTestApp-Resources: 5950ae44720217c6778ff03fb1d906c8fb3ce483
357357
SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447
358358
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
359359

ios/ReactTestApp/Manifest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Manifest: Codable {
1919
let components: [Component]
2020

2121
static func fromFile() -> Manifest? {
22-
guard let manifestURL = Bundle.main.url(forResource: "app", withExtension: "json", subdirectory: "assets"),
22+
guard let manifestURL = Bundle.main.url(forResource: "app", withExtension: "json"),
2323
let data = try? Data(contentsOf: manifestURL, options: .uncached) else {
2424
return nil
2525
}

ios/test_app.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def resources_pod(project_root, target_platform)
9191
app_manifest = find_file('app.json', project_root)
9292
return if app_manifest.nil?
9393

94-
resources = resolve_resources(JSON.parse(File.read(app_manifest)), target_platform)
95-
return if !resources.instance_of?(Array) || resources.empty?
94+
manifest_resources = resolve_resources(JSON.parse(File.read(app_manifest)), target_platform)
95+
resources = ['app.json'] + (manifest_resources.instance_of?(Array) ? manifest_resources : [])
9696

9797
spec = {
9898
'name' => 'ReactTestApp-Resources',

test/test_test_app.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ def test_react_native_pods
112112
assert_nil(resources_pod(Pathname.new('/'), target))
113113
assert_nil(resources_pod(Pathname.new('.'), target))
114114

115-
assert_nil(resources_pod(fixture_path('without_resources'), target))
116-
assert_nil(resources_pod(fixture_path('without_resources', target.to_s), target))
115+
assert_equal('.', resources_pod(fixture_path('without_resources'), target))
116+
assert_equal('..', resources_pod(fixture_path('without_resources', target.to_s), target))
117117

118-
assert_nil(resources_pod(fixture_path('without_platform_resources'), target))
119-
assert_nil(resources_pod(fixture_path('without_platform_resources', target.to_s), target))
118+
assert_equal('.', resources_pod(fixture_path('without_platform_resources'), target))
119+
assert_equal('..',
120+
resources_pod(fixture_path('without_platform_resources', target.to_s), target))
120121

121122
assert_equal('.', resources_pod(fixture_path('with_resources'), target))
122123
assert_equal('..', resources_pod(fixture_path('with_resources', target.to_s), target))
@@ -129,25 +130,30 @@ def test_react_native_pods
129130

130131
%i[ios macos].each do |target|
131132
define_method("test_#{target}_resources_pod_writes_podspec") do
132-
resources = %w[dist/assets dist/main.jsbundle]
133-
platform_resources = ["dist-#{target}/assets", "dist-#{target}/main.jsbundle"]
133+
resources = %w[app.json dist/assets dist/main.jsbundle]
134+
platform_resources = ['app.json', "dist-#{target}/assets", "dist-#{target}/main.jsbundle"]
134135

135136
[
136-
fixture_path('with_resources'),
137-
fixture_path('with_resources', target.to_s),
138137
fixture_path('with_platform_resources'),
139138
fixture_path('with_platform_resources', target.to_s),
139+
fixture_path('with_resources'),
140+
fixture_path('with_resources', target.to_s),
141+
fixture_path('without_platform_resources'),
142+
fixture_path('without_platform_resources', target.to_s),
143+
fixture_path('without_resources'),
144+
fixture_path('without_resources', target.to_s),
140145
].each do |project_root|
141146
podspec_path = resources_pod(project_root, target)
142147
manifest_path = app_manifest_path(project_root, podspec_path)
143148
manifest = JSON.parse(File.read(manifest_path))
144149

145-
if project_root.to_s.include?('with_platform_resources')
150+
if project_root.to_s.include?('without')
151+
assert_equal(['app.json'], manifest['resources'])
152+
elsif project_root.to_s.include?('with_platform_resources')
146153
assert_equal(platform_resources, manifest['resources'].sort)
147154
else
148155
assert_equal(resources, manifest['resources'].sort)
149156
end
150-
151157
ensure
152158
File.delete(manifest_path)
153159
end

0 commit comments

Comments
 (0)