Skip to content

Commit 6f1a2a5

Browse files
committed
fix: cleaned up cordova 7.0.0 fix
1 parent 862f14e commit 6f1a2a5

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ testbed/platforms
33
testbed/plugins
44
testbed/hooks
55
testbed/build.json
6+
testbed/package.json
67
node_modules
78
.installed
89
.gradle/

src/scripts/npm/processConfigXml.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,53 +108,56 @@
108108
var projectRoot = getProjectRoot(context)
109109
var projectPath = path.join(projectRoot, 'platforms', 'ios')
110110

111-
// try pre 5.0 cordova structure
112111
try {
112+
// pre 5.0 cordova structure
113113
return context.requireCordovaModule('cordova-lib/src/plugman/platforms').ios.parseProjectFile(projectPath)
114114
} catch (e) {
115-
// try pre 7.0 cordova structure
116115
try {
116+
// pre 7.0 cordova structure
117117
return context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios').parseProjectFile(projectPath)
118118
} catch (e) {
119-
return getProjectModulePlugman(context)
119+
// post 7.0 cordova structure
120+
return getProjectModuleGlob(context)
120121
}
121122
}
122123
}
123124

124-
function getProjectModulePlugman (context) {
125+
function getProjectModuleGlob (context) {
126+
// get xcodeproj
125127
var projectRoot = getProjectRoot(context)
126128
var projectPath = path.join(projectRoot, 'platforms', 'ios')
127129
var projectFiles = context.requireCordovaModule('glob').sync(path.join(projectPath, '*.xcodeproj', 'project.pbxproj'))
128-
129-
if (projectFiles.length === 0) {
130-
throw new Error('BRANCH SDK: Unable to locate the Xcode project file.')
131-
}
132-
130+
if (projectFiles.length === 0) return
133131
var pbxPath = projectFiles[0]
134132
var xcodeproj = context.requireCordovaModule('xcode').project(pbxPath)
133+
134+
// add hash
135135
xcodeproj.parseSync()
136136

137-
var xCodeProjectFile = {
137+
// return xcodeproj and write method
138+
return {
138139
'xcode': xcodeproj,
139140
'write': function () {
141+
// save xcodeproj
140142
var fs = context.requireCordovaModule('fs')
143+
fs.writeFileSync(pbxPath, xcodeproj.writeSync())
144+
145+
// pull framework dependencies
141146
var frameworksFile = path.join(projectPath, 'frameworks.json')
142147
var frameworks = {}
148+
143149
try {
144150
frameworks = context.requireCordovaModule(frameworksFile)
145151
} catch (e) {}
146-
147-
fs.writeFileSync(pbxPath, xcodeproj.writeSync())
152+
// If there are no framework references, remove this file
148153
if (Object.keys(frameworks).length === 0) {
149-
// If there is no framework references remain in the project, just remove this file
150-
context.requireCordovaModule('shelljs').rm('-rf', frameworksFile)
151-
return
154+
return context.requireCordovaModule('shelljs').rm('-rf', frameworksFile)
152155
}
153-
fs.writeFileSync(frameworksFile, JSON.stringify(this.frameworks, null, 4))
156+
157+
// save frameworks
158+
fs.writeFileSync(frameworksFile, JSON.stringify(frameworks, null, 4))
154159
}
155160
}
156-
157-
return xCodeProjectFile
158161
}
159162

160163
// validate <branch-config> properties within config.xml

testbed/init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ main() {
6666
rm -rf ./plugins
6767
rm -rf ./platforms
6868
rm -rf ./build.json
69+
rm -rf ./package.json
6970

7071
# build (platforms added before plugin because before_plugin_install does not work on file reference)
7172
if [[ "$run_ios" == "true" ]]; then

0 commit comments

Comments
 (0)