Reputation: 201
Quick overview: I have a private cocoapod which adds Fabric and Crashlytics via Carthage.
And I have a run script in the build phase:
/usr/local/bin/carthage copy-frameworks
Input files: $(SRCROOT)/Carthage/Build/iOS/Crashlytics.framework
Output files: $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Crashlytics.framework
In my podspec I have:
s.script_phases = [
{
:name => 'Fabric Setup',
:script => '"${PODS_TARGET_SRCROOT}/Carthage/Build/iOS/Fabric.framework/run" {key} {secret}',
:execution_position => :after_compile
}
]
So far so good.
In my app project that pulls in this private cocoapod i'm using fastlane.
crashlytics(
crashlytics_path: "...",
api_token: "...",
build_secret: "...",
groups: "..."
)
I'm trying to work out what to put for the crashlytics_path so that it points to the Crashlytics.framework generated by my private cocoapod carthage.
Project folder structures:
My Private Pod:
/Users/{MY_USER}/Repositories/Libs/{PRIVATE_POD_LIB}
Crashlytics location within Private Pod:
/Users/{MY_USER}/Repositories/Libs/{PRIVATE_POD_LIB}/Carthage/Build/iOS/Crashlytics.framework
The app that pulls in my private pod:
/Users/{MY_USER}/Repositories/Apps/{MY_APP}
If I edit the crashlytics_path in Fastlane to this it works:
crashlytics_path:
"/Users/{MY_USER}/Repositories/Libs/{PRIVATE_POD_LIB}/Carthage/Build/iOS/Crashlytics.framework",
But obviously I don't want to put the full path with my user in it as it needs to work on a Jenkins server and other user machines.
Any help appreciated.
Thanks
Upvotes: 0
Views: 281
Reputation: 758
If you need to hardcode a path to work in multiple environments I would suggest using an environment variable.
For your local development machine environment, you could create a .env
in your fastlane
directory (fastlane/.env
) with the following contents:
CRASHLYTICS_FRAMEWORK_PATH=/Users/{MY_USER}/Repositories/Libs/{PRIVATE_POD_LIB}/Carthage/Build/iOS/Crashlytics.framework
Also make sure to add this .env
file to your .gitignore
file so that it does not get committed to your repository and does not get used on your Jenkins build.
You can then set the CRASHLYTICS_FRAMEWORK_PATH
environment variable to something different on your Jenkins machine.
You can also find more documentation on environment variables here - https://docs.fastlane.tools/advanced/other/#environment-variables
Upvotes: 1