NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 196 forks source link

iOS simulator can't find app because incorrect case of "Build" in path #5055

Open jeffswitzer opened 4 years ago

jeffswitzer commented 4 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug Trying to migrate a project from 5.4 to 6 and having trouble running on the iOS emulator due to case sensitivity of the build path. Seems like 5.4 used 'build' but 6 changed this to 'Build'.

Replicate tns platform remove ios tns platform add ios tns run ios --emulator

I get: Project successfully built. The build result is located at: /Users/npn/Development/ns6/test/platforms/ios/build/Debug-iphonesimulator/test.app Installing on device 84F073AE-D836-4C81-8803-FDA3ABC8C731... Unable to apply changes on device: 84F073AE-D836-4C81-8803-FDA3ABC8C731. Error is: Command xcrun with arguments simctl install 84F073AE-D836-4C81-8803-FDA3ABC8C731 /Users/npn/Development/ns6/test/platforms/ios/build/Debug-iphonesimulator/test.app failed with exit code 2. Error output: An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2): Failed to install the requested application An application bundle was not found at the provided path. Provide a valid path to the desired application bundle.

Expected The issue is in the case of the word build in the path. On my drive tns is creating /Users/npn/Development/ns6/test/platforms/ios/Build/Debug-iphonesimulator/test.app but it's giving args to simctl as /Users/npn/Development/ns6/test/platforms/ios/build/Debug-iphonesimulator/test.app

Other than manually adjusting the path on my file system how do I get the two to agree on the case?

Fatme commented 4 years ago

Hey @jeffswitzer,

We'll need additional information in order to help you to resolve the problem. Can you please send us the followings:

Also, can you reproduce the issue using a newly created blank application?

Fatme commented 4 years ago

@jeffswitzer,

Meanwhile, we tried to reproduce the problem using case-sensitive file system, but without success. It seems on our side that the build folder is always created with lowercase b. Also, we've hardcoded the path to build folder and it is really strange how it is possible to be outputed in Build directory.

jeffswitzer commented 4 years ago

@Fatme,

Thanks for looking into this. Here is more info:

  1. pod --version = 1.5.3
  2. xcodebuild -version = Xcode 11.0 Build version 11A420a
  3. The problem does occur with a newly created blank application.
  4. Here is the package.json from the project created with tns create testing2 --ng
    {
    "nativescript": {
    "id": "org.nativescript.testing2",
    "tns-android": {
      "version": "6.1.2"
    },
    "tns-ios": {
      "version": "6.1.0"
    }
    },
    "description": "NativeScript Application",
    "license": "SEE LICENSE IN <your-license-filename>",
    "repository": "<fill-your-repository-here>",
    "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "nativescript-angular": "~8.2.0",
    "nativescript-theme-core": "~1.0.6",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.1.0",
    "zone.js": "~0.9.1"
    },
    "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@ngtools/webpack": "~8.2.0",
    "nativescript-dev-webpack": "~1.2.0",
    "typescript": "~3.5.3"
    },
    "gitHead": "1964ea9e8ca1a0518e0d6370781eedcf6c23db42",
    "readme": "NativeScript Application"
    }
Fatme commented 4 years ago

Hey @jeffswitzer,

Thank you for sending the information!

Can you try the following steps:

  1. Remove the DerivedData of your application

The default location of the project's derivedData is /Users/<username>/Library/Developer/Xcode/DerivedData/<projectName>-<guid>. In case you cannot find it at that location, you can open the native project in Xcode, go to Xcode menu -> Preferences -> Locations -> Derived Data.

  1. Remove the platforms folder of your application
  2. Execute tns run ios --emulator

Let us know if that helps.

jeffswitzer commented 4 years ago

Didn't seem to help. I removed the derived data folder:

(base) [npn@on-campus DerivedData]$ pwd
/Users/npn/Library/Developer/Xcode/DerivedData
(base) [npn@on-campus DerivedData]$ rm -rf testing2-ealggwqrnpsclqdikswczlrtkofi/

Then I removed the platforms folder and when it got recreated it still added the directory as Build and gave the same error. Here is the contents of /Users/npn/Development/ns6/testing2/platforms/ios

