Skip to content

Installation Guide

Athar Reza edited this page Nov 1, 2025 · 1 revision

πŸ“¦ Installation Guide

Complete setup instructions for AgriSense iOS development environment.


πŸ“‹ Prerequisites

System Requirements

  • macOS: 13.0 (Ventura) or later
  • Xcode: 15.0 or later
  • iOS Deployment Target: iOS 16.0+
  • RAM: Minimum 8GB (16GB recommended)
  • Disk Space: At least 10GB free space

Required Software

  1. Xcode

    # Install from Mac App Store or download from
    # https://developer.apple.com/xcode/
    
    # Verify installation
    xcodebuild -version
  2. Command Line Tools

    xcode-select --install
  3. Git

    # Check if Git is installed
    git --version
    
    # If not installed, it will prompt for installation
  4. CocoaPods (Optional, if needed for dependencies)

    sudo gem install cocoapods
    pod --version

πŸ”§ Development Environment

1. Clone the Repository

# Clone the repository
git clone https://github.com/Athar891/AgrisenseiOS.git

# Navigate to project directory
cd AgrisenseiOS

# Check current branch
git branch

2. Firebase Setup

Create Firebase Project

  1. Go to Firebase Console
  2. Create a new project or use existing one
  3. Add iOS app to your Firebase project
  4. Download GoogleService-Info.plist

Configure Firebase

# Place GoogleService-Info.plist in Agrisense folder
cp ~/Downloads/GoogleService-Info.plist ./Agrisense/

Important: Ensure GoogleService-Info.plist is added to Xcode target:

  • Open Xcode
  • Drag GoogleService-Info.plist to Agrisense folder
  • Check "Copy items if needed"
  • Select Agrisense target

Firebase Services to Enable

  1. Authentication

    • Email/Password provider
    • Google Sign-In provider
    • Phone authentication (optional)
  2. Cloud Firestore

  3. Cloud Storage

    • Enable storage bucket
    • Configure storage rules
  4. Cloud Functions (if using)

    • Set up Node.js functions

3. API Keys Configuration

Create Secrets.swift in Agrisense/Models/ directory:

// Agrisense/Models/Secrets.swift
import Foundation

enum Secrets {
    // OpenWeatherMap API Key
    static let weatherAPIKey = "YOUR_OPENWEATHER_API_KEY"
    
    // Google Gemini AI API Key
    static let geminiAPIKey = "YOUR_GEMINI_API_KEY"
    
    // Cloudinary Configuration
    static let cloudinaryCloudName = "YOUR_CLOUD_NAME"
    static let cloudinaryUploadPreset = "YOUR_UPLOAD_PRESET"
    
    // Government Data API (if required)
    static let govDataAPIKey = "YOUR_GOV_DATA_API_KEY" // Optional
}

Getting API Keys

  1. OpenWeatherMap API

    • Sign up at OpenWeatherMap
    • Navigate to API Keys section
    • Copy your API key
  2. Google Gemini AI API

    • Visit Google AI Studio
    • Sign in with Google account
    • Create API key
    • Copy the API key
  3. Cloudinary

    • Sign up at Cloudinary
    • Go to Dashboard
    • Note your Cloud Name
    • Create an unsigned upload preset:
      • Settings β†’ Upload β†’ Upload presets
      • Add upload preset (unsigned)
  4. Government Data API (Optional)

    • Visit data.gov.in
    • Register for API access
    • Request API key

4. Google Sign-In Setup

Configure OAuth Client

  1. Go to Google Cloud Console
  2. Select your Firebase project
  3. Navigate to APIs & Services β†’ Credentials
  4. Create OAuth 2.0 Client ID:
    • Application Type: iOS
    • Bundle ID: com.yourcompany.agrisense
    • Download the configuration

Update Info.plist

Add URL scheme to Agrisense/Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.googleusercontent.apps.YOUR-CLIENT-ID</string>
        </array>
    </dict>
</array>

5. Project Configuration

Update Bundle Identifier

  1. Open project in Xcode
  2. Select Agrisense target
  3. Go to Signing & Capabilities
  4. Update Bundle Identifier to your unique identifier
  5. Select your development team

Capabilities to Enable

  • Background Modes

    • Audio, AirPlay, and Picture in Picture
    • Background fetch
    • Remote notifications
  • Push Notifications

    • Enable push notifications capability
  • App Groups (if using)

    • Add app group identifier

πŸ— Building the Project

1. Open in Xcode

# Open the project
open Agrisense.xcodeproj

2. Select Scheme

  1. In Xcode, select scheme: Agrisense
  2. Select target device or simulator
  3. Recommended: iPhone 14 Pro or later simulator

