Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/services/cocoapods-platform-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager {
}

private getPlatformSectionData(projectPodfileContent: string): { podfilePlatformData: IPodfilePlatformData, platformSectionContent: string } {
const platformSectionRegExp = new RegExp(`${this.getPlatformSectionHeader()} ([\\s\\S]*?)with (.*)[\\s\\S]*?${this.getPlatformSectionFooter()}`, "m");
const platformSectionRegExp = new RegExp(`${this.getPlatformSectionHeader()} ([\\s\\S]*?)with[\\s\\S]*?\\n([\\s\\S]*?(?:,\\s*?['"](.+)['"])?)\\n${this.getPlatformSectionFooter()}`, "m");
const match = platformSectionRegExp.exec(projectPodfileContent);
let result = null;
if (match && match[0]) {
result = {
platformSectionContent: match[0],
podfilePlatformData: {
path: match[1].trim(),
content: "",
version: match[2]
content: match[2],
version: match[3]
}
};
}
Expand Down Expand Up @@ -104,7 +104,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager {
const appResourcesPodfilePath = path.join(projectData.getAppResourcesDirectoryPath(), "iOS", PODFILE_NAME);
const isFromAppResources = oldPodfilePlatformData.path !== appResourcesPodfilePath && currentPodfilePlatformData.path === appResourcesPodfilePath;
const isFromAppResourcesWithGreaterPlatformVersion = oldPodfilePlatformData.path === appResourcesPodfilePath && currentPodfilePlatformData.path === appResourcesPodfilePath && semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version));
const isPodfileWithGreaterPlatformVersion = !currentPodfilePlatformData.version || semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version));
const isPodfileWithGreaterPlatformVersion = !currentPodfilePlatformData.version || (oldPodfilePlatformData.version && semver.gt(semver.coerce(currentPodfilePlatformData.version), semver.coerce(oldPodfilePlatformData.version)));
const result = isFromAppResources || isFromAppResourcesWithGreaterPlatformVersion || isPodfileWithGreaterPlatformVersion;
return result;
}
Expand Down
33 changes: 33 additions & 0 deletions test/cocoapods-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,39 @@ target "projectName" do
# platform :ios, '10.0'
# End Podfile

# Begin Podfile - node_modules/myPluginWithoutPlatform/Podfile
pod 'myPod' ~> 0.3.4
# End Podfile# NativeScriptPlatformSection node_modules/myFirstPluginWithPlatform/Podfile with
platform :ios
# End NativeScriptPlatformSection
end`
},
{
name: "shouldn't replace the platform without version when no Podfile in App_Resources",
pods: [{
name: 'myPluginWithoutPlatform',
path: 'node_modules/myPluginWithoutPlatform/Podfile',
content: `pod 'myPod' ~> 0.3.4`
}, {
name: 'myFirstPluginWithPlatform',
path: 'node_modules/myFirstPluginWithPlatform/Podfile',
content: `platform :ios`
}, {
name: 'mySecondPluginWithPlatform',
path: 'node_modules/mySecondPluginWithPlatform/Podfile',
content: `platform :ios, '10.0'`
}],
expectedProjectPodfileContent: `use_frameworks!

target "projectName" do
# Begin Podfile - node_modules/mySecondPluginWithPlatform/Podfile
# platform :ios, '10.0'
# End Podfile

# Begin Podfile - node_modules/myFirstPluginWithPlatform/Podfile
# platform :ios
# End Podfile

# Begin Podfile - node_modules/myPluginWithoutPlatform/Podfile
pod 'myPod' ~> 0.3.4
# End Podfile# NativeScriptPlatformSection node_modules/myFirstPluginWithPlatform/Podfile with
Expand Down