SDK iOS FAQ
This FAQ addresses common issues encountered when integrating the AppTrove SDK into iOS applications, focusing on module loading errors in Swift. Each issue includes detailed explanations and solutions, including Podfile configurations and deployment target settings.
1. Why does the error "Cannot load underlying module for 'Alamofire'"
occur in AppDelegate.swift
when integrating the AppTrove SDK?
Issue: The Xcode build fails with the following error in AppDelegate.swift
:
Cannot load underlying module for 'Alamofire'
Cause: This error occurs because the AppTrove SDK likely depends on Alamofire, a popular networking library, but the CocoaPods configuration is not correctly set up to include Swift frameworks. Without the use_frameworks!
directive in the Podfile
, CocoaPods treats dependencies as static libraries, which can cause module loading issues for Swift-based dependencies like Alamofire. Additionally, mismatched deployment targets between the app and dependencies can exacerbate the issue.
Solution:
To resolve the module loading error, update the Podfile
and ensure consistent deployment targets for all dependencies. Follow these steps:
- Add
use_frameworks!
to the Podfile:- Open the
Podfile
in the root directory of your iOS project. - Add the
use_frameworks!
directive to enable dynamic frameworks for Swift dependencies. A samplePodfile
might look like this:
- Open the
platform :ios, '13.0'
target 'YourAppName' do
use_frameworks!
# AppTrove SDK and its dependencies
pod 'trackier-ios-sdk' # Use the latest version specified in Trackier documentation
pod 'Alamofire', '~> 5.9.1' # Explicitly include Alamofire if required
end
-
Set Consistent Deployment Targets:
- Ensure the iOS deployment target for the app and all dependencies is compatible. For example, set the deployment target to iOS 13.0 or higher (as required by the AppTrove SDK).
- Update the
Podfile
to specify the platform version (e.g.,platform :ios, '13.0'
). - In Xcode, go to the project settings:
- Select the project in the Project Navigator.
- Under the General tab, set the iOS Deployment Target to
13.0
(or the version specified by AppTrove SDK) for the main target. - Under the Pods project in the Project Navigator, ensure all pods (e.g., TrackierSDK, Alamofire) have the same deployment target:
- Select the Pods project.
- For each target (e.g., TrackierSDK, Alamofire), set the iOS Deployment Target to
13.0
.
-
Update Pods:
- Run the following commands in the terminal from the project directory to update the CocoaPods dependencies:
pod install --repo-update
- This ensures the latest compatible versions of TrackierSDK and Alamofire are installed.
-
Clean and Rebuild the Project:
- In Xcode, clean the build folder (
Product > Clean Build Folder
orShift + Command + K
). - Rebuild the project (
Product > Build
orCommand + B
). - Open the generated
.xcworkspace
file (not.xcodeproj
) to ensure the Pods are correctly integrated.
- In Xcode, clean the build folder (
-
Verify Alamofire Import:
- In
AppDelegate.swift
or other Swift files, ensure Alamofire is imported correctly (if used directly):
- In
import Alamofire
- If the AppTrove SDK handles Alamofire internally, you may not need to import it explicitly.
Explanation:
- The
use_frameworks!
directive tells CocoaPods to treat dependencies as dynamic frameworks, which is necessary for Swift-based libraries like Alamofire to work correctly in a Swift project. - Setting a consistent iOS deployment target ensures that the app and all dependencies are built for the same iOS version, preventing compatibility issues.
- Running
pod install --repo-update
ensures the CocoaPods repository is up-to-date and installs the correct versions of dependencies.
Additional Tips:
- Check the AppTrove SDK documentation for the exact versions of Alamofire and other dependencies required.
- If the error persists, verify that the
Pods
directory contains the expected frameworks (e.g.,TrackierSDK.framework
,Alamofire.framework
). - Ensure the
Podfile.lock
file is not enforcing an outdated version of Alamofire. If necessary, deletePodfile.lock
and runpod install
again.
2. How do I troubleshoot other AppTrove SDK integration issues on iOS?
General Troubleshooting Steps:
- Check SDK Version:
- Ensure you are using the latest version of the AppTrove SDK for iOS. Update the
Podfile
with the latest version:
- Ensure you are using the latest version of the AppTrove SDK for iOS. Update the
pod 'trackier-ios-sdk' # Replace with the latest version
- Run
pod update
to install the latest version:
pod update
-
Verify Podfile Configuration:
- Confirm that
use_frameworks!
is included in thePodfile
. - Ensure all required dependencies (e.g., Alamofire) are explicitly listed if not included transitively by the AppTrove SDK.
- Confirm that
-
Enable Logging:
- Enable debug logging in the AppTrove SDK to identify runtime issues. Refer to the AppTrove SDK documentation for instructions on enabling verbose logs.
-
Check Build Settings:
- In Xcode, verify that the Framework Search Paths and Library Search Paths include the
Pods
directory. - Ensure the Swift Version in the project settings matches the version required by the AppTrove SDK (e.g., Swift 5.0 or later).
- In Xcode, verify that the Framework Search Paths and Library Search Paths include the
-
Test in Staging:
- Build and test the app on a simulator or physical device to replicate production conditions.
- Use Xcode's Debug configuration initially, then test with Release to ensure no issues arise during optimization.
-
Check Permissions:
- Ensure the app has the necessary permissions in
Info.plist
, such as network access. For example:
- Ensure the app has the necessary permissions in
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- If the AppTrove SDK requires additional permissions (e.g., for tracking), ensure they are configured as per the documentation.
- Contact Support:
- If issues persist, contact AppTrove SDK support with the following details:
- AppTrove SDK version
- Xcode version
- iOS deployment target
- Podfile and Podfile.lock contents
- Build error logs or stack traces
- If issues persist, contact AppTrove SDK support with the following details:
Additional Resources
- AppTrove SDK Documentation: Refer to the official AppTrove SDK documentation for iOS integration steps.
- CocoaPods Documentation: Learn more about managing dependencies with CocoaPods at cocoapods.org.
- Apple Developer Documentation: Visit developer.apple.com for guidance on Xcode configuration and Swift development.
For further assistance, reach out to AppTrove SDK support or consult the iOS developer community.
For complete documentation, visit the Trackier Developer Portal.