Skip to content

Commit

Permalink
- adding ios auto pod installer
Browse files Browse the repository at this point in the history
  • Loading branch information
prscms committed Jun 29, 2018
1 parent f6c3da8 commit abb280b
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 55 deletions.
52 changes: 26 additions & 26 deletions Example/ios/ShineButtonExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
CB1A8F9D7FB348BEA8F07E1B /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 55F1B257DD814C308E29E710 /* Foundation.ttf */; };
CE0885A4200A270A00641FD4 /* libRNShineButton.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0885A3200A268300641FD4 /* libRNShineButton.a */; };
CE0D2C61208C647200727B17 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CED55CD72070F34100BBB7A4 /* libRNVectorIcons.a */; };
CE0D2CF7208C6D0500727B17 /* WCLShineButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */; };
CE0D2CF8208C6D0500727B17 /* WCLShineButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CE56C73D20E620BE00AAAB00 /* WCLShineButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */; };
CE56C73E20E620BE00AAAB00 /* WCLShineButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -332,23 +332,23 @@
remoteGlobalIDString = 9721D6151E5576D8003C31EF;
remoteInfo = Demo;
};
CE0D2CF3208C6CFA00727B17 /* PBXContainerItemProxy */ = {
CE56C73920E620B500AAAB00 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = B7E639DC672A27CFD2B8D2E59213162A;
remoteInfo = "Pods-RNShineButton";
};
CE0D2CF5208C6CFA00727B17 /* PBXContainerItemProxy */ = {
CE56C73B20E620B500AAAB00 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 4B34D5014B7F3B79CCB1E5250FE37FED;
remoteInfo = WCLShineButton;
};
CE0D2CF9208C6D0600727B17 /* PBXContainerItemProxy */ = {
CE56C73F20E620BE00AAAB00 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
containerPortal = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 46F144824DBD6F6FCCC2A98488B8B994;
remoteInfo = WCLShineButton;
Expand All @@ -369,7 +369,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
CE0D2CF8208C6D0500727B17 /* WCLShineButton.framework in Embed Frameworks */,
CE56C73E20E620BE00AAAB00 /* WCLShineButton.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -414,7 +414,7 @@
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>"; };
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>"; };
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>"; };
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>"; };
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>"; };
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>"; };
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>"; };
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>"; };
Expand All @@ -438,7 +438,7 @@
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
CE0D2CF7208C6D0500727B17 /* WCLShineButton.framework in Frameworks */,
CE56C73D20E620BE00AAAB00 /* WCLShineButton.framework in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
);
Expand Down Expand Up @@ -626,7 +626,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
CE0D2CED208C6CE900727B17 /* RNShineButton */,
CE56C73320E620A600AAAB00 /* RNShineButton */,
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
Expand Down Expand Up @@ -714,19 +714,19 @@
name = Products;
sourceTree = "<group>";
};
CE0D2CED208C6CE900727B17 /* RNShineButton */ = {
CE56C73320E620A600AAAB00 /* RNShineButton */ = {
isa = PBXGroup;
children = (
CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */,
CE56C73420E620B500AAAB00 /* Pods.xcodeproj */,
);
path = RNShineButton;
sourceTree = "<group>";
};
CE0D2CEF208C6CFA00727B17 /* Products */ = {
CE56C73520E620B500AAAB00 /* Products */ = {
isa = PBXGroup;
children = (
CE0D2CF4208C6CFA00727B17 /* Pods_RNShineButton.framework */,
CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */,
CE56C73A20E620B500AAAB00 /* Pods_RNShineButton.framework */,
CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -755,7 +755,7 @@
buildRules = (
);
dependencies = (
CE0D2CFA208C6D0600727B17 /* PBXTargetDependency */,
CE56C74020E620BE00AAAB00 /* PBXTargetDependency */,
);
name = ShineButtonExample;
productName = "Hello World";
Expand Down Expand Up @@ -808,8 +808,8 @@
projectDirPath = "";
projectReferences = (
{
ProductGroup = CE0D2CEF208C6CFA00727B17 /* Products */;
ProjectRef = CE0D2CEE208C6CFA00727B17 /* Pods.xcodeproj */;
ProductGroup = CE56C73520E620B500AAAB00 /* Products */;
ProjectRef = CE56C73420E620B500AAAB00 /* Pods.xcodeproj */;
},
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
Expand Down Expand Up @@ -1161,18 +1161,18 @@
remoteRef = CE0885B8200A2A9700641FD4 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
CE0D2CF4208C6CFA00727B17 /* Pods_RNShineButton.framework */ = {
CE56C73A20E620B500AAAB00 /* Pods_RNShineButton.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Pods_RNShineButton.framework;
remoteRef = CE0D2CF3208C6CFA00727B17 /* PBXContainerItemProxy */;
remoteRef = CE56C73920E620B500AAAB00 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
CE0D2CF6208C6CFA00727B17 /* WCLShineButton.framework */ = {
CE56C73C20E620B500AAAB00 /* WCLShineButton.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = WCLShineButton.framework;
remoteRef = CE0D2CF5208C6CFA00727B17 /* PBXContainerItemProxy */;
remoteRef = CE56C73B20E620B500AAAB00 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
CED55CD72070F34100BBB7A4 /* libRNVectorIcons.a */ = {
Expand Down Expand Up @@ -1268,10 +1268,10 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
CE0D2CFA208C6D0600727B17 /* PBXTargetDependency */ = {
CE56C74020E620BE00AAAB00 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = WCLShineButton;
targetProxy = CE0D2CF9208C6D0600727B17 /* PBXContainerItemProxy */;
targetProxy = CE56C73F20E620BE00AAAB00 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

Expand Down
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,14 @@ allprojects {

#### iOS
- Run Command: `cd ../node_modules/react-native-shine-button/ios && pod install`. If it has error => try `pod repo update` then `pod install`

- Add WCLShineButton.framework in Embedded Binaries & Linked Frameworks and Libraries. You can find this library from below path:

`node_modules/react-native-shine-button/ios/WCLShineButton/WCLShineButton.xcodeproj`
- 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`
- After verification, open your project and create a folder 'RNShineButton' under Libraries.
- Drag `node_modules/react-native-shine-button/ios/pods/Pods.xcodeproject` into RNShineButton, as well as the RNShineButton.xcodeproject if it does not exist.
- Add the `WCLShineButton.framework` into your project's `Embedded Binaries` and make sure the framework is also in linked libraries.
- Go to your project's `Build Settings -> Framework Search Path` and set `$(inherited) to recursive`.

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

- Now build your iOS app through Xcode

- If you receive below error, please check video below in order to resolve the same:

<img src="./assets/swift-error.png" />

**SOLUTION**

<img src="./assets/swift-error.gif" />


## 💻 Usage

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


## 📜 License
This library is provided under the Apache 2 License.
This library is provided under the Apache License.

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

Expand Down
12 changes: 11 additions & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'

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

pod 'WCLShineButton',:git => 'https://github.com/prscX/WCLShineButton.git', :commit =>'ddd4deb'

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name.include?('WCLShineButton')
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
end
24 changes: 14 additions & 10 deletions ios/RNShineButton.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = "RNShineButton"
s.version = "1.0.0"
s.summary = "RNShineButton"
s.description = <<-DESC
RNShineButton
DESC
s.homepage = ""
s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "author" => "[email protected]" }
s.platform = :ios, "7.0"
s.version = package['version']
s.summary = package['description']
s.description = package["description"]
s.homepage = "n/a"
s.license = package['license']
s.author = package['author']
s.platform = :ios, "9.0"
s.ios.deployment_target = '9.0'
s.library = 'z'
s.preserve_paths = '*.js'
s.source = { :git => "https://github.com/author/RNShineButton.git", :tag => "master" }
s.source_files = "RNShineButton/**/*.{h,m}"
s.requires_arc = true
s.static_framework = true


s.dependency "React"
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{
"name": "react-native-shine-button",
"version": "0.0.9",
"version": "0.0.10",
"description":
"React Native Bridge for ChadCSong/ShineButton & imwcl/WCLShineButton",
"main": "js/RNShineButton.js",
Expand All @@ -10,7 +10,8 @@
"url": "https://github.com/prscX/react-native-shine-button.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node scripts/installer.js"
},
"keywords": ["react-native"],
"author": "Pranav Raj Singh Chauhan",
Expand Down
100 changes: 100 additions & 0 deletions scripts/installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
const exec = require('child_process').exec

var osvar = process.platform

if (osvar !== 'darwin') return

exists('pod')
.then(function(command) {
installPods()
})
.catch(function() {
installCocoaPods().then(() => {
installPods()
})
})

function installPods() {
console.log('executing pod install command')

exec('cd ./ios && pod install', (err, stdout, stderr) => {
console.log(stderr)

if (err === undefined || err === null) {
console.log('pod install command successfull')
return
}

if (stdout !== undefined && stdout !== null) {
if (stdout.includes('could not find compatible versions for pod')) {
console.log('executing pod repo update command.')

exec('pod repo update', (err, stdout, stderr) => {
if (err === undefined || err === null) {
console.log('pod repo update successfull')

exec('cd ./ios && pod install', (err, stdout, stderr) => {})

return
}

console.log(stdout)
})
}
} else {
console.log('pod install sucessfull')
}
})
}

function installCocoaPods() {
console.log('installing socoapods.')

return new Promise((resolve, reject) => {
run('sudo gem install cocoapods')
.then(() => {
console.log('sudo gem install cocoapods sucessfull')
resolve()
})
.catch(e => {
console.log(e)
})
})
}

// returns Promise which fulfills with true if command exists
function exists(cmd) {
return run(`which ${cmd}`).then(stdout => {
if (stdout.trim().length === 0) {
// maybe an empty command was supplied?
// are we running on Windows??
return Promise.reject(new Error('No output'))
}

const rNotFound = /^[\w\-]+ not found/g

if (rNotFound.test(cmd)) {
return Promise.resolve(false)
}

return Promise.resolve(true)
})
}

function run(command) {
return new Promise((fulfill, reject) => {
exec(command, (err, stdout, stderr) => {
if (err) {
reject(err)
return
}

if (stderr) {
reject(new Error(stderr))
return
}

fulfill(stdout)
})
})
}

0 comments on commit abb280b

Please sign in to comment.