Skip to content

Commit 88bbeeb

Browse files
author
Fatme
authored
Merge pull request #4529 from NativeScript/fatme/remove-legacy-code
chore: remove legacy code from ios-project-service
2 parents 7a68fa7 + 4eee604 commit 88bbeeb

7 files changed

+3
-164
lines changed

lib/definitions/plugins.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ interface IPluginsService {
1010
* @returns {IPackageJsonDepedenciesResult}
1111
*/
1212
getDependenciesFromPackageJson(projectDir: string): IPackageJsonDepedenciesResult;
13-
validate(platformData: IPlatformData, projectData: IProjectData): Promise<void>;
1413
preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void>;
1514
convertToPluginData(cacheData: any, projectDir: string): IPluginData;
1615
isNativeScriptPlugin(pluginPackageJsonPath: string): boolean;

lib/definitions/project.d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
372372
*/
373373
validateOptions(projectId?: string, provision?: true | string, teamId?: true | string): Promise<boolean>;
374374

375-
validatePlugins(projectData: IProjectData): Promise<void>;
376-
377375
buildProject(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise<void>;
378376

379377
/**

lib/services/android-project-service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
145145
};
146146
}
147147

148-
public async validatePlugins(): Promise<void> { /* */ }
149-
150148
public async createProject(frameworkDir: string, frameworkVersion: string, projectData: IProjectData, config: ICreateProjectOptions): Promise<void> {
151149
if (semver.lt(frameworkVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE)) {
152150
this.$errors.failWithoutHelp(`The NativeScript CLI requires Android runtime ${AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE} or later to work properly.`);

lib/services/ios-project-service.ts

+3-149
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
5050
private $iOSEntitlementsService: IOSEntitlementsService,
5151
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
5252
private $plistParser: IPlistParser,
53-
private $sysInfo: ISysInfo,
5453
private $xcconfigService: IXcconfigService,
5554
private $iOSExtensionsService: IIOSExtensionsService) {
5655
super($fs, $projectDataService);
@@ -110,25 +109,17 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
110109
if (provision === true) {
111110
await this.$iOSProvisionService.listProvisions(projectId);
112111
this.$errors.failWithoutHelp("Please provide provisioning profile uuid or name with the --provision option.");
113-
return false;
114112
}
115113

116114
if (teamId === true) {
117115
await this.$iOSProvisionService.listTeams();
118116
this.$errors.failWithoutHelp("Please provide team id or team name with the --teamId options.");
119-
return false;
120117
}
121118

122119
return true;
123120
}
124121

125122
public getAppResourcesDestinationDirectoryPath(projectData: IProjectData): string {
126-
const frameworkVersion = this.getFrameworkVersion(projectData);
127-
128-
if (semver.lt(frameworkVersion, "1.3.0")) {
129-
return path.join(this.getPlatformData(projectData).projectRoot, projectData.projectName, "Resources", "icons");
130-
}
131-
132123
return path.join(this.getPlatformData(projectData).projectRoot, projectData.projectName, "Resources");
133124
}
134125

@@ -342,12 +333,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
342333
'SHARED_PRECOMPS_DIR=' + path.join(projectRoot, 'build', 'sharedpch')
343334
];
344335

345-
// Starting from tns-ios 1.4 the xcconfig file is referenced in the project template
346-
const frameworkVersion = this.getFrameworkVersion(projectData);
347-
if (semver.lt(frameworkVersion, "1.4.0")) {
348-
basicArgs.push("-xcconfig", path.join(projectRoot, projectData.projectName, BUILD_XCCONFIG_FILE_NAME));
349-
}
350-
351336
const handler = (data: any) => {
352337
this.emit(constants.BUILD_OUTPUT_EVENT_NAME, data);
353338
};
@@ -367,17 +352,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
367352
this.validateApplicationIdentifier(projectData);
368353
}
369354

