Skip to content

Commit 7be16b9

Browse files
authored
Merge pull request #155 from mockingbot/manage-native-deps-with-cocoapods
Manage native deps with cocoapods
2 parents 74c00e1 + 14397de commit 7be16b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3264
-16942
lines changed

.eslintrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
"extends": [
33
"standard",
44
"plugin:react/recommended"
5-
],
6-
"plugins": ["jest"],
7-
"env": {
8-
"jest/globals": true
9-
}
5+
]
106
}

README.md

Lines changed: 23 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,34 @@
1-
# React Native Zip Archive [![npm](https://img.shields.io/npm/dm/react-native-zip-archive.svg)](https://www.npmjs.com/package/react-native-zip-archive) [![npm](https://img.shields.io/npm/v/react-native-zip-archive.svg)](https://www.npmjs.com/package/react-native-zip-archive)
1+
# React Native Zip Archive [![npm](https://img.shields.io/npm/v/react-native-zip-archive.svg)](https://www.npmjs.com/package/react-native-zip-archive)
22

33
Zip archive utility for react-native
44

5-
# IMPORTANT
65

7-
For react-native < 0.58, use [email protected]
8-
For react-native >= 0.58, use [email protected]
6+
## Compatibility
7+
8+
| react-native version | react-native-zip-archive version |
9+
| --- | --- |
10+
| ^0.60 | ^5.0.0 |
11+
| ^0.58 | ^4.0.0 |
12+
| <0.58 | ^3.0.0 |
13+
914

1015
## Installation
1116

1217
```bash
1318
npm install react-native-zip-archive --save
1419
```
1520

21+
1622
## Linking
1723

18-
### Automatically (Recommend)
24+
For iOS, run the command below in you app's root folder once the package has been installed
1925

2026
````bash
21-
react-native link react-native-zip-archive
27+
cd ./ios && pod install
2228
````
2329

