iOS: Install resources from app manifest (#22)

This commit is contained in:
Tommy Nguyen 2020-03-19 18:42:09 +01:00 коммит произвёл GitHub
Родитель 3132b8ab10
Коммит 1c073b7b38
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 41 добавлений и 32 удалений

Просмотреть файл

@ -1,20 +0,0 @@
require 'json'
package = JSON.parse(File.read(File.join('..', 'package.json')))
Pod::Spec.new do |s|
s.name = 'Example-dev'
s.version = package['version']
s.author = { package['author']['name'] => package['author']['email'] }
s.license = package['license']
s.homepage = package['homepage']
s.source = { :git => package['repository']['url'] }
s.summary = 'Assets for Example app'
s.ios.deployment_target = '12.0'
s.dependency 'React'
s.resources = ['dist/assets', 'dist/main.jsbundle']
s.preserve_paths = 'dist/*'
end

Просмотреть файл

@ -3,10 +3,6 @@ require_relative 'node_modules/react-native-test-app/test_app.rb'
workspace 'Example.xcworkspace'
use_test_app!(__dir__) do |target|
target.app do
pod 'Example-dev', :path => '.'
end
target.tests do
pod 'Example-Tests', :path => '.'
end

Просмотреть файл

@ -1,8 +1,6 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- Example-dev (0.0.4):
- React
- Example-Tests (0.0.4):
- React
- Folly (2018.10.22.00):
@ -85,12 +83,12 @@ PODS:
- React-RCTWebSocket (0.60.6):
- React-Core (= 0.60.6)
- ReactTestApp-DevSupport (0.0.4)
- ReactTestApp-Resources (1.0.0-dev)
- SwiftLint (0.39.1)
- yoga (0.60.6.React)
DEPENDENCIES:
- DoubleConversion (from `node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- Example-dev (from `.`)
- Example-Tests (from `.`)
- Folly (from `node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `node_modules/react-native/third-party-podspecs/glog.podspec`)
@ -113,6 +111,7 @@ DEPENDENCIES:
- React-RCTVibration (from `node_modules/react-native/Libraries/Vibration`)
- React-RCTWebSocket (from `node_modules/react-native/Libraries/WebSocket`)
- ReactTestApp-DevSupport (from `./..`)
- ReactTestApp-Resources (from `.`)
- SwiftLint
- yoga (from `node_modules/react-native/ReactCommon/yoga`)
@ -125,8 +124,6 @@ SPEC REPOS:
EXTERNAL SOURCES:
DoubleConversion:
:podspec: node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
Example-dev:
:path: "."
Example-Tests:
:path: "."
Folly:
@ -169,13 +166,14 @@ EXTERNAL SOURCES:
:path: node_modules/react-native/Libraries/WebSocket
ReactTestApp-DevSupport:
:path: "./.."
ReactTestApp-Resources:
:path: "."
yoga:
:path: node_modules/react-native/ReactCommon/yoga
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
Example-dev: 671a30b61ca00c75363c12b33c3e02a76f0ce7cc
Example-Tests: 25caeb33c2a613595303e520bb87825315f2cad1
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
@ -198,9 +196,10 @@ SPEC CHECKSUMS:
React-RCTVibration: 7655d72dfb919dd6d8e135ca108a5a2bd9fcd7b4
React-RCTWebSocket: 7cd2c8d0f8ddd680dc76404defba7ab1f56b83af
ReactTestApp-DevSupport: 92a89c66c797f342e631955e4f3c67e0ae1d2690
ReactTestApp-Resources: 18abf3923397be7cd4eb2e247e954dcbf5b687e6
SwiftLint: 55e96a4a4d537d4a3156859fc1c54bd24851a046
yoga: 5079887aa3e4c62142d6bcee493022643ee4d730
PODFILE CHECKSUM: 85a755427665fbfcea1470614e0c2fc5f1d45553
PODFILE CHECKSUM: 0aa832921b7f3f2eb406b9c1dd66a2089b899e07
COCOAPODS: 1.8.4

Просмотреть файл

@ -5,5 +5,9 @@
"Example": {
"displayName": "App"
}
}
},
"resources": [
"dist/assets",
"dist/main.jsbundle"
]
}

Просмотреть файл

@ -15,6 +15,32 @@ def resolve_module(request)
Pod::Executable.execute_command('node', ['-e', script], true).strip
end
def resources_pod(package_root, current_dir = package_root)
return if File.expand_path(current_dir) == '/'
app_manifest = File.join(current_dir, 'app.json')
return resources_pod(package_root, File.join(current_dir, '..')) if !File.exist?(app_manifest)
resources = JSON.parse(File.read(app_manifest))['resources']
return if !resources.instance_of? Array or resources.empty?
spec = {
'name' => 'ReactTestApp-Resources',
'version' => '1.0.0-dev',
'summary' => 'Resources for ReactTestApp',
'homepage' => 'https://github.com/microsoft/react-native-test-app',
'license' => 'Unlicense',
'authors' => '@microsoft/react-native-test-app',
'source' => { 'git' => 'https://github.com/microsoft/react-native-test-app.git' },
'resources' => resources
}
podspec_path = File.join(current_dir, 'ReactTestApp-Resources.podspec.json')
File.write(podspec_path, spec.to_json())
at_exit { File.delete(podspec_path) }
Pathname.new(current_dir).relative_path_from(package_root).to_s()
end
def use_test_app!(package_root)
platform :ios, '12.0'
@ -82,6 +108,10 @@ def use_test_app!(package_root)
pod 'glog', :podspec => "#{react_native}/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "#{react_native}/third-party-podspecs/Folly.podspec"
if resources_pod_path = resources_pod(package_root)
pod 'ReactTestApp-Resources', :path => resources_pod_path
end
yield ReactTestAppTargets.new(self) if block_given?
use_native_modules! '.'