drwxr-xr-x  16 npn  staff   512B Oct 14 11:34 internal
drwxr-xr-x  10 npn  staff   320B Oct 14 11:35 testing2
-rw-r--r--   1 npn  staff   425B Oct 14 11:35 Podfile
-rw-r--r--   1 npn  staff   1.3K Oct 14 11:36 Podfile.lock
drwxr-xr-x   9 npn  staff   288B Oct 14 11:36 Pods
drwxr-xr-x@  3 npn  staff    96B Oct 14 11:36 testing2.xcworkspace
drwxr-xr-x   4 npn  staff   128B Oct 14 11:36 testing2.xcodeproj
-rw-r--r--   1 npn  staff   865B Oct 14 11:36 plugins-debug.xcconfig
-rw-r--r--   1 npn  staff   865B Oct 14 11:36 plugins-release.xcconfig
drwxr-xr-x   6 npn  staff   192B Oct 14 11:36 Build

Here is the error output:

(base) [npn@on-campus testing2]$ tns run ios --emulator
Searching for devices...
Copying template files...
Platform ios successfully added. v6.1.0
Preparing project...
File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Hash: 31b92cbbeb43be6d0b09
Version: webpack 4.27.1
Time: 11127ms
Built at: 10/14/2019 11:35:32 AM
                                            Asset       Size                                          Chunks             Chunk Names
                                        bundle.js   37.2 KiB                                          bundle  [emitted]  bundle
                                     package.json  112 bytes                                                  [emitted]
                                       runtime.js   71.4 KiB                                         runtime  [emitted]  runtime
tns_modules/tns-core-modules/inspector_modules.js  664 bytes  tns_modules/tns-core-modules/inspector_modules  [emitted]  tns_modules/tns-core-modules/inspector_modules
                                        vendor.js   13.9 MiB                                          vendor  [emitted]  vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
Entrypoint tns_modules/tns-core-modules/inspector_modules = runtime.js vendor.js tns_modules/tns-core-modules/inspector_modules.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.css] 918 bytes {bundle} [built]
[./app/app-routing.module.ts] 784 bytes {bundle} [built]
[./app/app.component.html] 167 bytes {bundle} [built]
[./app/app.component.ts] 354 bytes {bundle} [built]
[./app/app.module.ts] 1.51 KiB {bundle} [built]
[./app/item/item-detail.component.html] 394 bytes {bundle} [built]
[./app/item/item-detail.component.ts] 977 bytes {bundle} [built]
[./app/item/item.service.ts] 1.59 KiB {bundle} [built]
[./app/item/items.component.html] 1.68 KiB {bundle} [built]
[./app/item/items.component.ts] 733 bytes {bundle} [built]
[./main.ts] 2.09 KiB {bundle} [built]
[./package.json] 100 bytes {bundle} {tns_modules/tns-core-modules/inspector_modules} [optional] [built]
    + 443 hidden modules
