Skip to content

Commit 3e4ec78

Browse files
committed
feat: ios project settings
1 parent 7eb2a7c commit 3e4ec78

8 files changed

Lines changed: 243 additions & 204 deletions

File tree

android/src/main/java/com/jimmydaddy/bsdiffpatch/BsDiffPatchModule.kt

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -10,98 +10,98 @@ import java.io.File
1010

1111
@ReactModule(name = BsDiffPatchModule.NAME)
1212
class BsDiffPatchModule(reactContext: ReactApplicationContext?) :
13-
ReactContextBaseJavaModule(reactContext) {
14-
override fun getName(): String {
15-
return NAME
16-
}
13+
ReactContextBaseJavaModule(reactContext) {
14+
override fun getName(): String {
15+
return NAME
16+
}
1717

18-
fun getFileDir(dir: String): String {
19-
if (dir.startsWith("file://")) {
20-
return dir.substring(7)
21-
}
22-
return dir
18+
private fun getFileDir(dir: String): String {
19+
if (dir.startsWith("file://")) {
20+
return dir.substring(7)
2321
}
22+
return dir
23+
}
2424

25-
// Example method
26-
// See https://reactnative.dev/docs/native-modules-android
27-
@ReactMethod
28-
fun patch(oldFile: String?, newFile: String?, patchFile: String?, promise: Promise) {
29-
if (oldFile == null || newFile == null || patchFile == null || oldFile.isEmpty() || newFile.isEmpty() || patchFile.isEmpty()) {
30-
promise.reject("error", "oldFile, newFile, patchFile can not be null or empty")
31-
return
32-
}
33-
if (oldFile == newFile || oldFile == patchFile || newFile == patchFile) {
34-
promise.reject("error", "oldFile, newFile, patchFile can not be the same")
35-
return
36-
}
37-
val oldFileObj = File(getFileDir(oldFile))
38-
if (!oldFileObj.exists()) {
39-
promise.reject("error", "oldFile not exist")
40-
return
41-
}
42-
val patchFileObj = File(getFileDir(patchFile))
43-
if (!patchFileObj.exists()) {
44-
promise.reject("error", "patchFile not exist")
45-
return
46-
}
47-
val newFileObj = File(getFileDir(newFile))
48-
if (newFileObj.exists()) {
49-
promise.reject("error", "newFile already exist")
50-
return
51-
}
52-
try {
53-
val result = bsPatchFile(oldFileObj.absolutePath, newFileObj.absolutePath, patchFileObj.absolutePath)
54-
promise.resolve(result)
55-
} catch (e: Exception) {
56-
promise.reject("error", e.message)
57-
}
25+
// Example method
26+
// See https://reactnative.dev/docs/native-modules-android
27+
@ReactMethod
28+
fun patch(oldFile: String?, newFile: String?, patchFile: String?, promise: Promise) {
29+
if (oldFile == null || newFile == null || patchFile == null || oldFile.isEmpty() || newFile.isEmpty() || patchFile.isEmpty()) {
30+
promise.reject("error", "oldFile, newFile, patchFile can not be null or empty")
31+
return
32+
}
33+
if (oldFile == newFile || oldFile == patchFile || newFile == patchFile) {
34+
promise.reject("error", "oldFile, newFile, patchFile can not be the same")
35+
return
36+
}
37+
val oldFileObj = File(getFileDir(oldFile))
38+
if (!oldFileObj.exists()) {
39+
promise.reject("error", "oldFile: $oldFile not exist")
40+
return
41+
}
42+
val patchFileObj = File(getFileDir(patchFile))
43+
if (!patchFileObj.exists()) {
44+
promise.reject("error", "patchFile: $patchFile not exist")
45+
return
5846
}
47+
val newFileObj = File(getFileDir(newFile))
48+
if (newFileObj.exists()) {
49+
promise.reject("error", "newFile: $newFile already exist")
50+
return
51+
}
52+
try {
53+
val result = bsPatchFile(oldFileObj.absolutePath, newFileObj.absolutePath, patchFileObj.absolutePath)
54+
promise.resolve(result)
55+
} catch (e: Exception) {
56+
promise.reject("error", e.message)
57+
}
58+
}
5959

60-
@ReactMethod
61-
fun diff(oldFile: String?, newFile: String?, patchFile: String?, promise: Promise) {
62-
if (oldFile == null || newFile == null || patchFile == null || oldFile.isEmpty() || newFile.isEmpty() || patchFile.isEmpty()) {
63-
promise.reject("error", "oldFile, newFile, patchFile can not be null or empty")
64-
return
65-
}
66-
if (oldFile == newFile || oldFile == patchFile || newFile == patchFile) {
67-
promise.reject("error", "oldFile, newFile, patchFile can not be the same")
68-
return
69-
}
70-
val oldFileObj = File(getFileDir(oldFile))
71-
if (!oldFileObj.exists()) {
72-
promise.reject("error", "oldFile not exist")
73-
return
74-
}
75-
val newFileObj = File(getFileDir(newFile))
76-
if (!newFileObj.exists()) {
77-
promise.reject("error", "newFile not exist")
78-
return
79-
}
80-
val patchFileObj = File(getFileDir(patchFile))
81-
if (patchFileObj.exists()) {
82-
promise.reject("error", "patchFile already exist")
83-
return
84-
}
85-
try {
86-
val result = bsDiffFile(oldFileObj.absolutePath, newFileObj.absolutePath, patchFileObj.absolutePath)
87-
promise.resolve(result)
88-
} catch (e: Exception) {
89-
promise.reject("error", e.message)
90-
}
60+
@ReactMethod
61+
fun diff(oldFile: String?, newFile: String?, patchFile: String?, promise: Promise) {
62+
if (oldFile == null || newFile == null || patchFile == null || oldFile.isEmpty() || newFile.isEmpty() || patchFile.isEmpty()) {
63+
promise.reject("error", "oldFile, newFile, patchFile can not be null or empty")
64+
return
65+
}
66+
if (oldFile == newFile || oldFile == patchFile || newFile == patchFile) {
67+
promise.reject("error", "oldFile, newFile, patchFile can not be the same")
68+
return
9169
}
70+
val oldFileObj = File(getFileDir(oldFile))
71+
if (!oldFileObj.exists()) {
72+
promise.reject("error", "oldFile: $oldFile not exist")
73+
return
74+
}
75+
val newFileObj = File(getFileDir(newFile))
76+
if (!newFileObj.exists()) {
77+
promise.reject("error", "newFile: $newFile not exist")
78+
return
79+
}
80+
val patchFileObj = File(getFileDir(patchFile))
81+
if (patchFileObj.exists()) {
82+
promise.reject("error", "patchFile: $patchFile already exist")
83+
return
84+
}
85+
try {
86+
val result = bsDiffFile(oldFileObj.absolutePath, newFileObj.absolutePath, patchFileObj.absolutePath)
87+
promise.resolve(result)
88+
} catch (e: Exception) {
89+
promise.reject("error", e.message)
90+
}
91+
}
9292

93-
companion object {
94-
const val NAME = "BsDiffPatch"
93+
companion object {
94+
const val NAME = "BsDiffPatch"
9595

96-
init {
97-
System.loadLibrary("react-native-bs-diff-patch")
98-
}
96+
init {
97+
System.loadLibrary("react-native-bs-diff-patch")
98+
}
9999

100-
// Used to load the 'native-lib' library on application startup.
101-
// get new file from old file and patch file
102-
private external fun bsPatchFile(oldFile: String, newFile: String, patchFile: String): Int
100+
// Used to load the 'native-lib' library on application startup.
101+
// get new file from old file and patch file
102+
private external fun bsPatchFile(oldFile: String, newFile: String, patchFile: String): Int
103103

104-
// generate patch file
105-
private external fun bsDiffFile(oldFile: String, newFile: String, patchFile: String): Int
106-
}
104+
// generate patch file
105+
private external fun bsDiffFile(oldFile: String, newFile: String, patchFile: String): Int
106+
}
107107
}

example/ios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.xcode.env.local

example/ios/.xcode.env.local

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export NODE_BINARY=/private/var/folders/6_/_ffnz6q91dddz6wchgxcblsw0000gn/T/xfs-4db397e6/node
2-
1+
export NODE_BINARY=$(command -v node)

example/ios/BsDiffPatchExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@
663663
);
664664
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
665665
SDKROOT = iphoneos;
666-
USE_HERMES = true;
666+
USE_HERMES = false;
667667
};
668668
name = Debug;
669669
};
@@ -735,7 +735,7 @@
735735
);
736736
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
737737
SDKROOT = iphoneos;
738-
USE_HERMES = true;
738+
USE_HERMES = false;
739739
VALIDATE_PRODUCT = YES;
740740
};
741741
name = Release;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

example/ios/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ target 'BsDiffPatchExample' do
4545
# you should disable the next line.
4646
:flipper_configuration => flipper_config,
4747
# An absolute path to your application root.
48-
:app_path => "#{Pod::Config.instance.installation_root}/.."
48+
:app_path => "#{Pod::Config.instance.installation_root}/..",
49+
:hermes_enabled => false
4950
)
5051

5152
target 'BsDiffPatchExampleTests' do

0 commit comments

Comments
 (0)