Skip to content

Merge release in master #1664

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

Merged
merged 15 commits into from
Apr 4, 2016
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
NativeScript CLI Changelog
================

1.7.1 (2016, March 30)
==

### New
* [Implemented #1634](https://github.com/NativeScript/nativescript-cli/issues/1634): Replace plugin variables in all .xml files of android's plugin code.

### Fixed
* [Fixed #1610](https://github.com/NativeScript/nativescript-cli/issues/1610): `tns plugin add <plugin>` has issues with postinstall scripts.
* [Fixed #1610](https://github.com/NativeScript/nativescript-cli/issues/1612): Unable to execute unit tests on iOS Simulator in some cases.
* [Fixed #1619](https://github.com/NativeScript/nativescript-cli/issues/1619): Wrong error message on installation (or `tns doctor` command).
* [Fixed #1625](https://github.com/NativeScript/nativescript-cli/issues/1625): Double navigation when showing unit test results.

1.7.0 (2016, March 16)
==

Expand Down
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ With the NativeScript CLI, you can target the following mobile platforms.
System Requirements
===

You can install and run the NativeScript CLI on Windows or OS X.
You can install and run the NativeScript CLI on Windows, OS X or Linux.

* [Windows](#windows)
* [OS X](#os-x)
Expand All @@ -69,6 +69,21 @@ You can install and run the NativeScript CLI on Windows or OS X.

> On Windows systems, you can develop, build, and deploy NativeScript projects that target Android.

### Setup Script
To quickly set up your system for the latest NativeScript CLI, paste the following PowerShell script in the **Command Prompt** and hit `Enter`:
```cmd
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
```

Alternatively, your can paste the following PowerShell setup script in a **Windows PowerShell console** and hit `Enter`:
```PowerShell
start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
```
> Both scripts require that you have **.NET 4.0 or later** installed on your system. You can download .NET 4.6.1 from this [link](http://go.microsoft.com/fwlink/?LinkId=671729).


### Manual Setup

* Windows 7 SP1 or later
* The latest Node.js [0.10.x](https://nodejs.org/dist/latest-v0.10.x/), [0.12.x](https://nodejs.org/dist/latest-v0.12.x/), [4.x](https://nodejs.org/dist/latest-v4.x/) or [5.x](https://nodejs.org/dist/latest-v5.x/) stable official release
* (Optional) [Chocolatey][Chocolatey]
Expand Down Expand Up @@ -125,6 +140,14 @@ android update sdk --filter tools,platform-tools,android-23,build-tools-23.0.2,s

> On OS X systems, you can develop, build, and deploy NativeScript projects that target iOS and Android.

### Setup Script
To quickly set up your system for the latest NativeScript CLI, paste the following Ruby script in the **Terminal** and hit `Enter`:
```Shell
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.rb)"
```

### Manual Setup

* OS X Mavericks
* The latest Node.js [0.10.x](https://nodejs.org/dist/latest-v0.10.x/), [0.12.x](https://nodejs.org/dist/latest-v0.12.x/), [4.x](https://nodejs.org/dist/latest-v4.x/) or [5.x](https://nodejs.org/dist/latest-v5.x/) stable official release
* For iOS development
Expand Down Expand Up @@ -325,7 +348,7 @@ MyApp/
```

* The `app` directory is the **development space for your application**. You should modify all common and platform-specific code within this directory. When you run `prepare <Platform>`, the NativeScript CLI copies relevant content to the platform-specific folders for each target platform.
* The `platforms` directory is created empty. When you add a target platform to your project, the NativeScript CLI creates a new subdirectory with the platform name. The subdirectory contains the ready-to-build resources of your app. When you run `prepare <Platform>`, the NativeScript CLI copies relevant content from the `app` directory to the platform-specific subdirectory for each target platform.<br/>In the `platforms` directory, you can safely modify configuration files such as `AndroidManifest.xml` and `Info.plist`.
* The `platforms` directory is created empty. When you add a target platform to your project, the NativeScript CLI creates a new subdirectory with the platform name. The subdirectory contains the ready-to-build resources of your app. When you run `prepare <Platform>`, the NativeScript CLI copies relevant content from the `app` directory to the platform-specific subdirectory for each target platform.

[Back to Top][1]

Expand Down Expand Up @@ -398,9 +421,13 @@ You can develop shared functionality or design in common files. To indicate that

### Development in `platforms`

In `platforms`, you can safely modify files which are part of the native project structure and do not have a corresponding source located in the `app` directory in the root. For example, `AndroidManifest.xml` and `Info.plist`.
> **IMPORTANT:** Avoid editing files located in the `platforms` subdirectory because the NativeScript CLI overrides such files during the `prepare <Platform>` using the contents of the `app` directory.

### Modifying Configuration Files

**Do not modify files and resources that have a corresponding file in the `app` directory in the root**, such as application scripts, icons, and splash screens. The NativeScript CLI overrides such files during the `prepare <Platform>` operation with the content from `app`.
The NativeScript CLI respects any platform configuration files placed inside `app/App_Resources`. Those files are respectively `app/App_Resources/AndroidManifest.xml` for Android and `app/App_Resources/Info.plist` for iOS.

Additionaly, you can modify `app/App_Resources/build.xcconfig` and `app/App_Resources/app.gradle` for adding/removing additional build properties for iOS and Android, respectively.

[Back to Top][1]

Expand All @@ -417,8 +444,6 @@ tns prepare ios

Keep in mind that `prepare` overrides changes made to the platform-specific subdirectory in `platforms`. For more information, see [Development in platforms](#development-in-platforms).

> **IMPORTANT:** Always run `prepare <Platform>` before running `build <Platform>`, `deploy <Platform>`, or `emulate <Platform>`. This ensures that the NativeScript CLI will build an application package with your latest code and resources.

[Back to Top][1]

## Build Your Project
Expand All @@ -434,7 +459,9 @@ The NativeScript CLI calls the SDK for the selected target platform and uses it

When you build for Android, the NativeScript CLI saves the application package as an `APK` in `platforms` &#8594; `android` &#8594; `bin`.

When you build for iOS, if the `--device` flag is not set, the NativeScript CLI builds your project for the native emulator and saves the application package as an `APP` in `platforms` &#8594; `ios` &#8594; `build` &#8594; `emulator`. If the `--device` flag is set, the NativeScript CLI builds your project for device and saves the application package as an `IPA` in `platforms` &#8594; `ios` &#8594; `build` &#8594; `device`.
When you build for iOS, the NativeScript CLI will either build for a device, if there's a device attached, or for the native emulator if there are no devices attached. To trigger a native emulator build when a device is attached, set the `--emulator` flag.

The native emulator build is saved as an `APP` in `platforms` &#8594; `ios` &#8594; `build` &#8594; `emulator`. The device build is saved as an `IPA` in `platforms` &#8594; `ios` &#8594; `build` &#8594; `device`.

> **IMPORTANT:** To build your app for an iOS device, you must configure a valid certificate and provisioning profile pair, and have that pair present on your system for code signing your application package. For more information, see [iOS Code Signing - A Complete Walkthrough](http://seventhsoulmountain.blogspot.com/2013/09/ios-code-sign-in-complete-walkthrough.html).

Expand Down
4 changes: 2 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ export class PlatformService implements IPlatformService {
// Process configurations files from App_Resources
platformData.platformProjectService.processConfigurationFilesFromAppResources().wait();

this.applyBaseConfigOption(platformData).wait();

// Replace placeholders in configuration files
platformData.platformProjectService.interpolateConfigurationFile().wait();

this.applyBaseConfigOption(platformData).wait();

this.$logger.out("Project successfully prepared");
return true;
}).future<boolean>()();
Expand Down
36 changes: 26 additions & 10 deletions setup/native-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# To run it inside a COMMAND PROMPT against the production branch (only one supported with self-elevation) use
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
# To run it inside a WINDOWS POWERSHELL console against the production branch (only one supported with self-elevation) use
# iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))
# start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"

# Check if latest .NET framework installed is at least 4
$dotNetVersions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select Version
$latestDotNetVersion = $dotNetVersions.GetEnumerator() | Sort-Object Version | Select-Object -Last 1
$latestDotNetMajorNumber = $latestDotNetVersion.Version.Split(".")[0]
if ($latestDotNetMajorNumber -lt 4) {
Write-Host -ForegroundColor Red "To run this script, you need .NET 4.0 or later installed"
if ((Read-Host "Do you want to open Microsoft Download Center (y/n)") -eq 'y') {
Start-Process -FilePath "https://www.microsoft.com/en-us/download/search.aspx?q=.net%20framework&p=0&r=10&t=&s=Relevancy~Descending"
if ((Read-Host "Do you want to open .NET Framework 4.6.1 download page (y/n)") -eq 'y') {
Start-Process -FilePath "http://go.microsoft.com/fwlink/?LinkId=671729"
}

exit 1
Expand Down Expand Up @@ -71,16 +71,21 @@ Install "Google Chrome" "Installing Google Chrome (required to debug NativeScrip
Install "Java Development Kit" "Installing Java Development Kit" "cinst jdk8 --force --yes"

Install "Android SDK" "Installing Android SDK" "cinst android-sdk --force --yes"

# setup android sdk
echo yes | cmd /c "$env:localappdata\Android\android-sdk\tools\android" update sdk --filter "tools,platform-tools,android-23" --all --no-ui
echo yes | cmd /c "$env:localappdata\Android\android-sdk\tools\android" update sdk --filter "build-tools-23.0.1,extra-android-m2repository" --all --no-ui

# setup environment

if (!$env:ANDROID_HOME) {
[Environment]::SetEnvironmentVariable("ANDROID_HOME", "$env:localappdata\Android\android-sdk", "User")
$env:ANDROID_HOME = "$env:localappdata\Android\android-sdk";
# in case the user has `android` in the PATH, use it as base for setting ANDROID_HOME
$androidExecutableEnvironmentPath = Get-Command android -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if ($androidExecutableEnvironmentPath -ne $null) {
$androidHomeJoinedPath = [io.path]::combine($androidExecutableEnvironmentPath, "..", "..")
$androidHome = Resolve-Path $androidHomeJoinedPath | Select-Object -ExpandProperty Path
}
else {
$androidHome = "$env:localappdata\Android\android-sdk"
}

$env:ANDROID_HOME = $androidHome;
[Environment]::SetEnvironmentVariable("ANDROID_HOME", "$env:ANDROID_HOME", "User")
}

if (!$env:JAVA_HOME) {
Expand All @@ -90,5 +95,16 @@ if (!$env:JAVA_HOME) {
$env:JAVA_HOME = $javaHome;
}

# setup android sdk
# following commands are separated in case of having to answer to license agreements
# the android tool will introduce a --accept-license option in subsequent releases
$androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "android")
echo y | cmd /c "$androidExecutable" update sdk --filter "platform-tools" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "tools" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "android-23" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "build-tools-23.0.2" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "extra-android-m2repository" --all --no-ui


Write-Host -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
Pause
35 changes: 29 additions & 6 deletions setup/native-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,42 @@ def install(program_name, message, script, run_as_root = false, show_all_option
end

install("Java SE Development Kit", "Installing the Java SE Development Kit... This might take some time, please, be patient. (You will be prompted for your password)", 'brew cask install java', false, false)
execute('echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.profile', "Unable to set JAVA_HOME")

install("Android SDK", "Installing Android SDK", 'brew install android-sdk')
execute('echo "export ANDROID_HOME=/usr/local/opt/android-sdk" >> ~/.profile', "Unable to set ANDROID_HOME")

unless ENV["ANDROID_HOME"]
require 'pathname'
# if android-sdk was installed through brew, there should be a symlink in /usr/local/opt/android-sdk pointing to the actual sdk
android_home = "/usr/local/opt/android-sdk"
unless Pathname.new(android_home).exist?
require 'mkmf'
# if there's no such symlink then try to find the `android-sdk` directory through the `android` executable
android_executable_environment_path = find_executable('android')
if android_executable_environment_path
android_home_joined_path = File.join(android_executable_environment_path, "..", "..")
android_home = Pathname.new(android_home_joined_path).realpath
end
end

ENV["ANDROID_HOME"] = android_home
execute('echo "export ANDROID_HOME=%s" >> ~/.profile' % ENV["ANDROID_HOME"], "Unable to set ANDROID_HOME")
end

unless ENV["JAVA_HOME"]
execute('echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.profile', "Unable to set JAVA_HOME")
end

# the -p flag is set in order to ensure zero status code even if the directory exists
execute("mkdir -p ~/.cocoapods", "There was a problem in creating ~/.cocoapods directory")
install("CocoaPods", "Installing CocoaPods... This might take some time, please, be patient.", 'gem install cocoapods -V', true)

puts "Configuring your system for Android development... This might take some time, please, be patient."
# Note that multiple license acceptances may be required, hence the multiple y answers
# Note that multiple license acceptances may be required, hence the multiple commands
# the android tool will introduce a --accept-license option in subsequent releases
execute("(for i in {1..5}; do echo y; sleep 4; done) | /usr/local/opt/android-sdk/tools/android update sdk --filter tools,platform-tools,android-23,build-tools-23.0.2,extra-android-m2repository --all --no-ui",
"There seem to be some problems with the Android configuration")
android_executable = File.join(ENV["ANDROID_HOME"], "tools", "android")
execute("echo y | #{android_executable} update sdk --filter platform-tools --all --no-ui", "There seem to be some problems with the Android configuration")
execute("echo y | #{android_executable} update sdk --filter tools --all --no-ui", "There seem to be some problems with the Android configuration")
execute("echo y | #{android_executable} update sdk --filter android-23 --all --no-ui", "There seem to be some problems with the Android configuration")
execute("echo y | #{android_executable} update sdk --filter build-tools-23.0.2 --all --no-ui", "There seem to be some problems with the Android configuration")
execute("echo y | #{android_executable} update sdk --filter extra-android-m2repository --all --no-ui", "There seem to be some problems with the Android configuration")

puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .profile. Restart the terminal to use them."