Skip to content

Commit b5fef05

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # lib/controllers/build-controller.ts # lib/services/device/device-install-app-service.ts # package-lock.json # yarn.lock
2 parents 51ca951 + e341c31 commit b5fef05

16 files changed

+607
-30283
lines changed

lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ export type SupportedPlatform = PlatformTypes.ios | PlatformTypes.android;
335335

336336
export const PODFILE_NAME = "Podfile";
337337

338+
export const EXTENSION_PROVISIONING_FILENAME = "provisioning.json";
339+
338340
export class IosProjectConstants {
339341
public static XcodeProjExtName = ".xcodeproj";
340342
public static XcodeSchemeExtName = ".xcscheme";

lib/controllers/build-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class BuildController extends EventEmitter implements IBuildController {
116116
);
117117

118118
if (buildData.copyTo) {
119-
this.$buildArtifactsService.copyLatestAppPackage(
119+
this.$buildArtifactsService.copyAppPackages(
120120
buildData.copyTo,
121121
platformData,
122122
buildData

lib/declarations.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ interface IProvision {
530530
provision: string;
531531
}
532532

533+
interface IProvisioningJSON {
534+
[identifier: string]: string;
535+
}
536+
533537
interface ITeamIdentifier {
534538
teamId: string;
535539
}

lib/definitions/project.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,11 @@ interface ICocoaPodsService {
652652
platformData: IPlatformData
653653
): Promise<void>;
654654

655+
applyPodfileFromExtensions(
656+
projectData: IProjectData,
657+
platformData: IPlatformData
658+
): Promise<void>;
659+
655660
/**
656661
* Prepares the Podfile content of a plugin and merges it in the project's Podfile.
657662
* @param {string} moduleName The module which the Podfile is from.

lib/services/cocoapods-service.ts

Lines changed: 97 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "../common/declarations";
2222
import { injector } from "../common/yok";
2323
import { XcodeSelectService } from "../common/services/xcode-select-service";
24+
import * as constants from "../constants";
2425

2526
export class CocoaPodsService implements ICocoaPodsService {
2627
private static PODFILE_POST_INSTALL_SECTION_NAME = "post_install";
@@ -121,9 +122,10 @@ ${versionResolutionHint}`);
121122
);
122123
const podFolder = path.join(platformData.projectRoot, podFilesRootDirName);
123124
if (this.$fs.exists(podFolder)) {
124-
const pluginsXcconfigFilePaths = this.$xcconfigService.getPluginsXcconfigFilePaths(
125-
platformData.projectRoot
126-
);
125+
const pluginsXcconfigFilePaths =
126+
this.$xcconfigService.getPluginsXcconfigFilePaths(
127+
platformData.projectRoot
128+
);
127129
for (const configuration in pluginsXcconfigFilePaths) {
128130
const pluginsXcconfigFilePath = pluginsXcconfigFilePaths[configuration];
129131
const podXcconfigFilePath = path.join(
@@ -199,6 +201,71 @@ end`.trim();
199201
this.$fs.deleteFile(exclusionsPodfile);
200202
}
201203

204+
public async applyPodfileFromExtensions(
205+
projectData: IProjectData,
206+
platformData: IPlatformData
207+
) {
208+
const extensionFolderPath = path.join(
209+
projectData.getAppResourcesDirectoryPath(),
210+
constants.iOSAppResourcesFolderName,
211+
constants.NATIVE_EXTENSION_FOLDER
212+
);
213+
const projectPodfilePath = this.getProjectPodfilePath(
214+
platformData.projectRoot
215+
);
216+
217+
if (
218+
!this.$fs.exists(extensionFolderPath) ||
219+
!this.$fs.exists(projectPodfilePath)
220+
) {
221+
return;
222+
}
223+
224+
let projectPodFileContent = this.$fs.readText(projectPodfilePath);
225+
226+
const extensionsPodfile = this.$fs
227+
.readDirectory(extensionFolderPath)
228+
.filter((name) => {
229+
const extensionPath = path.join(extensionFolderPath, name);
230+
const stats = this.$fs.getFsStats(extensionPath);
231+
return stats.isDirectory() && !name.startsWith(".");
232+
})
233+
.map((name) => ({
234+
targetName: name,
235+
podfilePath: path.join(
236+
extensionFolderPath,
237+
name,
238+
constants.PODFILE_NAME
239+
),
240+
}));
241+
242+
extensionsPodfile.forEach(({ targetName, podfilePath }) => {
243+
// Remove the data between #Begin Podfile and #EndPodfile
244+
const regExpToRemove = new RegExp(
245+
`${this.getExtensionPodfileHeader(
246+
podfilePath,
247+
targetName
248+
)}[\\s\\S]*?${this.getExtensionPodfileEnd()}`,
249+
"mg"
250+
);
251+
projectPodFileContent = projectPodFileContent.replace(regExpToRemove, "");
252+
253+
if (this.$fs.exists(podfilePath)) {
254+
const podfileContentWithoutTarget = this.$fs.readText(podfilePath);
255+
const podFileContent =
256+
this.getExtensionPodfileHeader(podfilePath, targetName) +
257+
EOL +
258+
podfileContentWithoutTarget +
259+
EOL +
260+
this.getExtensionPodfileEnd();
261+
262+
projectPodFileContent += EOL + podFileContent;
263+
}
264+
});
265+
266+
this.$fs.writeFile(projectPodfilePath, projectPodFileContent);
267+
}
268+
202269
public async applyPodfileToProject(
203270
moduleName: string,
204271
podfilePath: string,
@@ -216,16 +283,13 @@ end`.trim();
216283
return;
217284
}
218285

219-
const {
220-
podfileContent,
221-
replacedFunctions,
222-
podfilePlatformData,
223-
} = this.buildPodfileContent(
224-
podfilePath,
225-
moduleName,
226-
projectData,
227-
platformData
228-
);
286+
const { podfileContent, replacedFunctions, podfilePlatformData } =
287+
this.buildPodfileContent(
288+
podfilePath,
289+
moduleName,
290+
projectData,
291+
platformData
292+
);
229293
const pathToProjectPodfile = this.getProjectPodfilePath(nativeProjectPath);
230294
const projectPodfileContent = this.$fs.exists(pathToProjectPodfile)
231295
? this.$fs.readText(pathToProjectPodfile).trim()
@@ -297,11 +361,12 @@ end`.trim();
297361
moduleName,
298362
projectPodFileContent
299363
);
300-
projectPodFileContent = this.$cocoaPodsPlatformManager.removePlatformSection(
301-
moduleName,
302-
projectPodFileContent,
303-
podfilePath
304-
);
364+
projectPodFileContent =
365+
this.$cocoaPodsPlatformManager.removePlatformSection(
366+
moduleName,
367+
projectPodFileContent,
368+
podfilePath
369+
);
305370

306371
const defaultPodfileBeginning = this.getPodfileHeader(
307372
projectData.projectName
@@ -496,6 +561,20 @@ end`.trim();
496561
return `# End Podfile${EOL}`;
497562
}
498563

564+
private getExtensionPodfileHeader(
565+
extensionPodFilePath: string,
566+
targetName: string
567+
): string {
568+
const targetHeader = `target "${targetName.trim()}" do`;
569+
return `${this.getPluginPodfileHeader(
570+
extensionPodFilePath
571+
)}${EOL}${targetHeader}`;
572+
}
573+
574+
private getExtensionPodfileEnd(): string {
575+
return `end${EOL}${this.getPluginPodfileEnd()}`;
576+
}
577+
499578
private getPostInstallHookHeader() {
500579
return `${CocoaPodsService.PODFILE_POST_INSTALL_SECTION_NAME} do |${CocoaPodsService.INSTALLER_BLOCK_PARAMETER_NAME}|${EOL}`;
501580
}

lib/services/device/device-install-app-service.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class DeviceInstallAppService {
5050
});
5151
const buildOutputOptions = platformData.getValidBuildOutputData(buildData);
5252
const outputPath = buildData.outputPath || platformData.getBuildOutputPath(buildData);
53-
const packages = await this.$buildArtefactsService.getAllAppPackages(
53+
const packages = await this.$buildArtifactsService.getAllAppPackages(
5454
outputPath,
5555
buildOutputOptions
5656
);
@@ -76,11 +76,8 @@ export class DeviceInstallAppService {
7676
}
7777

7878
if (!packageFile) {
79-
// this.$logger.error(
80-
// `Could not find a package corresponding to the device with identifier '${device.deviceInfo.identifier}'.`);
81-
packageFile = await this.$buildArtifactsService.getLatestAppPackagePath(
82-
platformData,
83-
buildData
79+
this.$logger.error(
80+
`Could not find a package corresponding to the device with identifier '${device.deviceInfo.identifier}'.`
8481
);
8582
return;
8683
}

lib/services/ios-native-target-service.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { injector } from "../common/yok";
1313
export class IOSNativeTargetService implements IIOSNativeTargetService {
1414
constructor(
1515
protected $fs: IFileSystem,
16-
protected $pbxprojDomXcode: IPbxprojDomXcode
16+
protected $pbxprojDomXcode: IPbxprojDomXcode,
17+
protected $logger: ILogger
1718
) {}
1819

1920
public addTargetToProject(
@@ -141,19 +142,51 @@ export class IOSNativeTargetService implements IIOSNativeTargetService {
141142
targetUuid
142143
);
143144
}
145+
const properties: IXcodeTargetBuildConfigurationProperty[] = [];
144146

147+
// Set for both release and debug
145148
if (configurationJson.targetBuildConfigurationProperties) {
146-
const properties: IXcodeTargetBuildConfigurationProperty[] = [];
147149
_.forEach(
148150
configurationJson.targetBuildConfigurationProperties,
149151
(value, name: string) => properties.push({ value, name })
150152
);
151-
this.setXcodeTargetBuildConfigurationProperties(
152-
properties,
153-
targetName,
154-
project
153+
}
154+
155+
if (configurationJson.targetNamedBuildConfigurationProperties) {
156+
_.forEach(
157+
configurationJson.targetNamedBuildConfigurationProperties,
158+
(value, name: string) => {
159+
var buildName: BuildNames = null;
160+
switch (name) {
161+
case "debug": {
162+
buildName = BuildNames.debug;
163+
break;
164+
}
165+
case "release": {
166+
buildName = BuildNames.release;
167+
break;
168+
}
169+
default: {
170+
this.$logger.warn(
171+
"Ignoring targetNamedBuildConfigurationProperties: %s. Only 'release', 'debug' are allowed.",
172+
name
173+
);
174+
}
175+
}
176+
if (buildName) {
177+
_.forEach(value, (value, name: string) =>
178+
properties.push({ value, name, buildNames: [buildName] })
179+
);
180+
}
181+
}
155182
);
156183
}
184+
185+
this.setXcodeTargetBuildConfigurationProperties(
186+
properties,
187+
targetName,
188+
project
189+
);
157190
}
158191
}
159192
}

0 commit comments

Comments
 (0)