370-
public async validatePlugins(projectData: IProjectData): Promise<void> {
371-
const installedPlugins = await (<IPluginsService>this.$injector.resolve("pluginsService")).getAllInstalledPlugins(projectData);
372-
for (const pluginData of installedPlugins) {
373-
const pluginsFolderExists = this.$fs.exists(path.join(pluginData.pluginPlatformsFolderPath(this.$devicePlatformsConstants.iOS.toLowerCase()), "Podfile"));
374-
const cocoaPodVersion = await this.$sysInfo.getCocoaPodsVersion();
375-
if (pluginsFolderExists && !cocoaPodVersion) {
376-
this.$errors.failWithoutHelp(`${pluginData.name} has Podfile and you don't have Cocoapods installed or it is not configured correctly. Please verify Cocoapods can work on your machine.`);
377-
}
378-
}
379-
}
380-
381355
private async buildForDevice(projectRoot: string, args: string[], buildConfig: IBuildConfig, projectData: IProjectData): Promise<void> {
382356
if (!buildConfig.release && !buildConfig.architectures) {
383357
await this.$devicesService.initialize({
@@ -406,24 +380,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
406380
"BUILD_DIR=" + path.join(projectRoot, constants.BUILD_DIR)
407381
]);
408382

409-
const xcodeBuildVersion = await this.getXcodeVersion();
410-
if (helpers.versionCompare(xcodeBuildVersion, "8.0") >= 0) {
411-
await this.setupSigningForDevice(projectRoot, buildConfig, projectData);
412-
}
383+
await this.setupSigningForDevice(projectRoot, buildConfig, projectData);
413384

414385
await this.createIpa(projectRoot, projectData, buildConfig, args);
415386
}
416387

417388
private async xcodebuild(args: string[], cwd: string, stdio: any = "inherit"): Promise<ISpawnResult> {
418389
const localArgs = [...args];
419-
const xcodeBuildVersion = await this.getXcodeVersion();
420-
try {
421-
if (helpers.versionCompare(xcodeBuildVersion, "9.0") >= 0) {
422-
localArgs.push("-allowProvisioningUpdates");
423-
}
424-
} catch (e) {
425-
this.$logger.warn("Failed to detect whether -allowProvisioningUpdates can be used with your xcodebuild version due to error: " + e);
426-
}
390+
localArgs.push("-allowProvisioningUpdates");
391+
427392
if (this.$logger.getLevel() === "INFO") {
428393
localArgs.push("-quiet");
429394
this.$logger.info("Xcode build...");
@@ -650,87 +615,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
650615
return contentIsTheSame;
651616
}
652617

653-
/**
654-
* Patch **LaunchScreen.xib** so we can be backward compatible for eternity.
655-
* The **xcodeproj** template proior v**2.1.0** had blank white screen launch screen.
656-
* We extended that by adding **app/AppResources/iOS/LaunchScreen.storyboard**
657-
* However for projects created prior **2.1.0** to keep working without the obsolete **LaunchScreen.xib**
658-
* we must still provide it on prepare.
659-
* Here we check if **UILaunchStoryboardName** is set to **LaunchScreen** in the **platform/ios/<proj>/<proj>-Info.plist**.
660-
* If it is, and no **LaunchScreen.storyboard** nor **.xib** is found in the project, we will create one.
661-
*/
662-
private provideLaunchScreenIfMissing(projectData: IProjectData): void {
663-
try {
664-
this.$logger.trace("Checking if we need to provide compatability LaunchScreen.xib");
665-
const platformData = this.getPlatformData(projectData);
666-
const projectPath = path.join(platformData.projectRoot, projectData.projectName);
667-
const projectPlist = this.getInfoPlistPath(projectData);
668-
const plistContent = plist.parse(this.$fs.readText(projectPlist));
669-
const storyName = plistContent["UILaunchStoryboardName"];
670-
this.$logger.trace(`Examining ${projectPlist} UILaunchStoryboardName: "${storyName}".`);
671-
if (storyName !== "LaunchScreen") {
672-
this.$logger.trace("The project has its UILaunchStoryboardName set to " + storyName + " which is not the pre v2.1.0 default LaunchScreen, probably the project is migrated so we are good to go.");
673-
return;
674-
}
675-
676-
const expectedStoryPath = path.join(projectPath, "Resources", "LaunchScreen.storyboard");
677-
if (this.$fs.exists(expectedStoryPath)) {
678-
// Found a LaunchScreen on expected path
679-
this.$logger.trace("LaunchScreen.storyboard was found. Project is up to date.");
680-
return;
681-
}
682-
this.$logger.trace("LaunchScreen file not found at: " + expectedStoryPath);
683-
684-
const expectedXibPath = path.join(projectPath, "en.lproj", "LaunchScreen.xib");
685-
if (this.$fs.exists(expectedXibPath)) {
686-
this.$logger.trace("Obsolete LaunchScreen.xib was found. It'k OK, we are probably running with iOS runtime from pre v2.1.0.");
687-
return;
688-
}
689-
this.$logger.trace("LaunchScreen file not found at: " + expectedXibPath);
690-
691-
const isTheLaunchScreenFile = (fileName: string) => fileName === "LaunchScreen.xib" || fileName === "LaunchScreen.storyboard";
692-
const matches = this.$fs.enumerateFilesInDirectorySync(projectPath, isTheLaunchScreenFile, { enumerateDirectories: false });
693-
if (matches.length > 0) {
694-
this.$logger.trace("Found LaunchScreen by slowly traversing all files here: " + matches + "\nConsider moving the LaunchScreen so it could be found at: " + expectedStoryPath);
695-
return;
696-
}
697-
698-
const compatabilityXibPath = path.join(projectPath, "Resources", "LaunchScreen.xib");
699-
this.$logger.warn(`Failed to find LaunchScreen.storyboard but it was specified in the Info.plist.
700-
Consider updating the resources in app/App_Resources/iOS/.
701-
A good starting point would be to create a new project and diff the changes with your current one.
702-
Also the following repo may be helpful: https://github.com/NativeScript/template-hello-world/tree/master/App_Resources/iOS
703-
We will now place an empty obsolete compatability white screen LauncScreen.xib for you in ${path.relative(projectData.projectDir, compatabilityXibPath)} so your app may appear as it did in pre v2.1.0 versions of the ios runtime.`);
704-
705-
const content = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
706-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
707-
<dependencies>
708-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
709-
</dependencies>
710-
<objects>
711-
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
712-
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
713-
<view contentMode="scaleToFill" id="iN0-l3-epB">
714-
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
715-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
716-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
717-
<nil key="simulatedStatusBarMetrics"/>
718-
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
719-
<point key="canvasLocation" x="548" y="455"/>
720-
</view>
721-
</objects>
722-
</document>`;
723-
try {
724-
this.$fs.createDirectory(path.dirname(compatabilityXibPath));
725-
this.$fs.writeFile(compatabilityXibPath, content);
726-
} catch (e) {
727-
this.$logger.warn("We have failed to add compatability LaunchScreen.xib due to: " + e);
728-
}
729-
} catch (e) {
730-
this.$logger.warn("We have failed to check if we need to add a compatability LaunchScreen.xib due to: " + e);
731-
}
732-
}
733-
734618
public async prepareProject(projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<void> {
735619
const projectRoot = path.join(projectData.platformsDir, "ios");
736620

@@ -745,8 +629,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
745629

746630
const project = this.createPbxProj(projectData);
747631

748-
this.provideLaunchScreenIfMissing(projectData);
749-
750632
const resources = project.pbxGroupByName("Resources");
751633

752634
if (resources) {
@@ -801,14 +683,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
801683
await this.mergeProjectXcconfigFiles(projectData, opts);
802684
}
803685

804-
private getInfoPlistPath(projectData: IProjectData): string {
805-
return path.join(
806-
projectData.appResourcesDirectoryPath,
807-
this.getPlatformData(projectData).normalizedPlatformName,
808-
this.getPlatformData(projectData).configurationFileName
809-
);
810-
}
811-
812686
public ensureConfigurationFileInAppResources(): void {
813687
return null;
814688
}
@@ -826,11 +700,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
826700
const infoPlistPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
827701
this.ensureConfigurationFileInAppResources();
828702

829-
if (!this.$fs.exists(infoPlistPath)) {
830-
this.$logger.trace("Info.plist: No app/App_Resources/iOS/Info.plist found, falling back to pre-1.6.0 Info.plist behavior.");
831-
return;
832-
}
833-
834703
const reporterTraceMessage = "Info.plist:";
835704
const reporter: Reporter = {
836705
log: (txt: string) => this.$logger.trace(`${reporterTraceMessage} ${txt}`),
@@ -1244,21 +1113,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12441113
}
12451114
}
12461115

1247-
private async getXcodeVersion(): Promise<string> {
1248-
let xcodeBuildVersion = "";
1249-
1250-
try {
1251-
xcodeBuildVersion = await this.$sysInfo.getXcodeVersion();
1252-
} catch (error) {
1253-
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
1254-
}
1255-
1256-
const splitedXcodeBuildVersion = xcodeBuildVersion.split(".");
1257-
xcodeBuildVersion = `${splitedXcodeBuildVersion[0] || 0}.${splitedXcodeBuildVersion[1] || 0}`;
1258-
1259-
return xcodeBuildVersion;
1260-
}
1261-
12621116
private getBuildXCConfigFilePath(projectData: IProjectData): string {
12631117
const buildXCConfig = path.join(projectData.appResourcesDirectoryPath,
12641118
this.getPlatformData(projectData).normalizedPlatformName, BUILD_XCCONFIG_FILE_NAME);

lib/services/plugins-service.ts

-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export class PluginsService implements IPluginsService {
8787
}
8888
}
8989

90-
public async validate(platformData: IPlatformData, projectData: IProjectData): Promise<void> {
91-
return await platformData.platformProjectService.validatePlugins(projectData);
92-
}
93-
9490
public async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void> {
9591
const platformData = this.$platformsData.getPlatformData(platform, projectData);
9692
pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform.toLowerCase());

lib/services/prepare-platform-native-service.ts

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export class PreparePlatformNativeService extends PreparePlatformService impleme
99
$xmlValidator: IXmlValidator,
1010
$hooksService: IHooksService,
1111
private $nodeModulesBuilder: INodeModulesBuilder,
12-
private $pluginsService: IPluginsService,
1312
private $projectChangesService: IProjectChangesService,
1413
private $androidResourcesMigrationService: IAndroidResourcesMigrationService) {
1514
super($fs, $hooksService, $xmlValidator);
@@ -46,8 +45,6 @@ export class PreparePlatformNativeService extends PreparePlatformService impleme
4645
const hasConfigChange = !config.changesInfo || config.changesInfo.configChanged;
4746

4847
if (hasModulesChange) {
49-
await this.$pluginsService.validate(config.platformData, config.projectData);
50-
5148
const appDestinationDirectoryPath = path.join(config.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
5249
const lastModifiedTime = this.$fs.exists(appDestinationDirectoryPath) ? this.$fs.getFsStats(appDestinationDirectoryPath).mtime : null;
5350

test/stubs.ts

-3
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,6 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
398398
validate(): Promise<IValidatePlatformOutput> {
399399
return Promise.resolve(<IValidatePlatformOutput>{});
400400
}
401-
validatePlugins(projectData: IProjectData) {
402-
return Promise.resolve();
403-
}
404401
async createProject(projectRoot: string, frameworkDir: string): Promise<void> {
405402
return Promise.resolve();
406403
}

0 commit comments

Comments
 (0)