Skip to content

Commit abb280b

Browse files
committed
- adding ios auto pod installer
1 parent f6c3da8 commit abb280b

File tree

6 files changed

+160
-55
lines changed

6 files changed

+160
-55
lines changed

Example/ios/ShineButtonExample.xcodeproj/project.pbxproj

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
CB1A8F9D7FB348BEA8F07E1B /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 55F1B257DD814C308E29E710 /* Foundation.ttf */; };
4848
CE0885A4200A270A00641FD4 /* libRNShineButton.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0885A3200A268300641FD4 /* libRNShineButton.a */; };
4949
CE0D2C61208C647200727B17 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CED55CD72070F34100BBB7A4 /* libRNVectorIcons.a */; };
50-
CE0D2CF7208C6D0500727B17 /* WCLShineButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */; };
51-
CE0D2CF8208C6D0500727B17 /* WCLShineButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
50+
CE56C73D20E620BE00AAAB00 /* WCLShineButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */; };
51+
CE56C73E20E620BE00AAAB00 /* WCLShineButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5252
/* End PBXBuildFile section */
5353

5454
/* Begin PBXContainerItemProxy section */
@@ -332,23 +332,23 @@
332332
remoteGlobalIDString = 9721D6151E5576D8003C31EF;
333333
remoteInfo = Demo;
334334
};
335-
CE0D2CF3208C6CFA00727B17 /* PBXContainerItemProxy */ = {
335+
CE56C73920E620B500AAAB00 /* PBXContainerItemProxy */ = {
336336
isa = PBXContainerItemProxy;
337-
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
337+
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
338338
proxyType = 2;
339339
remoteGlobalIDString = B7E639DC672A27CFD2B8D2E59213162A;
340340
remoteInfo = "Pods-RNShineButton";
341341
};
342-
CE0D2CF5208C6CFA00727B17 /* PBXContainerItemProxy */ = {
342+
CE56C73B20E620B500AAAB00 /* PBXContainerItemProxy */ = {
343343
isa = PBXContainerItemProxy;
344-
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
344+
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
345345
proxyType = 2;
346346
remoteGlobalIDString = 4B34D5014B7F3B79CCB1E5250FE37FED;
347347
remoteInfo = WCLShineButton;
348348
};
349-
CE0D2CF9208C6D0600727B17 /* PBXContainerItemProxy */ = {
349+
CE56C73F20E620BE00AAAB00 /* PBXContainerItemProxy */ = {
350350
isa = PBXContainerItemProxy;
351-
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
351+
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
352352
proxyType = 1;
353353
remoteGlobalIDString = 46F144824DBD6F6FCCC2A98488B8B994;
354354
remoteInfo = WCLShineButton;
@@ -369,7 +369,7 @@
369369
dstPath = "";
370370
dstSubfolderSpec = 10;
371371
files = (
372-
CE0D2CF8208C6D0500727B17 /* WCLShineButton.framework in Embed Frameworks */,
372+
CE56C73E20E620BE00AAAB00 /* WCLShineButton.framework in Embed Frameworks */,
373373
);
374374
name = "Embed Frameworks";
375375
runOnlyForDeploymentPostprocessing = 0;
@@ -414,7 +414,7 @@
414414
C5EB5A242149417FB583E214 /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = "<group>"; };
415415
C9630889E5CC4287A53478A8 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = "<group>"; };
416416
CE0885B1200A2A9700641FD4 /* WCLShineButton.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WCLShineButton.xcodeproj; path = "../node_modules/react-native-shine-button/ios/WCLShineButton/WCLShineButton.xcodeproj"; sourceTree = "<group>"; };
417-
CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Pods.xcodeproj; path = "../../node_modules/react-native-shine-button/ios/Pods/Pods.xcodeproj"; sourceTree = "<group>"; };
417+
CE56C73420E620B500AAAB00 /* Pods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Pods.xcodeproj; path = "../../node_modules/react-native-shine-button/ios/Pods/Pods.xcodeproj"; sourceTree = "<group>"; };
418418
E3B9972F15B44798BE201777 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf"; sourceTree = "<group>"; };
419419
EC182BB10D7D43939CEAD235 /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
420420
FCAFB28E352344778EA6FBA1 /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"; sourceTree = "<group>"; };
@@ -438,7 +438,7 @@
438438
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
439439
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
440440
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
441-
CE0D2CF7208C6D0500727B17 /* WCLShineButton.framework in Frameworks */,
441+
CE56C73D20E620BE00AAAB00 /* WCLShineButton.framework in Frameworks */,
442442
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
443443
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
444444
);
@@ -626,7 +626,7 @@
626626
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
627627
isa = PBXGroup;
628628
children = (
629-
CE0D2CED208C6CE900727B17 /* RNShineButton */,
629+
CE56C73320E620A600AAAB00 /* RNShineButton */,
630630
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
631631
146833FF1AC3E56700842450 /* React.xcodeproj */,
632632
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
@@ -714,19 +714,19 @@
714714
name = Products;
715715
sourceTree = "<group>";
716716
};
717-
CE0D2CED208C6CE900727B17 /* RNShineButton */ = {
717+
CE56C73320E620A600AAAB00 /* RNShineButton */ = {
718718
isa = PBXGroup;
719719
children = (
720-
CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */,
720+
CE56C73420E620B500AAAB00 /* Pods.xcodeproj */,
721721
);
722722
path = RNShineButton;
723723
sourceTree = "<group>";
724724
};
725-
CE0D2CEF208C6CFA00727B17 /* Products */ = {
725+
CE56C73520E620B500AAAB00 /* Products */ = {
726726
isa = PBXGroup;
727727
children = (
728-
CE0D2CF4208C6CFA00727B17 /* Pods_RNShineButton.framework */,
729-
CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */,
728+
CE56C73A20E620B500AAAB00 /* Pods_RNShineButton.framework */,
729+
CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */,
730730
);
731731
name = Products;
732732
sourceTree = "<group>";
@@ -755,7 +755,7 @@
755755
buildRules = (
756756
);
757757
dependencies = (
758-
CE0D2CFA208C6D0600727B17 /* PBXTargetDependency */,
758+
CE56C74020E620BE00AAAB00 /* PBXTargetDependency */,
759759
);
760760
name = ShineButtonExample;
761761
productName = "Hello World";
@@ -808,8 +808,8 @@
808808
projectDirPath = "";
809809
projectReferences = (
810810
{
811-
ProductGroup = CE0D2CEF208C6CFA00727B17 /* Products */;
812-
ProjectRef = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
811+
ProductGroup = CE56C73520E620B500AAAB00 /* Products */;
812+
ProjectRef = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
813813
},
814814
{
815815
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
@@ -1161,18 +1161,18 @@
11611161
remoteRef = CE0885B8200A2A9700641FD4 /* PBXContainerItemProxy */;
11621162
sourceTree = BUILT_PRODUCTS_DIR;
11631163
};
1164-
CE0D2CF4208C6CFA00727B17 /* Pods_RNShineButton.framework */ = {
1164+
CE56C73A20E620B500AAAB00 /* Pods_RNShineButton.framework */ = {
11651165
isa = PBXReferenceProxy;
11661166
fileType = wrapper.framework;
11671167
path = Pods_RNShineButton.framework;
1168-
remoteRef = CE0D2CF3208C6CFA00727B17 /* PBXContainerItemProxy */;
1168+
remoteRef = CE56C73920E620B500AAAB00 /* PBXContainerItemProxy */;
11691169
sourceTree = BUILT_PRODUCTS_DIR;
11701170
};
1171-
CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */ = {
1171+
CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */ = {
11721172
isa = PBXReferenceProxy;
11731173
fileType = wrapper.framework;
11741174
path = WCLShineButton.framework;
1175-
remoteRef = CE0D2CF5208C6CFA00727B17 /* PBXContainerItemProxy */;
1175+
remoteRef = CE56C73B20E620B500AAAB00 /* PBXContainerItemProxy */;
11761176
sourceTree = BUILT_PRODUCTS_DIR;
11771177
};
11781178
CED55CD72070F34100BBB7A4 /* libRNVectorIcons.a */ = {
@@ -1268,10 +1268,10 @@
12681268
/* End PBXSourcesBuildPhase section */
12691269

12701270
/* Begin PBXTargetDependency section */
1271-
CE0D2CFA208C6D0600727B17 /* PBXTargetDependency */ = {
1271+
CE56C74020E620BE00AAAB00 /* PBXTargetDependency */ = {
12721272
isa = PBXTargetDependency;
12731273
name = WCLShineButton;
1274-
targetProxy = CE0D2CF9208C6D0600727B17 /* PBXContainerItemProxy */;
1274+
targetProxy = CE56C73F20E620BE00AAAB00 /* PBXContainerItemProxy */;
12751275
};
12761276
/* End PBXTargetDependency section */
12771277

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,14 @@ allprojects {
6868
6969

7070
#### iOS
71-
- Run Command: `cd ../node_modules/react-native-shine-button/ios && pod install`. If it has error => try `pod repo update` then `pod install`
72-
73-
- Add WCLShineButton.framework in Embedded Binaries & Linked Frameworks and Libraries. You can find this library from below path:
74-
75-
`node_modules/react-native-shine-button/ios/WCLShineButton/WCLShineButton.xcodeproj`
71+
- After `react-native link react-native-shine-button`, please verify `node_modules/react-native-shine-button/ios/` contains `Pods` folder. If does not exist please execute `pod install` command on `node_modules/react-native-shine-button/ios/`, if any error => try `pod repo update` then `pod install`
72+
- After verification, open your project and create a folder 'RNShineButton' under Libraries.
73+
- Drag `node_modules/react-native-shine-button/ios/pods/Pods.xcodeproject` into RNShineButton, as well as the RNShineButton.xcodeproject if it does not exist.
74+
- Add the `WCLShineButton.framework` into your project's `Embedded Binaries` and make sure the framework is also in linked libraries.
75+
- Go to your project's `Build Settings -> Framework Search Path` and set `$(inherited) to recursive`.
7676

7777
<img src="assets/setup.gif" />
7878

79-
- Now build your iOS app through Xcode
80-
81-
- If you receive below error, please check video below in order to resolve the same:
82-
83-
<img src="./assets/swift-error.png" />
84-
85-
**SOLUTION**
86-
87-
<img src="./assets/swift-error.gif" />
88-
8979

9080
## 💻 Usage
9181

@@ -143,7 +133,7 @@ If you are using this library in one of your projects, add it in this list below
143133

144134

145135
## 📜 License
146-
This library is provided under the Apache 2 License.
136+
This library is provided under the Apache License.
147137

148138
RNShineButton @ [prscX](https://github.com/prscX)
149139

ios/Podfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment the next line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
platform :ios, '9.0'
33

44
target 'RNShineButton' do
55
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
@@ -8,4 +8,14 @@ target 'RNShineButton' do
88
# Pods for RNShineButton
99

1010
pod 'WCLShineButton',:git => 'https://github.com/prscX/WCLShineButton.git', :commit =>'ddd4deb'
11+
12+
post_install do |installer|
13+
installer.pods_project.targets.each do |target|
14+
if target.name.include?('WCLShineButton')
15+
target.build_configurations.each do |config|
16+
config.build_settings['SWIFT_VERSION'] = '4.1'
17+
end
18+
end
19+
end
20+
end
1121
end

ios/RNShineButton.podspec

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
14

25
Pod::Spec.new do |s|
36
s.name = "RNShineButton"
4-
s.version = "1.0.0"
5-
s.summary = "RNShineButton"
6-
s.description = <<-DESC
7-
RNShineButton
8-
DESC
9-
s.homepage = ""
10-
s.license = "MIT"
11-
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
12-
s.author = { "author" => "[email protected]" }
13-
s.platform = :ios, "7.0"
7+
s.version = package['version']
8+
s.summary = package['description']
9+
s.description = package["description"]
10+
s.homepage = "n/a"
11+
s.license = package['license']
12+
s.author = package['author']
13+
s.platform = :ios, "9.0"
14+
s.ios.deployment_target = '9.0'
15+
s.library = 'z'
16+
s.preserve_paths = '*.js'
1417
s.source = { :git => "https://github.com/author/RNShineButton.git", :tag => "master" }
1518
s.source_files = "RNShineButton/**/*.{h,m}"
1619
s.requires_arc = true
20+
s.static_framework = true
1721

1822

1923
s.dependency "React"

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{
33
"name": "react-native-shine-button",
4-
"version": "0.0.9",
4+
"version": "0.0.10",
55
"description":
66
"React Native Bridge for ChadCSong/ShineButton & imwcl/WCLShineButton",
77
"main": "js/RNShineButton.js",
@@ -10,7 +10,8 @@
1010
"url": "https://github.com/prscX/react-native-shine-button.git"
1111
},
1212
"scripts": {
13-
"test": "echo \"Error: no test specified\" && exit 1"
13+
"test": "echo \"Error: no test specified\" && exit 1",
14+
"postinstall": "node scripts/installer.js"
1415
},
1516
"keywords": ["react-native"],
1617
"author": "Pranav Raj Singh Chauhan",

scripts/installer.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
const exec = require('child_process').exec
2+
3+
var osvar = process.platform
4+
5+
if (osvar !== 'darwin') return
6+
7+
exists('pod')
8+
.then(function(command) {
9+
installPods()
10+
})
11+
.catch(function() {
12+
installCocoaPods().then(() => {
13+
installPods()
14+
})
15+
})
16+
17+
function installPods() {
18+
console.log('executing pod install command')
19+
20+
exec('cd ./ios && pod install', (err, stdout, stderr) => {
21+
console.log(stderr)
22+
23+
if (err === undefined || err === null) {
24+
console.log('pod install command successfull')
25+
return
26+
}
27+
28+
if (stdout !== undefined && stdout !== null) {
29+
if (stdout.includes('could not find compatible versions for pod')) {
30+
console.log('executing pod repo update command.')
31+
32+
exec('pod repo update', (err, stdout, stderr) => {
33+
if (err === undefined || err === null) {
34+
console.log('pod repo update successfull')
35+
36+
exec('cd ./ios && pod install', (err, stdout, stderr) => {})
37+
38+
return
39+
}
40+
41+
console.log(stdout)
42+
})
43+
}
44+
} else {
45+
console.log('pod install sucessfull')
46+
}
47+
})
48+
}
49+
50+
function installCocoaPods() {
51+
console.log('installing socoapods.')
52+
53+
return new Promise((resolve, reject) => {
54+
run('sudo gem install cocoapods')
55+
.then(() => {
56+
console.log('sudo gem install cocoapods sucessfull')
57+
resolve()
58+
})
59+
.catch(e => {
60+
console.log(e)
61+
})
62+
})
63+
}
64+
65+
// returns Promise which fulfills with true if command exists
66+
function exists(cmd) {
67+
return run(`which ${cmd}`).then(stdout => {
68+
if (stdout.trim().length === 0) {
69+
// maybe an empty command was supplied?
70+
// are we running on Windows??
71+
return Promise.reject(new Error('No output'))
72+
}
73+
74+
const rNotFound = /^[\w\-]+ not found/g
75+
76+
if (rNotFound.test(cmd)) {
77+
return Promise.resolve(false)
78+
}
79+
80+
return Promise.resolve(true)
81+
})
82+
}
83+
84+
function run(command) {
85+
return new Promise((fulfill, reject) => {
86+
exec(command, (err, stdout, stderr) => {
87+
if (err) {
88+
reject(err)
89+
return
90+
}
91+
92+
if (stderr) {
93+
reject(new Error(stderr))
94+
return
95+
}
96+
97+
fulfill(stdout)
98+
})
99+
})
100+
}

0 commit comments

Comments
 (0)