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

Nativescript IOS Run error #4853

Closed SebastianCBA closed 5 years ago

SebastianCBA commented 5 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):

✔ Getting NativeScript components versions information... ✔ Component nativescript has 5.4.2 version and is up to date. ✔ Component tns-core-modules has 5.4.3 version and is up to date. ✔ Component tns-android has 5.4.0 version and is up to date. ✔ Component tns-ios has 5.4.2 version and is up to date.

{ "nativescript": { "id": "com.famefan.app", "tns-android": { "version": "5.4.0" }, "tns-ios": { "version": "5.4.2" } }, "description": "Famefan", "license": "SEE LICENSE IN ", "repository": "", "dependencies": { "@vue/devtools": "^5.0.0-beta.3", "axios": "^0.18.0", "email-validator": "^2.0.4", "nativescript-background-http": "^3.4.0", "nativescript-checkbox": "^3.0.3", "nativescript-email": "^1.5.3", "nativescript-exit": "^1.0.1", "nativescript-fonticon": "^2.0.0", "nativescript-geolocation": "^5.0.0", "nativescript-gradient": "^2.0.1", "nativescript-loading-indicator": "^2.4.0", "nativescript-material-icons": "^1.0.3", "nativescript-mediafilepicker": "^2.0.16", "nativescript-modal-datetimepicker": "^1.1.12", "nativescript-oauth2": "^1.5.3", "nativescript-openurl": "^1.0.2", "nativescript-orientation": "^2.2.1", "nativescript-platform-css": "^1.6.7", "nativescript-popup": "^1.5.0", "nativescript-social-login": "^3.0.13-201804121139", "nativescript-social-share": "^1.5.1", "nativescript-socket.io": "^0.10.1", "nativescript-theme-core": "~1.0.4", "nativescript-toast": "^2.0.0", "nativescript-ui-listview": "^6.3.1", "nativescript-vue": "~2.2.0", "nativescript-vue-devtools": "^1.1.0", "nativescript-youtubeplayer": "^3.0.1", "tns-core-modules": "~5.4.0", "tns-core-modules-widgets": "^5.4.2", "vue-infinite-loading": "^2.4.3" }, "devDependencies": { "@babel/core": "~7.1.0", "@babel/preset-env": "~7.1.0", "babel-loader": "~8.0.0", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.2", "css-loader": "^1.0.0", "lazy": "1.0.11", "nativescript-dev-webpack": "~0.24.0", "nativescript-vue-template-compiler": "~2.0.0", "nativescript-worker-loader": "~0.9.0", "node-sass": "^4.9.0", "sass-loader": "^7.1.0", "terser-webpack-plugin": "^1.1.0", "vue-loader": "~15.4.0" }, "gitHead": "8c1a4866a66daab09bf5ef8e5a96472687192373", "readme": "NativeScript Application" }

Describe the bug When I execute "tns run ios --emulator" I get this error:

Webpack compilation complete. Watching for file changes. Webpack build done! Copying template files... Platform ios successfully added. v5.4.2 Preparing project... Info.plist: Merging CFBundleURLTypes: Property CFBundleTypeRole is required! Info.plist: Merging CFBundleURLTypes: Property CFBundleTypeRole is required! invalid document source @#[line:0,col:undefined] Unable to apply changes on device: 8BCD59E5-E4CE-4085-91E2-B14FB9861817. Error is: Cannot read property 'documentElement' of undefined.

Somebody can help me? Thanks in advance

KristianDD commented 5 years ago

Hi @SebastianCBA The error indicates that the CLI failed to merge the different Info.plist files of the application, runtimes and plugins.

I managed to build a blank NativeScript Vue.js application with the same plugins as described in your package.json. This indicates that most probably the issue is caused by the contents of the app/App_Resources/iOS/Info.plist. Please check if you notice something strange in its content.

Feel free to post the app/App_Resources/iOS/Info.plist contents here, so we can investigate further what causes the error.

SebastianCBA commented 5 years ago

Hi @KristanDD, thanks for your answer, my info.plist is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>

    <key>CFBundleURLTypes</key>
    <array>
        <!-- GOOGLE START -->
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Famefan</string>
            <key>CFBundleURLName</key>
            <string>com.famefan.app</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb291048201366687</string>
                <string>com.googleusercontent.apps.653986041129-5904lau2h7vcdc5v7hfl7fo3kska167d</string>
            </array>
        </dict>     
        <dict>
        <key>CLIENT_ID</key>
        <string>653986041129-5904lau2h7vcdc5v7hfl7fo3kska167d.apps.googleusercontent.com</string>
        <key>REVERSED_CLIENT_ID</key>
        <string>com.googleusercontent.apps.653986041129-5904lau2h7vcdc5v7hfl7fo3kska167d</string>
        <key>PLIST_VERSION</key>
        <string>1</string>
        <key>BUNDLE_ID</key>
        <string>com.famefan.app</string>
        </dict>
        <!-- GOOGLE END -->
        <!-- FACEBOOK START -->
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb291048201366687</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>FacebookAppID</key>
        <string>291048201366687</string>
    <key>FacebookDisplayName</key>
    <string>Famefan</string>
<!-- FACEBOOK END -->   
</dict>
</plist>

Do you see something wrong?

KristianDD commented 5 years ago

Hi @SebastianCBA, The Info.plist seems fine and I managed to build with its content inside my blank application.

There is a chance that I am getting newer version of some plugins, because of the package-lock.json. Can you please try clearing the following folders: rm -rf platforms hooks node_modules package-lock.json.

If you continue to get the same error, could you please try to run the command with --log trace | tee clioutput.txt at the end. This will produce a text file called clioutput.txt in the current working directory, which will contain the CLI output with additional information. Then attach the produced file to a response in this issue. This should allow us to see exactly which .plist file causes the error.

SebastianCBA commented 5 years ago

Hi @KristianDD , here is the file clioutput.txt

I understand this file, can you help me with this file? Thanks in advance.

KristianDD commented 5 years ago

Hi @SebastianCBA , This file is a verbose output of the CLI that describes what the tooling is doing in more detail. The file looks OK and the application seems to be prepared, build and deployed successfully.

Preparing project...
Installing pods...
....
Project successfully prepared (iOS)
Building project...
...
Project successfully built.
Installing on device XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX...
Successfully installed on device with identifier 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.
Successfully transferred all files on device XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Restarting application on device XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX...
Successfully synced application com.famefan.app on device XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
...

There seems to be an error after starting of the application

file:///app/bundle.js:16260:61: JS ERROR TypeError: undefined is not an object
Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: undefined is not an object

This is an issue specific to your application code and will need some debugging to solve.

In order to see the file and location from where the exception is caused (currently you see the location inside the bundle - bundle.js:16260:61) you can take advantage of a feature that we have just released with NativeScript v6.0.0, which uses the source map and prints the real location of the error in the console output. There a few steps needed in order to update to v6.0.0: 1 npm i -g nativescript@latest 2 tns migrate 3 tns run ios

You can read more about migrating to NativeScript v6.0.0 here.

DimitarTachev commented 5 years ago

Closing due to inactivity.