From 609442941f6b85c626231b4c03cd356b8d87f984 Mon Sep 17 00:00:00 2001 From: race604 Date: Fri, 25 Dec 2015 20:16:04 +0800 Subject: [PATCH] Upgrade to RN 0.17.0 --- .flowconfig | 39 +++++--- .gitignore | 8 +- MainScreen.android.js | 2 +- StoryItem.js | 5 +- StoryScreen.js | 3 +- WebView.js | 4 +- android/app/app.iml | 47 +++++---- android/app/build.gradle | 95 +++++++++++-------- android/app/proguard-rules.pro | 43 +++++++++ android/app/react.gradle | 87 +++++++++++++++++ .../ReactSwipeRefreshLayoutManager.java | 2 +- .../view/webview/ReactWebViewManager.java | 34 ++----- .../com/race604/zhihu/daily/MainActivity.java | 2 +- .../java/com/rctzhihudaily/MainActivity.java | 78 +++++++++++++++ android/build.gradle | 2 +- ios/RCTZhiHuDaily.xcodeproj/project.pbxproj | 53 +++++++---- ios/RCTZhiHuDaily/AppDelegate.m | 10 +- .../AppIcon.appiconset/Contents.json | 6 +- ios/RCTZhiHuDaily/Info.plist | 2 +- ios/RCTZhiHuDailyTests/RCTZhiHuDailyTests.m | 2 +- package.json | 2 +- 21 files changed, 378 insertions(+), 148 deletions(-) create mode 100644 android/app/react.gradle create mode 100644 android/app/src/main/java/com/rctzhihudaily/MainActivity.java diff --git a/.flowconfig b/.flowconfig index 438e495..71d9905 100644 --- a/.flowconfig +++ b/.flowconfig @@ -7,13 +7,24 @@ # Some modules have their own node_modules with overlap .*/node_modules/node-haste/.* -# Ignore react-tools where there are overlaps, but don't ignore anything that -# react-native relies on -.*/node_modules/react-tools/src/React.js -.*/node_modules/react-tools/src/renderers/shared/event/EventPropagators.js -.*/node_modules/react-tools/src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js -.*/node_modules/react-tools/src/shared/vendor/core/ExecutionEnvironment.js - +# Ugh +.*/node_modules/babel.* +.*/node_modules/babylon.* +.*/node_modules/invariant.* + +# Ignore react and fbjs where there are overlaps, but don't ignore +# anything that react-native relies on +.*/node_modules/fbjs-haste/.*/__tests__/.* +.*/node_modules/fbjs-haste/__forks__/Map.js +.*/node_modules/fbjs-haste/__forks__/Promise.js +.*/node_modules/fbjs-haste/__forks__/fetch.js +.*/node_modules/fbjs-haste/core/ExecutionEnvironment.js +.*/node_modules/fbjs-haste/core/isEmpty.js +.*/node_modules/fbjs-haste/crypto/crc32.js +.*/node_modules/fbjs-haste/stubs/ErrorUtils.js +.*/node_modules/react-haste/React.js +.*/node_modules/react-haste/renderers/dom/ReactDOM.js +.*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js # Ignore commoner tests .*/node_modules/commoner/test/.* @@ -22,7 +33,10 @@ .*/react-tools/node_modules/commoner/lib/reader.js # Ignore jest -.*/react-native/node_modules/jest-cli/.* +.*/node_modules/jest-cli/.* + +# Ignore Website +.*/website/.* [include] @@ -34,13 +48,16 @@ module.system=haste munge_underscores=true +module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' +module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub' + suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-4]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-4]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy [version] -0.14.0 +0.19.0 diff --git a/.gitignore b/.gitignore index a181412..94fc867 100644 --- a/.gitignore +++ b/.gitignore @@ -21,10 +21,12 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace -.idea/ -taskArtifacts/ -local.properties +# Android/IJ +# +.idea +.gradle +local.properties # node.js # diff --git a/MainScreen.android.js b/MainScreen.android.js index aa0b18f..4be4f8e 100644 --- a/MainScreen.android.js +++ b/MainScreen.android.js @@ -71,7 +71,7 @@ var MainScreen = React.createClass({ onActionSelected={this.onActionSelected} /> { this.swipeRefreshLayout = swipeRefreshLayout; }} - onRefresh={this.onRefresh}> + onSwipeRefresh={this.onRefresh}> diff --git a/StoryItem.js b/StoryItem.js index 5de8656..a143278 100644 --- a/StoryItem.js +++ b/StoryItem.js @@ -13,14 +13,11 @@ var { View, } = React; -var precomputeStyle = require('precomputeStyle'); - var TITLE_REF = 'title'; var StoryItem = React.createClass({ updateReadSate: function() { - var nativeProps = precomputeStyle({color: '#777777'}, ['color']); - this.refs[TITLE_REF].setNativeProps(nativeProps); + this.refs[TITLE_REF].setNativeProps({style: {color: '#777777'}}); this.props.onSelect(); }, render: function() { diff --git a/StoryScreen.js b/StoryScreen.js index 5a4d6b6..d9bbf17 100644 --- a/StoryScreen.js +++ b/StoryScreen.js @@ -15,7 +15,6 @@ var { WebView, } = React; -var MyWebView = (Platform.OS === 'ios') ? WebView : require('./WebView'); var DetailToolbar = require('./DetailToolbar'); var BASE_URL = 'http://news.at.zhihu.com/api/4/news/'; @@ -86,7 +85,7 @@ var StoryScreen = React.createClass({ + ''; return ( - diff --git a/WebView.js b/WebView.js index 11dba38..01bf929 100644 --- a/WebView.js +++ b/WebView.js @@ -2,6 +2,7 @@ var React = require('react-native'); var { + View, requireNativeComponent, PropTypes } = React; @@ -27,12 +28,13 @@ class ObservableWebView extends React.Component { } ObservableWebView.propTypes = { + ...View.propTypes, url: PropTypes.string, html: PropTypes.string, css: PropTypes.string, onScrollChange: PropTypes.func, }; -// +// // ObservableWebView.viewConfig = { // uiViewClassName: 'RCTWebView', // validAttributes: ReactNativeViewAttributes.RKView diff --git a/android/app/app.iml b/android/app/app.iml index 8bceb80..9347192 100644 --- a/android/app/app.iml +++ b/android/app/app.iml @@ -65,54 +65,53 @@ - - + - + - - - - - - + + + + + + - - - - - - + + - + - + + + + - - - + + + + + - - + + - + - \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 21ab3c8..c4da3e1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,4 +1,53 @@ -apply plugin: 'com.android.application' +apply plugin: "com.android.application" + +/** + * The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets. + * These basically call `react-native bundle` with the correct arguments during the Android build + * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the + * bundle directly from the development server. Below you can see all the possible configurations + * and their defaults. If you decide to add a configuration block, make sure to add it before the + * `apply from: "react.gradle"` line. + * + * project.ext.react = [ + * // the name of the generated asset file containing your JS bundle + * bundleAssetName: "index.android.bundle", + * + * // the entry file for bundle generation + * entryFile: "index.android.js", + * + * // whether to bundle JS and assets in debug mode + * bundleInDebug: false, + * + * // whether to bundle JS and assets in release mode + * bundleInRelease: true, + * + * // the root of your project, i.e. where "package.json" lives + * root: "../../", + * + * // where to put the JS bundle asset in debug mode + * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", + * + * // where to put the JS bundle asset in release mode + * jsBundleDirRelease: "$buildDir/intermediates/assets/release", + * + * // where to put drawable resources / React Native assets, e.g. the ones you use via + * // require('./image.png')), in debug mode + * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", + * + * // where to put drawable resources / React Native assets, e.g. the ones you use via + * // require('./image.png')), in release mode + * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", + * + * // by default the gradle tasks are skipped if none of the JS files or assets change; this means + * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to + * // date; if you have any other folders that you want to ignore for performance reasons (gradle + * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ + * // for example, you might want to remove it from here. + * inputExcludes: ["android/**", "ios/**"] + * ] + */ + +apply from: "react.gradle" android { compileSdkVersion 23 @@ -14,50 +63,16 @@ android { abiFilters "armeabi-v7a", "x86" } } - - signingConfigs { - release { -// storeFile file(RELEASE_STORE_FILE) -// storePassword RELEASE_STORE_PASSWORD -// keyAlias RELEASE_KEY_ALIAS -// keyPassword RELEASE_KEY_PASSWORD - } - } - buildTypes { release { - signingConfig signingConfigs.release - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + minifyEnabled false // Set this to true to enable Proguard + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.1' - compile 'com.facebook.react:react-native:0.12.+' + compile fileTree(dir: "libs", include: ["*.jar"]) + compile "com.android.support:appcompat-v7:23.0.1" + compile "com.facebook.react:react-native:0.17.+" } - -final def TARGET_BUNDLE_DIR = 'app/src/main/assets/' -final def TARGET_BUNDLE_FILE = 'index.android.bundle' -final def DOWNLOAD_URL = 'http://localhost:8081/index.android.bundle?platform=android&dev=false&minify=true' - -task downloadJSBundle << { - def dir = new File(TARGET_BUNDLE_DIR) - if (!dir.exists()) { - dir.mkdirs() - } - def f = new File(TARGET_BUNDLE_DIR + TARGET_BUNDLE_FILE) - if (f.exists()) { - f.delete() - } - try { - new URL(DOWNLOAD_URL).withInputStream{ i -> f.withOutputStream{ it << i }} - } catch (Exception e) { - e.printStackTrace() - } - -} - -preBuild.dependsOn downloadJSBundle diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index a92fa17..ffa8c9f 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -15,3 +15,46 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + +# Disabling obfuscation is useful if you collect stack traces from production crashes +# (unless you are using a system that supports de-obfuscate the stack traces). +-dontobfuscate + +# React Native + +# Keep our interfaces so they can be used by other ProGuard rules. +# See http://sourceforge.net/p/proguard/bugs/466/ +-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip +-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters + +# Do not strip any method/class that is annotated with @DoNotStrip +-keep @com.facebook.proguard.annotations.DoNotStrip class * +-keepclassmembers class * { + @com.facebook.proguard.annotations.DoNotStrip *; +} + +-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { + void set*(***); + *** get*(); +} + +-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } +-keep class * extends com.facebook.react.bridge.NativeModule { *; } +-keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } +-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp ; } +-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup ; } + +# okhttp + +-keepattributes Signature +-keepattributes *Annotation* +-keep class com.squareup.okhttp.** { *; } +-keep interface com.squareup.okhttp.** { *; } +-dontwarn com.squareup.okhttp.** + +# okio + +-keep class sun.misc.Unsafe { *; } +-dontwarn java.nio.file.* +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement +-dontwarn okio.** diff --git a/android/app/react.gradle b/android/app/react.gradle new file mode 100644 index 0000000..9668e71 --- /dev/null +++ b/android/app/react.gradle @@ -0,0 +1,87 @@ +import org.apache.tools.ant.taskdefs.condition.Os + +def config = project.hasProperty("react") ? project.react : []; + +def bundleAssetName = config.bundleAssetName ?: "index.android.bundle" +def entryFile = config.entryFile ?: "index.android.js" + +// because elvis operator +def elvisFile(thing) { + return thing ? file(thing) : null; +} + +def reactRoot = elvisFile(config.root) ?: file("../../") +def jsBundleDirDebug = elvisFile(config.jsBundleDirDebug) ?: + file("$buildDir/intermediates/assets/debug") +def jsBundleDirRelease = elvisFile(config.jsBundleDirRelease) ?: + file("$buildDir/intermediates/assets/release") +def resourcesDirDebug = elvisFile(config.resourcesDirDebug) ?: + file("$buildDir/intermediates/res/merged/debug") +def resourcesDirRelease = elvisFile(config.resourcesDirRelease) ?: + file("$buildDir/intermediates/res/merged/release") +def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"] + +def jsBundleFileDebug = file("$jsBundleDirDebug/$bundleAssetName") +def jsBundleFileRelease = file("$jsBundleDirRelease/$bundleAssetName") + +task bundleDebugJsAndAssets(type: Exec) { + // create dirs if they are not there (e.g. the "clean" task just ran) + doFirst { + jsBundleDirDebug.mkdirs() + resourcesDirDebug.mkdirs() + } + + // set up inputs and outputs so gradle can cache the result + inputs.files fileTree(dir: reactRoot, excludes: inputExcludes) + outputs.dir jsBundleDirDebug + outputs.dir resourcesDirDebug + + // set up the call to the react-native cli + workingDir reactRoot + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file", + entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug + } else { + commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file", + entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug + } + + enabled config.bundleInDebug ?: true +} + +task bundleReleaseJsAndAssets(type: Exec) { + // create dirs if they are not there (e.g. the "clean" task just ran) + doFirst { + jsBundleDirRelease.mkdirs() + resourcesDirRelease.mkdirs() + } + + // set up inputs and outputs so gradle can cache the result + inputs.files fileTree(dir: reactRoot, excludes: inputExcludes) + outputs.dir jsBundleDirRelease + outputs.dir resourcesDirRelease + + // set up the call to the react-native cli + workingDir reactRoot + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine "cmd","/c", "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file", + entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease + } else { + commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file", + entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease + } + + enabled config.bundleInRelease ?: true +} + +gradle.projectsEvaluated { + // hook bundleDebugJsAndAssets into the android build process + bundleDebugJsAndAssets.dependsOn mergeDebugResources + bundleDebugJsAndAssets.dependsOn mergeDebugAssets + processDebugResources.dependsOn bundleDebugJsAndAssets + + // hook bundleReleaseJsAndAssets into the android build process + bundleReleaseJsAndAssets.dependsOn mergeReleaseResources + bundleReleaseJsAndAssets.dependsOn mergeReleaseAssets + processReleaseResources.dependsOn bundleReleaseJsAndAssets +} diff --git a/android/app/src/main/java/com/race604/react/view/swiperefresh/ReactSwipeRefreshLayoutManager.java b/android/app/src/main/java/com/race604/react/view/swiperefresh/ReactSwipeRefreshLayoutManager.java index 1d86a9b..86b2df1 100644 --- a/android/app/src/main/java/com/race604/react/view/swiperefresh/ReactSwipeRefreshLayoutManager.java +++ b/android/app/src/main/java/com/race604/react/view/swiperefresh/ReactSwipeRefreshLayoutManager.java @@ -76,7 +76,7 @@ public void receiveCommand(ReactSwipeRefreshLayout root, int commandId, @Override public Map getExportedCustomDirectEventTypeConstants() { return MapBuilder.of( - RefreshEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRefresh")); + RefreshEvent.EVENT_NAME, MapBuilder.of("registrationName", "onSwipeRefresh")); } @Override diff --git a/android/app/src/main/java/com/race604/react/view/webview/ReactWebViewManager.java b/android/app/src/main/java/com/race604/react/view/webview/ReactWebViewManager.java index 33b6a52..143354a 100644 --- a/android/app/src/main/java/com/race604/react/view/webview/ReactWebViewManager.java +++ b/android/app/src/main/java/com/race604/react/view/webview/ReactWebViewManager.java @@ -1,6 +1,8 @@ package com.race604.react.view.webview; +import com.facebook.react.bridge.ReactMethod; import com.facebook.react.uimanager.CatalystStylesDiffMap; +import com.facebook.react.uimanager.ReactProp; import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.UIProp; @@ -12,15 +14,6 @@ public class ReactWebViewManager extends SimpleViewManager { public static final String REACT_CLASS = "RCTWebView"; - @UIProp(UIProp.Type.STRING) - public static final String PROP_URL = "url"; - - @UIProp(UIProp.Type.STRING) - public static final String PROP_HTML = "html"; - - @UIProp(UIProp.Type.STRING) - public static final String PROP_CSS = "css"; - @Override public String getName() { return REACT_CLASS; @@ -31,21 +24,14 @@ protected ObservableWebView createViewInstance(ThemedReactContext reactContext) return new ObservableWebView(reactContext); } - @Override - public void updateView(final ObservableWebView webView, CatalystStylesDiffMap props) { - super.updateView(webView, props); - if (props.hasKey(PROP_URL)) { - webView.loadUrl(props.getString(PROP_URL)); - } - - if (props.hasKey(PROP_HTML)) { - String html = props.getString(PROP_HTML); - if (props.hasKey(PROP_CSS)) { - String css = props.getString(PROP_CSS); - html = "" + html; - } - webView.loadData(html, "text/html; charset=utf-8", "UTF-8"); - } + @ReactProp(name = "url") + public void setUrl(final ObservableWebView webView, String url) { + webView.loadUrl(url); + } + @ReactProp(name = "html") + public void setHtml(final ObservableWebView webView, String html) { + webView.loadData(html, "text/html; charset=utf-8", "UTF-8"); } + } diff --git a/android/app/src/main/java/com/race604/zhihu/daily/MainActivity.java b/android/app/src/main/java/com/race604/zhihu/daily/MainActivity.java index 689769a..ea8b93f 100644 --- a/android/app/src/main/java/com/race604/zhihu/daily/MainActivity.java +++ b/android/app/src/main/java/com/race604/zhihu/daily/MainActivity.java @@ -75,7 +75,7 @@ protected void onResume() { super.onResume(); if (mReactInstanceManager != null) { - mReactInstanceManager.onResume(this); + mReactInstanceManager.onResume(this, this); } } diff --git a/android/app/src/main/java/com/rctzhihudaily/MainActivity.java b/android/app/src/main/java/com/rctzhihudaily/MainActivity.java new file mode 100644 index 0000000..a3a09f6 --- /dev/null +++ b/android/app/src/main/java/com/rctzhihudaily/MainActivity.java @@ -0,0 +1,78 @@ +package com.rctzhihudaily; + +import android.app.Activity; +import android.os.Bundle; +import android.view.KeyEvent; + +import com.facebook.react.LifecycleState; +import com.facebook.react.ReactInstanceManager; +import com.facebook.react.ReactRootView; +import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; +import com.facebook.react.shell.MainReactPackage; +import com.facebook.soloader.SoLoader; + +public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { + + private ReactInstanceManager mReactInstanceManager; + private ReactRootView mReactRootView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mReactRootView = new ReactRootView(this); + + mReactInstanceManager = ReactInstanceManager.builder() + .setApplication(getApplication()) + .setBundleAssetName("index.android.bundle") + .setJSMainModuleName("index.android") + .addPackage(new MainReactPackage()) + .setUseDeveloperSupport(BuildConfig.DEBUG) + .setInitialLifecycleState(LifecycleState.RESUMED) + .build(); + + mReactRootView.startReactApplication(mReactInstanceManager, "RCTZhiHuDaily", null); + + setContentView(mReactRootView); + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) { + mReactInstanceManager.showDevOptionsDialog(); + return true; + } + return super.onKeyUp(keyCode, event); + } + + @Override + public void onBackPressed() { + if (mReactInstanceManager != null) { + mReactInstanceManager.onBackPressed(); + } else { + super.onBackPressed(); + } + } + + @Override + public void invokeDefaultOnBackPressed() { + super.onBackPressed(); + } + + @Override + protected void onPause() { + super.onPause(); + + if (mReactInstanceManager != null) { + mReactInstanceManager.onPause(); + } + } + + @Override + protected void onResume() { + super.onResume(); + + if (mReactInstanceManager != null) { + mReactInstanceManager.onResume(this, this); + } + } +} diff --git a/android/build.gradle b/android/build.gradle index 32bc6f5..ccdfc4e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:1.3.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/ios/RCTZhiHuDaily.xcodeproj/project.pbxproj b/ios/RCTZhiHuDaily.xcodeproj/project.pbxproj index 24da173..929fbe7 100644 --- a/ios/RCTZhiHuDaily.xcodeproj/project.pbxproj +++ b/ios/RCTZhiHuDaily.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 008F07F21AC5B25A0029DE68 /* main.jsbundle */; }; 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; @@ -106,17 +105,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; + 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = main.jsbundle; sourceTree = ""; }; + 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = ""; }; + 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = ""; }; + 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = ""; }; + 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = ""; }; + 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = ""; }; 00E356EE1AD99517003FC87E /* RCTZhiHuDailyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RCTZhiHuDailyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* RCTZhiHuDailyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTZhiHuDailyTests.m; sourceTree = ""; }; - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; + 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = ""; }; + 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* RCTZhiHuDaily.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RCTZhiHuDaily.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RCTZhiHuDaily/AppDelegate.h; sourceTree = ""; }; 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = RCTZhiHuDaily/AppDelegate.m; sourceTree = ""; }; @@ -124,9 +123,9 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = RCTZhiHuDaily/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RCTZhiHuDaily/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RCTZhiHuDaily/main.m; sourceTree = ""; }; - 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; + 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../node_modules/react-native/React/React.xcodeproj; sourceTree = ""; }; + 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = ""; }; + 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -334,6 +333,7 @@ 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, + 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, ); buildRules = ( ); @@ -350,7 +350,6 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0610; ORGANIZATIONNAME = Facebook; TargetAttributes = { @@ -506,7 +505,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, ); @@ -514,6 +512,24 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Bundle React Native code and images"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "../node_modules/react-native/packager/react-native-xcode.sh"; + showEnvVarsInLog = 1; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 00E356EA1AD99517003FC87E /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -596,19 +612,16 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; DEAD_CODE_STRIPPING = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", ); - INFOPLIST_FILE = RCTZhiHuDaily/Info.plist; + INFOPLIST_FILE = "RCTZhiHuDaily/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTZhiHuDaily; - SWIFT_OBJC_BRIDGING_HEADER = "RCTZhiHuDaily-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; @@ -616,17 +629,15 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", ); - INFOPLIST_FILE = RCTZhiHuDaily/Info.plist; + INFOPLIST_FILE = "RCTZhiHuDaily/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTZhiHuDaily; - SWIFT_OBJC_BRIDGING_HEADER = "RCTZhiHuDaily-Bridging-Header.h"; }; name = Release; }; diff --git a/ios/RCTZhiHuDaily/AppDelegate.m b/ios/RCTZhiHuDaily/AppDelegate.m index 7be8186..4e035d0 100644 --- a/ios/RCTZhiHuDaily/AppDelegate.m +++ b/ios/RCTZhiHuDaily/AppDelegate.m @@ -35,12 +35,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( /** * OPTION 2 - * Load from pre-bundled file on disk. To re-generate the static bundle - * from the root of your project directory, run - * - * $ react-native bundle --minify - * - * see http://facebook.github.io/react-native/docs/runningondevice.html + * Load from pre-bundled file on disk. The static bundle is automatically + * generated by "Bundle React Native code and images" build step. */ // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; @@ -51,7 +47,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( launchOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [[UIViewController alloc] init]; + UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; diff --git a/ios/RCTZhiHuDaily/Images.xcassets/AppIcon.appiconset/Contents.json b/ios/RCTZhiHuDaily/Images.xcassets/AppIcon.appiconset/Contents.json index 9a5da7b..118c98f 100644 --- a/ios/RCTZhiHuDaily/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/RCTZhiHuDaily/Images.xcassets/AppIcon.appiconset/Contents.json @@ -21,15 +21,13 @@ "scale" : "3x" }, { - "size" : "60x60", "idiom" : "iphone", - "filename" : "ic_launcher.png", + "size" : "60x60", "scale" : "2x" }, { - "size" : "60x60", "idiom" : "iphone", - "filename" : "ic_launcher-1.png", + "size" : "60x60", "scale" : "3x" } ], diff --git a/ios/RCTZhiHuDaily/Info.plist b/ios/RCTZhiHuDaily/Info.plist index cddf076..91963b2 100644 --- a/ios/RCTZhiHuDaily/Info.plist +++ b/ios/RCTZhiHuDaily/Info.plist @@ -40,7 +40,7 @@ NSAppTransportSecurity - + NSAllowsArbitraryLoads diff --git a/ios/RCTZhiHuDailyTests/RCTZhiHuDailyTests.m b/ios/RCTZhiHuDailyTests/RCTZhiHuDailyTests.m index e64f169..a5645b7 100644 --- a/ios/RCTZhiHuDailyTests/RCTZhiHuDailyTests.m +++ b/ios/RCTZhiHuDailyTests/RCTZhiHuDailyTests.m @@ -42,7 +42,7 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; - RCTSetLogFunction(^(RCTLogLevel level, NSString *fileName, NSNumber *lineNumber, NSString *message) { + RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { redboxError = message; } diff --git a/package.json b/package.json index 9f13be8..b0e3bda 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "start": "node_modules/react-native/packager/packager.sh" }, "dependencies": { - "react-native": "^0.12.0", + "react-native": "^0.17.0", "react-native-drawer": "^1.4.2", "react-native-viewpager": "^0.1.0", "react-timer-mixin": "^0.13.3"