-
-
Notifications
You must be signed in to change notification settings - Fork 201
Work correctly if iOS runtime version is lower than 1.3 #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import * as path from "path"; | |
| import * as shell from "shelljs"; | ||
| import * as util from "util"; | ||
| import * as os from "os"; | ||
| import * as semver from "semver"; | ||
| import * as xcode from "xcode"; | ||
| import * as constants from "../constants"; | ||
| import * as helpers from "../common/helpers"; | ||
|
|
@@ -28,7 +29,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
| private $logger: ILogger, | ||
| private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices, | ||
| private $options: IOptions, | ||
| private $injector: IInjector) { | ||
| private $injector: IInjector, | ||
| private $projectDataService: IProjectDataService) { | ||
| super($fs); | ||
| } | ||
|
|
||
|
|
@@ -39,7 +41,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
| frameworkPackageName: "tns-ios", | ||
| normalizedPlatformName: "iOS", | ||
| appDestinationDirectoryPath: path.join(projectRoot, this.$projectData.projectName), | ||
| appResourcesDestinationDirectoryPath: path.join(projectRoot, this.$projectData.projectName, "Resources"), | ||
| platformProjectService: this, | ||
| emulatorServices: this.$iOSEmulatorServices, | ||
| projectRoot: projectRoot, | ||
|
|
@@ -61,6 +62,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
| }; | ||
| } | ||
|
|
||
| public getAppResourcesDestinationDirectoryPath(): IFuture<string> { | ||
| return (() => { | ||
| this.$projectDataService.initialize(this.$projectData.projectDir); | ||
| let frameworkVersion = this.$projectDataService.getValue(this.platformData.frameworkPackageName).wait()["version"]; | ||
|
|
||
| if(semver.lt(frameworkVersion, "1.3.0")) { | ||
| return path.join(this.platformData.projectRoot, this.$projectData.projectName, "Resources", "icons"); | ||
| } | ||
|
|
||
| return path.join(this.platformData.projectRoot, this.$projectData.projectName, "Resources"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both return statements build the same path - is this expected?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The paths are different -
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh dear, the last part ("icons") went on another line on my monitor and I missed it completely. I am so sorry. |
||
| }).future<string>()(); | ||
| } | ||
|
|
||
| public validate(): IFuture<void> { | ||
| return (() => { | ||
| try { | ||
|
|
@@ -258,25 +272,27 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ | |
| this.$logger.trace("Images from Xcode project"); | ||
| this.$logger.trace(xcodeProjectImages); | ||
|
|
||
| let appResourcesImages = this.$fs.readDirectory(this.platformData.appResourcesDestinationDirectoryPath).wait(); | ||
| let appResourcesImages = this.$fs.readDirectory(this.getAppResourcesDestinationDirectoryPath().wait()).wait(); | ||
| this.$logger.trace("Current images from App_Resources"); | ||
| this.$logger.trace(appResourcesImages); | ||
|
|
||
| let imagesToAdd = _.difference(appResourcesImages, xcodeProjectImages); | ||
| this.$logger.trace(`New images to add into xcode project: ${imagesToAdd.join(", ")}`); | ||
| _.each(imagesToAdd, image => project.addResourceFile(path.relative(this.platformData.projectRoot, path.join( this.platformData.appResourcesDestinationDirectoryPath, image)))); | ||
| _.each(imagesToAdd, image => project.addResourceFile(path.relative(this.platformData.projectRoot, path.join(this.getAppResourcesDestinationDirectoryPath().wait(), image)))); | ||
|
|
||
| let imagesToRemove = _.difference(xcodeProjectImages, appResourcesImages); | ||
| this.$logger.trace(`Images to remove from xcode project: ${imagesToRemove.join(", ")}`); | ||
| _.each(imagesToRemove, image => project.removeResourceFile(path.join(this.platformData.appResourcesDestinationDirectoryPath, image))); | ||
| _.each(imagesToRemove, image => project.removeResourceFile(path.join(this.getAppResourcesDestinationDirectoryPath().wait(), image))); | ||
|
|
||
| this.savePbxProj(project).wait(); | ||
| } | ||
| }).future<void>()(); | ||
| } | ||
|
|
||
| public prepareAppResources(appResourcesDirectoryPath: string): IFuture<void> { | ||
| return this.$fs.deleteDirectory(this.platformData.appResourcesDestinationDirectoryPath); | ||
| return (() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can unwrap the return -> wait -> future chain
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I feel stupid :( |
||
| this.$fs.deleteDirectory(this.getAppResourcesDestinationDirectoryPath().wait()).wait(); | ||
| }).future<void>()(); | ||
| } | ||
|
|
||
| private get projectPodFilePath(): string { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may use future.fromResult here