spaceshiptrip / Garmin-fenix-simple-intervals-DOESNTWORK

0 stars 0 forks source link

How to build and deploy #3

Open spaceshiptrip opened 1 month ago

spaceshiptrip commented 1 month ago

Now that you have the manifest.xml and the source code for your Garmin Connect IQ app, you can compile and deploy it to your Garmin Fenix 5X Plus. Here's a step-by-step guide to help you with the process:

Step 1: Set Up Your Development Environment

Make sure you've installed the Garmin Connect IQ SDK and the Connect IQ SDK Manager. If you're using Eclipse or Visual Studio Code, ensure your IDE is set up correctly with the Connect IQ SDK plugin.

Using Eclipse (Garmin's Recommended IDE):

  1. Open Eclipse.

  2. Install Connect IQ Plugin:

    • Go to Help > Eclipse Marketplace.
    • Search for Connect IQ and install the plugin.
    • Restart Eclipse once installed.
  3. Create a New Connect IQ Project:

    • Go to File > New > Other > Connect IQ Project.
    • Give the project a name (e.g., IntervalApp).
    • Choose WatchApp as the type and set the minimum SDK version to 3.2 (or as required by your Fenix 5X Plus).
  4. Add Your Source Files:

    • Replace the manifest.xml and source folder content with your actual source code and manifest.xml.
    • Make sure all source files are in the source directory and the manifest.xml is at the project root.

Step 2: Compile Your App

Using Eclipse:

  1. Build the Project:

    • Once you've added your source code and manifest.xml, right-click on your project in the Project Explorer.
    • Select Build Project (Eclipse will automatically compile your project).
  2. Check for Compilation Errors:

    • If there are any errors in the code or manifest, they will show up in the Console or Problems tab.
    • Fix any issues, if any, and re-build the project.

Step 3: Deploy the App to Your Garmin Device

Using Eclipse:

  1. Connect Your Garmin Fenix 5X Plus:

    • Connect your Fenix 5X Plus to your computer using the USB cable.
  2. Launch the Simulator:

    • Go to Run > Run Configurations....
    • Select Connect IQ App under Connect IQ.
    • Click New Launch Configuration (top-left icon).
    • In the Main tab, select your device (fenix 5X Plus) from the Device drop-down list.
    • Click Apply.
  3. Deploy to Your Watch:

    • In Eclipse, click the green Run button to either:
      • Launch the app on the simulator to test it.
      • Or, if your Fenix 5X Plus is connected, deploy it directly to the device.
    • You will see output in the console as the app is deployed to your watch.

Step 4: Test the App on Your Watch

Once the app is successfully deployed, you should be able to find it on your Garmin Fenix 5X Plus under the "Apps" menu.

Step 5: Using the Simulator (Optional)

Garmin provides a simulator that allows you to test your app without deploying it directly to your device.

  1. Launch the Simulator:

    • In Eclipse, go to Run > Run Configurations... and select Connect IQ App Simulator.
    • Click Run to launch the Garmin simulator.
  2. Test the App:

    • The simulator allows you to simulate GPS data, heart rate, and other sensor data. You can interact with your app in the same way as you would on your actual device.

Step 6: Sync with Garmin Connect (for Activity Upload)

After testing and saving activities, when you connect your watch to Garmin Connect (via the mobile app or Garmin Express on a PC), the activity should sync with your Garmin Connect account. If the session was saved, it will be uploaded automatically.

Troubleshooting

Let me know if you run into any issues or need further clarification!

spaceshiptrip commented 1 month ago

Using VSCode and manually build and deploy:

If you're using VS Code on your Mac and have already installed the Garmin Connect IQ SDK, you can compile and deploy your app to your Garmin Fenix 5X Plus by following these steps:

Step 1: Install the Garmin Connect IQ CLI Tools

The Garmin Connect IQ SDK comes with command-line tools that allow you to compile, simulate, and deploy your apps. To use these tools, ensure that you have the Connect IQ SDK installed and that the monkeyc command-line tool is in your system's PATH.

Add Garmin SDK to PATH (if not already done):

  1. Open a terminal.

  2. Add the Garmin Connect IQ SDK to your PATH by adding this line to your ~/.zshrc (or ~/.bashrc if using Bash):

    export PATH=$PATH:/path/to/garmin/sdk/bin

    Replace /path/to/garmin/sdk/bin with the actual path where you installed the SDK (e.g., /Users/yourusername/Library/Application Support/Garmin/ConnectIQ/Sdk/bin).

  3. Reload the terminal or source your shell config file:

    source ~/.zshrc
  4. Verify that monkeyc is available by running:

    monkeyc --version

    You should see output like monkeyc version <version-number>.

Step 2: Set Up Your Project in VS Code

  1. Create a New Connect IQ Project:

    • In VS Code, create a new folder for your project (e.g., IntervalApp).
    • Inside this folder, create the following structure:
      IntervalApp/
      ├── source/
      │   └── app.mc     # Your Monkey C source code
      ├── manifest.xml   # Your manifest file
      └── resources/     # Optional resources (e.g., icons)
  2. Add Your Source Code and Manifest:

    • Add your Monkey C code (app.mc) to the source/ folder.
    • Add the manifest.xml at the project root (as you've already created).

Step 3: Compile Your App with monkeyc

In the terminal, navigate to your project directory (where the manifest.xml is located) and use the monkeyc command to compile your app.

Here’s the basic syntax for compiling:

monkeyc -o output.prg -f manifest.xml -y developer_key.der -m /path/to/sdk/device_profiles/fenix5XPlus/device.xml source/app.mc

Let’s break down the command:

Step 4: Generate a Developer Key (if you don’t have one)

If this is your first time compiling an app for Garmin Connect IQ, you need to generate a developer key. You can do this using the monkeyc command:

monkeyc --create-key developer_key.der --cn "Your Name"

This will generate a file called developer_key.der that you can use to sign your app when compiling.

Step 5: Run Your App on the Simulator

Garmin provides a Connect IQ Simulator as part of the SDK. To run your app on the simulator:

  1. Launch the Simulator:

    connectiq

    This will open the Garmin Connect IQ Simulator.

  2. Load and run your app in the simulator:

    • In the Simulator, click on File > Load App.
    • Navigate to the .prg file you compiled (output.prg).
    • Select your target device (e.g., Fenix 5X Plus) from the simulator interface.
    • Click Run to test your app.

Step 6: Deploy Your App to the Garmin Device

Once your app is compiled into the .prg file, you can deploy it to your Garmin Fenix 5X Plus.

  1. Connect your Garmin device to your Mac via USB.
  2. Use the monkeydo command to deploy the app to your watch:

    monkeydo output.prg /path/to/sdk/device_profiles/fenix5XPlus/device.xml

    Replace /path/to/sdk/device_profiles/fenix5XPlus/device.xml with the correct path to your device profile XML file in the SDK. This command deploys the output.prg file to your Fenix 5X Plus.

Step 7: Test Your App on the Device

Once deployed, the app should appear on your Fenix 5X Plus under "Apps". You can now launch and test it directly on the watch.

Troubleshooting Tips

Let me know if you encounter any issues or need further assistance with the compilation or deployment process!