I have an Xcode project setup with multiple targets/schemes so that I have several apps under the same codebase.
I created the following testing lane in my Fastfile which runs the "sigh" tool for every one of my apps:
lane :testing do
["First", "Second", "Third", "Fourth"].each do |scheme_name|
sigh
end
end
Looking at the fastlane documentation, I see you can define a bundle identifier, which sigh uses. But I need it to automatically grab the current bundle identifier from each target/scheme's plist and use that for sigh. Can this be accomplished?
Something like (psuedo code):
bundle_id = get_bundle_id_from_plist
sigh(app_identifier: bundle_id)
I tried using this plugin: https://github.com/SiarheiFedartsou/fastlane-plugin-versioning which has a method for getting plist path. I then ran this code:
bundle_id = get_info_plist_value(path: get_info_plist_path(target: scheme_name), key: 'CFBundleIdentifier')
puts bundle_id
The output is $(PRODUCT_BUNDLE_IDENTIFIER), which actually what is in the plist value, so I'm getting closer. But I need this to return the actual bundle id, not just the variable it points to.
The whole reason for me wanting to use sigh is because each app/target has its own provisioning profiles that I had to manually generate initially because of CarPlay entitlement. I would like it to automatically create new provisioning profiles for each target when they expire.
I do not know of any fastlane
actions that provide such functionality, but you may be able to build a local fastlane action, or create and share a fastlane plugin, that provides the CFBundleIdentifier
using the code that updates an info plist using the scheme name as an example.
This code uses the xcodeproj
Ruby gem to get the Info.plist file from the Scheme. It then changes plist values and then saves the plist file. You could do something similar except just return the CFBundleIdentifier
from the plist.
If you don't want to create the plugin, I can create it later on this week as this interests me.
This code should work for you until I get the plugin finished:
# At the top of your Fastfile; you may need to add "gem 'xcodeproj'" to your Gemfile and then do a bundle install
require 'xcodeproj'
def product_bundle_id(scheme)
project = Xcodeproj::Project.open('path/to/your/xcodeproj')
scheme = project.native_targets.find { |target| target.name == scheme }
build_configuration = scheme.build_configurations.first
build_configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
end
lane :testing do
["First", "Second", "Third", "Fourth"].each do |scheme_name|
sigh(app_identifier: product_bundle_id(scheme_name))
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With