24-
### Manually
25-
26-
#### iOS
27-
28-
refer to the [official guide](https://facebook.github.io/react-native/docs/linking-libraries-ios.html),
29-
remember to also link `libz`, `libiconv` and `Security` to your target.(You can follow the tutorial on [this](http://docs.onemobilesdk.aol.com/ios-ad-sdk/adding-frameworks-xcode.html))
30-
31-
#### Android
32-
33-
* Edit `android/settings.gradle` to look like this (without the +):
34-
35-
```diff
36-
rootProject.name = 'MyApp'
37-
38-
include ':app'
39-
40-
+ include ':react-native-zip-archive'
41-
+ project(':react-native-zip-archive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zip-archive/android')
42-
```
43-
44-
* Edit `android/app/build.gradle` (note: **app** folder) to look like this:
45-
46-
```diff
47-
apply plugin: 'com.android.application'
48-
49-
android {
50-
...
51-
}
52-
53-
dependencies {
54-
compile fileTree(dir: 'libs', include: ['*.jar'])
55-
compile 'com.android.support:appcompat-v7:23.0.0'
56-
compile 'com.facebook.react:react-native:0.16.+'
57-
+ compile project(':react-native-zip-archive')
58-
}
59-
```
60-
61-
* For react-native blew 0.19.0
62-
- Edit your `MainActivity.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):
63-
64-
```diff
65-
+ import import com.rnziparchive.RNZipArchivePackage;
66-
67-
....
30+
For Andriod, it's ready to go.
6831

69-
@Override
70-
protected void onCreate(Bundle savedInstanceState) {
71-
super.onCreate(savedInstanceState);
72-
mReactRootView = new ReactRootView(this);
73-
74-
mReactInstanceManager = ReactInstanceManager.builder()
75-
.setApplication(getApplication())
76-
.setBundleAssetName("index.android.bundle")
77-
.setJSMainModuleName("index.android")
78-
.addPackage(new MainReactPackage())
79-
+ .addPackage(new RNZipArchivePackage())
80-
.setUseDeveloperSupport(BuildConfig.DEBUG)
81-
.setInitialLifecycleState(LifecycleState.RESUMED)
82-
.build();
83-
84-
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
85-
86-
setContentView(mReactRootView);
87-
}
88-
```
89-
90-
* react-native 0.19.0 and higher
91-
92-
- Edit your `MainActivity.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):
93-
94-
```diff
95-
package com.myapp;
96-
97-
+ import com.rnziparchive.RNZipArchivePackage;
98-
99-
....
100-
101-
@Override
102-
protected List<ReactPackage> getPackages() {
103-
return Arrays.<ReactPackage>asList(
104-
new MainReactPackage(),
105-
+ new RNZipArchivePackage()
106-
);
107-
}
108-
109-
}
110-
```
111-
112-
* For react-native 0.29.0 and higher ( in MainApplication.java )
113-
114-
- Edit your `MainApplication.java` (deep in `android/app/src/main/java/...`) to look like this (note **three** places to edit):
115-
116-
```diff
117-
+ import com.rnziparchive.RNZipArchivePackage;
118-
119-
public class MainApplication extends Application implements ReactApplication {
120-
...
121-
@Override
122-
protected List<ReactPackage> getPackages() {
123-
return Arrays.<ReactPackage>asList(
124-
- new MainReactPackage()
125-
+ new MainReactPackage(),
126-
+ new RNZipArchivePackage()
127-
);
128-
}
129-
```
13032

13133
## Usage
13234

@@ -142,9 +44,10 @@ you may also want to use something like [react-native-fs](https://github.com/joh
14244
import { MainBundlePath, DocumentDirectoryPath } from 'react-native-fs'
14345
```
14446

47+
14548
## API
14649

147-
**zip(source: string, target: string): Promise**
50+
**`zip(source: string, target: string): Promise<string>`**
14851

14952
> zip source to target
15053
@@ -163,7 +66,7 @@ zip(sourcePath, targetPath)
16366
})
16467
```
16568

166-
**zipWithPassword(source: string, target: string, password: string, encryptionType: string): Promise**
69+
**`zipWithPassword(source: string, target: string, password: string, encryptionType: string): Promise<string>`**
16770

16871
> zip source to target
16972
@@ -195,7 +98,7 @@ Example
19598
```js
19699
const sourcePath = `${DocumentDirectoryPath}/myFile.zip`
197100
const targetPath = DocumentDirectoryPath
198-
const charset = 'UTF-8'
101+
const charset = 'UTF-8'
199102
// charset possible values: UTF-8, GBK, US-ASCII and so on. If none was passed, default value is UTF-8
200103

201104

@@ -208,7 +111,7 @@ unzip(sourcePath, targetPath, charset)
208111
})
209112
```
210113

211-
**unzipWithPassword(source: string, target: string, password: string): Promise**
114+
**`unzipWithPassword(source: string, target: string, password: string): Promise<string>`**
212115

213116
> unzip from source to target
214117
@@ -228,7 +131,7 @@ unzipWithPassword(sourcePath, targetPath, password)
228131
})
229132
```
230133

231-
**unzipAssets(assetPath: string, target: string): Promise**
134+
**`unzipAssets(assetPath: string, target: string): Promise<string>`**
232135

233136
> unzip file from Android `assets` folder to target path
234137
@@ -237,7 +140,7 @@ unzipWithPassword(sourcePath, targetPath, password)
237140
`assetPath` is the relative path to the file inside the pre-bundled assets folder, e.g. `folder/myFile.zip`. ***Do not pass an absolute directory.***
238141

239142
```js
240-
const assetPath = `${DocumentDirectoryPath}/myFile.zip`
143+
const assetPath = './myFile.zip'
241144
const targetPath = DocumentDirectoryPath
242145

243146
unzipAssets(assetPath, targetPath)
@@ -249,7 +152,7 @@ unzipAssets(assetPath, targetPath)
249152
})
250153
```
251154

252-
**subscribe(callback: ({ progress: number, filePath: string })): EmitterSubscription**
155+
**`subscribe(callback: ({ progress: number, filePath: string }) => void): EmitterSubscription`**
253156

254157
> Subscribe to the progress callbacks. Useful for displaying a progress bar on your UI during the process.
255158
@@ -276,6 +179,8 @@ componentWillUnmount() {
276179
}
277180
```
278181

182+
279183
## Related Projects
280184

