Skip to content

Commit 49463eb

Browse files
committed
fix: process correctly podfiles without platform's version
Steps to reproduce: 1. `tns create myPodApp --js` 2. `tns plugin add nativescript-imagepicker` 3. `tns plugin add nativescript-facebook` 4. Open `node_modules/nativescript-facebook/platforms/ios/Podfile` and replace the file's content with `platform :ios` 5. Open `node_modules/nativescript-imagepicker/platforms/ios/Podfile` and replace the file's content with `platform :ios, '9.0'`
1 parent 0fabc39 commit 49463eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/services/cocoapods-platform-manager.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager {
4545
}
4646

4747
private getPlatformSectionData(projectPodfileContent: string): { podfilePlatformData: IPodfilePlatformData, platformSectionContent: string } {
48-
const platformSectionRegExp = new RegExp(`${this.getPlatformSectionHeader()} ([\\s\\S]*?)with (.*)[\\s\\S]*?${this.getPlatformSectionFooter()}`, "m");
48+
const platformSectionRegExp = new RegExp(`${this.getPlatformSectionHeader()} ([\\s\\S]*?)with[\\s\\S]*?\\n([\\s\\S]*?(?:,\\s*?['"](.+)['"])?)\\n${this.getPlatformSectionFooter()}`, "m");
4949
const match = platformSectionRegExp.exec(projectPodfileContent);
5050
let result = null;
5151
if (match && match[0]) {
5252
result = {
5353
platformSectionContent: match[0],
5454
podfilePlatformData: {
5555
path: match[1].trim(),
56-
content: "",
57-
version: match[2]
56+
content: match[2],
57+
version: match[3]
5858
}
5959
};
6060
}
@@ -104,7 +104,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager {
104104
const appResourcesPodfilePath = path.join(projectData.getAppResourcesDirectoryPath(), "iOS", PODFILE_NAME);
105105
const isFromAppResources = oldPodfilePlatformData.path !== appResourcesPodfilePath && currentPodfilePlatformData.path === appResourcesPodfilePath;
106106
const isFromAppResourcesWithGreaterPlatformVersion = oldPodfilePlatformData.path === appResourcesPodfilePath && currentPodfilePlatformData.path === appResourcesPodfilePath && semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version));
107-
const isPodfileWithGreaterPlatformVersion = !currentPodfilePlatformData.version || semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version));
107+
const isPodfileWithGreaterPlatformVersion = !currentPodfilePlatformData.version || (oldPodfilePlatformData.version && semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version)));
108108
const result = isFromAppResources || isFromAppResourcesWithGreaterPlatformVersion || isPodfileWithGreaterPlatformVersion;
109109
return result;
110110
}

0 commit comments

Comments
 (0)