Webpack compilation complete. Watching for file changes.
Webpack build done!
Installing pods...
Ignoring ffi-1.9.18 because its extensions are not built.  Try: gem pristine ffi --version 1.9.18
Analyzing dependencies
Downloading dependencies
Installing MDFInternationalization (2.0.0)
Installing MaterialComponents (84.6.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `testing2.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
Project successfully prepared (ios)
Building project...
Xcode build...
Project successfully built.
The build result is located at: /Users/npn/Development/ns6/testing2/platforms/ios/build/Debug-iphonesimulator/testing2.app
Installing on device 7477F938-CA4A-4581-B681-B8208588E740...
Unable to apply changes on device: 7477F938-CA4A-4581-B681-B8208588E740. Error is: Command xcrun with arguments simctl install 7477F938-CA4A-4581-B681-B8208588E740 /Users/npn/Development/ns6/testing2/platforms/ios/build/Debug-iphonesimulator/testing2.app failed with exit code 2. Error output:
 An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
.
Fatme commented 4 years ago

@jeffswitzer,

I removed the derived data folder:

(base) [npn@on-campus DerivedData]$ pwd
/Users/npn/Library/Developer/Xcode/DerivedData
(base) [npn@on-campus DerivedData]$ rm -rf testing2-ealggwqrnpsclqdikswczlrtkofi/

Sometimes there are more than one folder in format <project-name>-<guid> inside /Users/npn/Library/Developer/Xcode/DerivedData. Can you ensure that all folders that started with testing2 are deleted?

If the above didn't help, rename /Users/npn/Library/Developer/Xcode/DerivedData to /Users/npn/Library/Developer/Xcode/DerivedData1, delete platforms folder of your project and try again.

jeffswitzer commented 4 years ago

@Fatme there was only one folder that started with testing2. I tried renaming the DerivedData folder:

(base) [npn@on-campus Xcode]$ mv /Users/npn/Library/Developer/Xcode/DerivedData/ /Users/npn/Library/Developer/Xcode/DerivedData1
(base) [npn@on-campus Xcode]$ ls
Archives        DocumentationCache  Products        iOS Device Logs
DerivedData1        GPUToolsAgent.sock  UserData        iOS DeviceSupport

Then removed the platforms directory and tried again. But the same result. It did generate a new DerivedData folder.

Fatme commented 4 years ago

@jeffswitzer,

xcodebuild -version = Xcode 11.0 Build version 11A420a

Can you try to update to Xcode 11.1, delete DerivedData and platforms folders and execute again tns run ios --emulator?

jeffswitzer commented 4 years ago

@Fatme Found some more information. I have a second nvm environment from before trying to migrate my project to ns 6+ where I think everything is the same except it uses Nativescript 5.4.2 and node 10.12 instead of 10.16. Using that older version, it makes the correct build instead of Build. The tns run ios --emulator output also says "You are using the Legacy Workflow." Here are version params you asked for earlier from this other nvm environment.

(base) [npn@on-campus ios (develop)]$ nvm use 10.12
Now using node v10.12.0 (npm v6.9.0)
(base) [npn@on-campus ios (develop)]$ tns --version
5.4.2
(base) [npn@on-campus ios (develop)]$ pod --version
Ignoring ffi-1.9.18 because its extensions are not built.  Try: gem pristine ffi --version 1.9.18
1.5.3
(base) [npn@on-campus ios (develop)]$ xcodebuild -version
Xcode 11.0
Build version 11A420a
jeffswitzer commented 4 years ago

@Fatme also I can try the 11.1 update, but it probably won't be today as I need to hunt for some disk space to reclaim before it lets me install the update. Apparently 11g free isn't enough. Also seems unlikely that an Xcode update will fix it in light of ns 5.4.2 writing the correct build path?

Fatme commented 4 years ago

Hey @jeffswitzer,

Also seems unlikely that an Xcode update will fix it in light of ns 5.4.2 writing the correct build path?

That's true. When investigating the issue, we found a difference in the arguments passed to xcodebuild from CLI 6.0.0 and CLI 5.4.0. Most probably that difference is not causing the current issue with Build directory. However, we've decided to fix the problem and the fix is already merged in next version of CLI. Could you try the following steps and update us back:

  1. npm i nativescript@next -g
  2. Update Xcode to 11.1
  3. Delete DerivedData and platforms folders
  4. tns run ios --emulator
abhayastudios commented 4 years ago

I am having a similar issue (for release builds only) on a mac both with NS 6.1 & 6.2:

Project successfully built.
The build result is located at: /Users/joni/<myapp>/nativescript/platforms/ios/build/Release-iphoneos/nativescript.ipa
Installing on device FF06901E-EDB6-4E1F-A7E3-E27D4DDAB48F...
Command xcrun with arguments simctl install FF06901E-EDB6-4E1F-A7E3-E27D4DDAB48F /Users/joni/<myapp>/nativescript/platforms/ios/build/Release-iphoneos/nativescript.ipa failed with exit code 2. Error output:
 An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.

The build process does create an IPA file of ~43M in: ./platforms/ios/build/Release-iphoneos/myapp.ipa

However ./platforms/ios/build/Release-iphoneos/myapp.app is linked to a non-existing file:

$ ls -al platforms/ios/build/Release-iphoneos/nativescript.app
lrwxr-xr-x  1 joni  staff  226 Nov 13 15:01 platforms/ios/build/Release-iphoneos/nativescript.app -> /Users/joni/Library/Developer/Xcode/DerivedData/nativescript-fueylrwznjovxgbtjkbkccnootyu/Build/Intermediates.noindex/ArchiveIntermediates/nativescript/InstallationBuildProductsLocation/Applications/nativescript.app

The following dir does exist: but does not contain a dir called InstallationBuildProductsLocation:

/Users/jonathansalomon/Library/Developer/Xcode/DerivedData/nativescript-fueylrwznjovxgbtjkbkccnootyu/Build/Intermediates.noindex/ArchiveIntermediates/nativescript

This location does contain a dir called BuildProductsPath but it is empty after the build.

Note my NS project dir is called nativescript because I have both the firebase and nativescript proejcts in one git repo.

$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.2.0 version and is up to date.
✔ Component tns-core-modules has 6.2.1 version and is up to date.
✔ Component tns-android has 6.2.0 version and is up to date.
✔ Component tns-ios has 6.2.0 version and is up to date.