281185
- [ZipArchive](https://github.com/ZipArchive/ZipArchive)
186+
- [zip4j](https://github.com/srikanth-lingala/zip4j)

RNZipArchive.podspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ require 'json'
33
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
44

55
Pod::Spec.new do |s|
6-
76
s.name = 'RNZipArchive'
87
s.version = package['version']
98
s.summary = package['description']
@@ -13,14 +12,13 @@ Pod::Spec.new do |s|
1312
s.source = { :git => 'https://github.com/mockingbot/react-native-zip-archive.git', :tag => "#{s.version}"}
1413
s.platform = :ios, '8.0'
1514
s.preserve_paths = '*.js'
16-
s.library = 'z'
1715

1816
s.dependency 'React'
1917
s.dependency 'SSZipArchive', '2.2.2'
18+
s.compiler_flags = '-GCC_PREPROCESSOR_DEFINITIONS="HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB MZ_ZIP_NO_SIGNING $(inherited)"'
2019

2120
s.subspec 'Core' do |ss|
2221
ss.source_files = 'ios/*.{h,m}'
2322
ss.public_header_files = ['ios/RNZipArchive.h']
2423
end
25-
2624
end

example/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

example/.flowconfig

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,66 @@
1111
; Ignore duplicate module providers
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
15-
14+
node_modules/react-native/Libraries/react-native/React.js
1615
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
18-
19-
; Ignore metro
20-
.*/node_modules/metro/.*
21-
16+
node_modules/react-native/Libraries/polyfills/.*
17+
; These should not be required directly
18+
; require from fbjs/lib instead: require('fbjs/lib/warning')
19+
node_modules/warning/.*
20+
; Flow doesn't support platforms
21+
.*/Libraries/Utilities/HMRLoadingView.js
22+
[untyped]
23+
.*/node_modules/@react-native-community/cli/.*/.*
2224
[include]
23-
2425
[libs]
2526
node_modules/react-native/Libraries/react-native/react-native-interface.js
2627
node_modules/react-native/flow/
27-
node_modules/react-native/flow-github/
28-
2928
[options]
3029
emoji=true
31-
3230
esproposal.optional_chaining=enable
3331
esproposal.nullish_coalescing=enable
34-
32+
module.file_ext=.js
33+
module.file_ext=.json
34+
module.file_ext=.ios.js
3535
module.system=haste
3636
module.system.haste.use_name_reducers=true
3737
# get basename
38-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
39-
# strip .js or .js.flow suffix
40-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
41-
# strip .ios suffix
42-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
4438
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
4539
module.system.haste.paths.blacklist=.*/__tests__/.*
4640
module.system.haste.paths.blacklist=.*/__mocks__/.*
47-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
4841
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
49-
42+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
43+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
44+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
45+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
5046
munge_underscores=true
51-
5247
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
53-
54-
module.file_ext=.js
55-
module.file_ext=.jsx
56-
module.file_ext=.json
57-
module.file_ext=.native.js
58-
5948
suppress_type=$FlowIssue
6049
suppress_type=$FlowFixMe
6150
suppress_type=$FlowFixMeProps
6251
suppress_type=$FlowFixMeState
63-
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
66-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6754
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
68-
55+
[lints]
56+
sketchy-null-number=warn
57+
sketchy-null-mixed=warn
58+
sketchy-number=warn
59+
untyped-type-import=warn
60+
nonstrict-import=warn
61+
deprecated-type=warn
62+
unsafe-getters-setters=warn
63+
inexact-spread=warn
64+
unnecessary-invariant=warn
65+
signature-verification-failure=warn
66+
deprecated-utility=error
67+
[strict]
68+
deprecated-type
69+
nonstrict-import
70+
sketchy-null
71+
unclear-type
72+
unsafe-getters-setters
73+
untyped-import
74+
untyped-type-import
6975
[version]
70-
^0.86.0
76+
^0.98.0

example/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/

example/Example.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { Component } from 'react'
22
import {
33
StyleSheet, View,
4-
Alert, WebView, Platform
4+
Alert, Platform
55
} from 'react-native'
6+
import WebView from 'react-native-webview'
67
import {
78
ANIMATIONS_SLIDE,
89
CustomTabs

example/__tests__/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* @format
3-
* @lint-ignore-every XPLATJSCOPYRIGHT1
43
*/
54

65
import 'react-native';

0 commit comments

Comments
 (0)