3. Install Dependencies

The project uses Swift Package Manager for dependencies. Xcode will automatically resolve packages on first build.

If you encounter issues:

# In Xcode
File β†’ Packages β†’ Reset Package Caches
File β†’ Packages β†’ Resolve Package Versions

4. Build the Project

Option 1: Using Xcode

  • Press ⌘B (Command + B) to build
  • Press ⌘R (Command + R) to build and run

Option 2: Using Command Line

# Build for simulator
xcodebuild -project Agrisense.xcodeproj \
  -scheme Agrisense \
  -sdk iphonesimulator \
  -configuration Debug \
  build

# Or use the task (if configured)
# See .vscode/tasks.json

5. Run on Simulator

# List available simulators
xcrun simctl list devices

# Boot a simulator
xcrun simctl boot "iPhone 14 Pro"

# Run the app
xcodebuild -project Agrisense.xcodeproj \
  -scheme Agrisense \
  -sdk iphonesimulator \
  -destination 'platform=iOS Simulator,name=iPhone 14 Pro' \
  build

6. Run on Physical Device

  1. Connect device via USB
  2. Trust computer on device
  3. Select device in Xcode
  4. Enable Developer Mode on iOS device:
    • Settings β†’ Privacy & Security β†’ Developer Mode
  5. Build and Run (⌘R)

πŸ” Verification

Test Basic Functionality

After installation, verify:

  1. App Launches βœ…

    • No crashes on launch
    • Splash screen appears
  2. Authentication βœ…

    • Email/Password sign-up works
    • Google Sign-In works
    • Sign-out functionality
  3. Firebase Connection βœ…

    • Check Xcode console for Firebase initialization logs
    • Test Firestore read/write
  4. API Integration βœ…

    • Weather data loads
    • Market prices fetch successfully
  5. AI Assistant βœ…

    • Voice recognition activates
    • Gemini AI responds correctly

Check Logs

Look for these success messages in Xcode console:

βœ… Firebase configured successfully
βœ… Google Sign-In initialized
βœ… Location services authorized
βœ… Weather data fetched
βœ… Gemini AI service ready

πŸ› Common Issues

Issue: Build Fails with Package Resolution Error

Solution:

# Clear derived data
rm -rf ~/Library/Developer/Xcode/DerivedData/*

# Reset package caches in Xcode
File β†’ Packages β†’ Reset Package Caches

Issue: GoogleService-Info.plist Not Found

Solution:

  1. Verify file is in Agrisense/ directory
  2. Check file is added to Agrisense target
  3. Clean build folder (βŒ˜β‡§K)
  4. Rebuild project

Issue: Code Signing Error

Solution:

  1. Go to Signing & Capabilities
  2. Enable "Automatically manage signing"
  3. Select your team
  4. Change bundle identifier if needed

Issue: Simulator Not Running

Solution:

# Kill all simulator processes
killall Simulator

# Reset simulator
xcrun simctl erase all

# Reboot simulator
xcrun simctl boot "iPhone 14 Pro"

Issue: Firebase Not Connecting

Solution:

  1. Verify GoogleService-Info.plist is correct
  2. Check Firebase project settings
  3. Ensure bundle ID matches Firebase configuration
  4. Check internet connection

πŸ”„ Updating Dependencies

Swift Packages

# In Xcode
File β†’ Packages β†’ Update to Latest Package Versions

Firebase

# Check for Firebase updates
# Xcode will notify of available updates
# Or manually update in Package Dependencies

πŸ“š Next Steps

After successful installation:

  1. Quick Start Guide - Build your first feature
  2. Project Architecture - Understand the codebase
  3. Contributing Guide - Start contributing

πŸ’‘ Tips

  • Use Simulator Shortcuts:

    • ⌘K - Toggle keyboard
    • βŒ˜β†’ - Rotate right
    • βŒ˜β‡§H - Home button
  • Debug Efficiently:

    • Enable Zombie Objects for memory debugging
    • Use View Debugger (Debug β†’ View Debugging β†’ Capture View Hierarchy)
    • Profile with Instruments (⌘I)
  • Version Control:

    • Create feature branches for development
    • Commit frequently with meaningful messages
    • Pull latest changes regularly

πŸ†˜ Getting Help

If you encounter issues:

  1. Check Troubleshooting Guide
  2. Search GitHub Issues
  3. Create new issue with:
    • Xcode version
    • iOS version
    • Error messages
    • Steps to reproduce

Ready to start developing? β†’ Quick Start Guide

Clone this wiki locally