Skip to content

Commit 9a8891f

Browse files
committed
Merge pull request #1806 from NativeScript/cankov/xcarchive-publish
Add archive and exportArchive for iOS.
2 parents e2f6242 + 15c7919 commit 9a8891f

File tree

114 files changed

+676
-386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+676
-386
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ scratch/
2828
*.suo
2929
.travis.yml
3030
docs/html/
31+
dev/

Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ module.exports = function(grunt) {
3939
},
4040

4141
devlib: {
42-
src: ["lib/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
42+
src: ["lib/**/*.ts", "!lib/common/node_modules/**/*.ts"],
4343
reference: "lib/.d.ts"
4444
},
4545

4646
devall: {
47-
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!lib/common/test/.d.ts"],
47+
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!lib/common/test/.d.ts"],
4848
reference: "lib/.d.ts"
4949
},
5050

5151
release_build: {
52-
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
52+
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts"],
5353
reference: "lib/.d.ts",
5454
options: {
5555
sourceMap: false,

dev/tsc-to-mocha-watch.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Run "tsc" with watch, upon successful compilation run mocha tests.
2+
3+
var child_process = require("child_process");
4+
var spawn = child_process.spawn;
5+
var readline = require("readline");
6+
var chalk = require("chalk");
7+
8+
var mocha = null;
9+
var mochal = null;
10+
var errors = 0;
11+
12+
function compilationStarted() {
13+
if (mocha) {
14+
mocha.kill('SIGINT');
15+
}
16+
mocha = null;
17+
mochal = null;
18+
errors = 0;
19+
}
20+
function foundErrors() {
21+
errors ++;
22+
}
23+
function compilationComplete() {
24+
if (errors) {
25+
console.log(" " + chalk.red("TS errors. Will not start mocha."));
26+
return;
27+
} else {
28+
console.log(" " + chalk.gray("Run mocha."));
29+
}
30+
mocha = spawn("./node_modules/.bin/mocha", ["--colors"]);
31+
mocha.on('close', code => {
32+
if (code) {
33+
console.log(chalk.gray("mocha: ") + "Exited with " + code);
34+
} else {
35+
console.log(chalk.gray("mocha: ") + chalk.red("Exited with " + code));
36+
}
37+
mocha = null;
38+
mochal = null;
39+
});
40+
mochal = readline.createInterface({ input: mocha.stdout });
41+
mochal.on('line', line => {
42+
console.log(chalk.gray('mocha: ') + line);
43+
});
44+
}
45+
46+
var tsc = spawn("./node_modules/.bin/tsc", ["--watch"]);
47+
var tscl = readline.createInterface({ input: tsc.stdout });
48+
tscl.on('line', line => {
49+
console.log(chalk.gray(" tsc: ") + line);
50+
if (line.indexOf("Compilation complete.") >= 0) {
51+
compilationComplete();
52+
} else if (line.indexOf("File change detected.") >= 0) {
53+
compilationStarted();
54+
} else if (line.indexOf(": error TS") >= 0) {
55+
foundErrors();
56+
}
57+
});

docs/man_pages/publishing/appstore.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Lists all application records in iTunes Connect. The list contains name, version
1212
<% if(isHtml) { %>
1313
`<Apple ID>` and `<Password>` are your credentials for logging in iTunes Connect. If you do not provide them when running the command, the NativeScript CLI will prompt you to provide them.
1414

15+
### Options
16+
* `--team-id` - Specified the team id for which Xcode will try to find distribution certificate and provisioning profile when exporting for AppStore submission.
17+
1518
### Command Limitations
1619

1720
* You can run `$ tns appstore upload` only on OS X systems.

docs/man_pages/publishing/publish-ios.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Uploads project to iTunes Connect. The command either issues a production build
1313

1414
### Options
1515
* `--ipa` - If set, will use provided .ipa file instead of building the project.
16+
* `--team-id` - Specified the team id for which Xcode will try to find distribution certificate and provisioning profile when exporting for AppStore submission.
1617

1718
### Attributes
1819
* `<Apple ID>` and `<Password>` are your credentials for logging into iTunes Connect.

lib/android-tools-info.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path=".d.ts"/>
2-
"use strict";
3-
41
import * as path from "path";
52
import * as semver from "semver";
63
import {EOL} from "os";

lib/bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ $injector.require("iOSNotificationService", "./services/ios-notification-service
108108
$injector.require("socketProxyFactory", "./device-sockets/ios/socket-proxy-factory");
109109
$injector.require("iOSNotification", "./device-sockets/ios/notification");
110110
$injector.require("iOSSocketRequestExecutor", "./device-sockets/ios/socket-request-executor");
111-
$injector.require("messages", "./messages");
111+
$injector.require("messages", "./common/messages/messages");
112112
$injector.require("xmlValidator", "./xml-validator");

lib/commands/add-platform.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class AddPlatformCommand implements ICommand {
52
constructor(private $platformService: IPlatformService,
63
private $errors: IErrors) { }

lib/commands/appstore-list.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
import { createTable } from "../common/helpers";
52
import {StringCommandParameter} from "../common/command-params";
63

lib/commands/appstore-upload.ts

+46-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
import {StringCommandParameter} from "../common/command-params";
52
import * as path from "path";
3+
import {IOSProjectService} from "../services/ios-project-service";
64

75
export class PublishIOS implements ICommand {
86
constructor(private $errors: IErrors,
@@ -13,17 +11,29 @@ export class PublishIOS implements ICommand {
1311
private $logger: ILogger,
1412
private $options: IOptions,
1513
private $prompter: IPrompter,
16-
private $stringParameterBuilder: IStringParameterBuilder) { }
14+
private $stringParameterBuilder: IStringParameterBuilder,
15+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) { }
1716

1817
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
1918
new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
2019

20+
private get $platformsData(): IPlatformsData {
21+
return this.$injector.resolve("platformsData");
22+
}
23+
24+
// This property was introduced due to the fact that the $platformService dependency
25+
// ultimately tries to resolve the current project's dir and fails if not executed from within a project
26+
private get $platformService(): IPlatformService {
27+
return this.$injector.resolve("platformService");
28+
}
29+
2130
public execute(args: string[]): IFuture<void> {
2231
return (() => {
2332
let username = args[0],
2433
password = args[1],
2534
mobileProvisionIdentifier = args[2],
2635
codeSignIdentity = args[3],
36+
teamID = this.$options.teamId,
2737
ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null;
2838

2939
if(!username) {
@@ -42,12 +52,42 @@ export class PublishIOS implements ICommand {
4252
this.$logger.warn("No code sign identity set. A default code sign identity will be used. You can set one in app/App_Resources/iOS/build.xcconfig");
4353
}
4454

55+
if (!ipaFilePath) {
56+
let platform = this.$devicePlatformsConstants.iOS;
57+
// No .ipa path provided, build .ipa on out own.
58+
if (mobileProvisionIdentifier || codeSignIdentity) {
59+
let iOSBuildConfig: IiOSBuildConfig = {
60+
buildForDevice: true,
61+
mobileProvisionIdentifier,
62+
codeSignIdentity
63+
};
64+
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
65+
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
66+
this.$platformService.buildPlatform(platform, iOSBuildConfig).wait();
67+
ipaFilePath = this.$platformService.lastOutputPath(platform, { isForDevice: iOSBuildConfig.buildForDevice });
68+
} else {
69+
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
70+
if (!this.$platformService.preparePlatform(platform).wait()) {
71+
this.$errors.failWithoutHelp("Failed to prepare project.");
72+
}
73+
74+
let platformData = this.$platformsData.getPlatformData(platform);
75+
let iOSProjectService = <IOSProjectService>platformData.platformProjectService;
76+
77+
let archivePath = iOSProjectService.archive(platformData.projectRoot).wait();
78+
this.$logger.info("Archive at: " + archivePath);
79+
80+
let exportPath = iOSProjectService.exportArchive({ archivePath, teamID }).wait();
81+
this.$logger.info("Export at: " + exportPath);
82+
83+
ipaFilePath = exportPath;
84+
}
85+
}
86+
4587
this.$options.release = true;
4688
this.$itmsTransporterService.upload({
4789
username,
4890
password,
49-
mobileProvisionIdentifier,
50-
codeSignIdentity,
5191
ipaFilePath,
5292
verboseLogging: this.$logger.getLevel() === "TRACE"
5393
}).wait();

lib/commands/build.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class BuildCommandBase {
52
constructor(protected $options: IOptions,
63
private $platformService: IPlatformService) { }

lib/commands/create-project.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
import * as constants from "../constants";
52

63
export class CreateProjectCommand implements ICommand {

lib/commands/debug.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
4-
export class DebugPlatformCommand implements ICommand {
1+
export class DebugPlatformCommand implements ICommand {
52
constructor(private debugService: IDebugService,
63
private $devicesService: Mobile.IDevicesService,
74
private $errors: IErrors,

lib/commands/deploy.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class DeployOnDeviceCommand implements ICommand {
52
constructor(private $platformService: IPlatformService,
63
private $platformCommandParameter: ICommandParameter,

lib/commands/emulate.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class EmulateCommandBase {
52
constructor(private $platformService: IPlatformService) { }
63

lib/commands/generate-help.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class GenerateHelpCommand implements ICommand {
52
constructor(private $htmlHelpService: IHtmlHelpService) {
63
}

lib/commands/info.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class InfoCommand implements ICommand {
52
constructor(private $infoService: IInfoService) { }
63

lib/commands/init.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class InitCommand implements ICommand {
52
constructor(private $initService: IInitService) { }
63

lib/commands/install.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
31
import {EOL} from "os";
42

53
export class InstallCommand implements ICommand {

lib/commands/list-platforms.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
import * as helpers from "../common/helpers";
52

63
export class ListPlatformsCommand implements ICommand {

lib/commands/livesync.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class LivesyncCommand implements ICommand {
52
constructor(private $logger: ILogger,
63
private $usbLiveSyncService: ILiveSyncService,

lib/commands/plugin/add-plugin.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../../.d.ts"/>
2-
"use strict";
3-
41
export class AddPluginCommand implements ICommand {
52
constructor(private $pluginsService: IPluginsService,
63
private $errors: IErrors) { }

lib/commands/plugin/find-plugins.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
///<reference path="../../.d.ts"/>
2-
"use strict";
31
import { createTable, isInteractive } from "../../common/helpers";
42
import { NATIVESCRIPT_KEY_NAME } from "../../constants";
53
import Future = require("fibers/future");

lib/commands/plugin/list-plugins.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
///<reference path="../../.d.ts"/>
2-
"use strict";
31
import { createTable } from "../../common/helpers";
42

53
export class ListPluginsCommand implements ICommand {

lib/commands/plugin/remove-plugin.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../../.d.ts"/>
2-
"use strict";
3-
41
export class RemovePluginCommand implements ICommand {
52
constructor(private $pluginsService: IPluginsService,
63
private $errors: IErrors,

lib/commands/prepare.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class PrepareCommand implements ICommand {
52
constructor(private $errors: IErrors,
63
private $platformService: IPlatformService,

lib/commands/remove-platform.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class RemovePlatformCommand implements ICommand {
52
constructor(private $platformService: IPlatformService,
63
private $errors: IErrors) { }

lib/commands/run.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class RunCommandBase {
52
constructor(private $platformService: IPlatformService) { }
63

lib/commands/test-init.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
3-
"use strict";
4-
51
import * as path from 'path';
62
import * as util from 'util';
73
import {TESTING_FRAMEWORKS} from '../constants';

lib/commands/test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
3-
"use strict";
4-
51
function RunTestCommandFactory(platform: string) {
62
return function RunTestCommand($testExecutionService: ITestExecutionService) {
73
this.execute = (args: string[]): IFuture<void> => $testExecutionService.startTestRunner(platform);

lib/commands/update-platform.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="../.d.ts"/>
2-
"use strict";
3-
41
export class UpdatePlatformCommand implements ICommand {
52
constructor(private $platformService: IPlatformService,
63
private $errors:IErrors) { }

lib/common

Submodule common updated 154 files

lib/config.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path=".d.ts"/>
2-
"use strict";
3-
41
import * as path from "path";
52
import {StaticConfigBase} from "./common/static-config-base";
63
import {ConfigBase} from "./common/config-base";

lib/constants.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path=".d.ts"/>
2-
"use strict";
3-
41
export let APP_FOLDER_NAME = "app";
52
export let APP_RESOURCES_FOLDER_NAME = "App_Resources";
63
export let PROJECT_FRAMEWORK_FOLDER_NAME = "framework";

0 commit comments

Comments
 (0)