jdee / settings-bundle Goto Github PK
View Code? Open in Web Editor NEWFastlane plugin to update static settings in an iOS settings bundle
License: MIT License
Fastlane plugin to update static settings in an iOS settings bundle
License: MIT License
When adding a settings bundle to a project, there is an option to call it something other than Settings. This doesn't seem to be a common use case, but it is possible. Rather than looking for a file in the project called Settings.bundle, it might be necessary to allow the name to be passed in or infer the location by looking for a directory called *.bundle (containing a file called Root.plist).
This would require further modifications to the built-in commit_version_bump
action. If this becomes an issue for anyone, it can be addressed then.
The new target param added in the last release broke my update_settings_bundle fastlane plugin. Have already verified it works with 1.0 and fails after upgrading to 1.1. The issue is that the new param's key to fastlane is a duplicate of an existing key 'file':
FastlaneCore::ConfigItem.new(key: :file,
env_name: "SETTINGS_BUNDLE_TARGET",
description: "An optional target name from the project",
optional: true,
type: String)
I believe the key: should be key: :target instead of :file since :file is an existing param in 1.0
Any support for multi-value keys?
Root.plist:
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Environments</string>
<key>Key</key>
<string>app_environment</string>
<key>Titles</key>
<array>
<string>localhost</string>
<string>prd</string>
</array>
<key>Values</key>
<array>
<string>localhost</string>
<string>prd</string>
</array>
</dict>
Fastfile:
lane :change_env_settings do |options|
update_settings_bundle(
key: "app_environment",
value: options[:value]
)
end
Error:
[!] preference for key app_environment must be of type title
Since the inclusion of this pull request in Fastlane, the Fastlane::Actions.ignore_cocoapods_path
has been removed in favour of Fastlane::Helper::XcodeprojHelper
which detects Carthage and Cocoapod workspace project files.
My suggestion is that settings_bundle_helper.rb:143 needs changing to:
xcodeproj_paths = Fastlane::Helper::XcodeprojHelper.find(all_xcodeproj_paths)
And then the failing test in specs/settings_bundle_helper_spec.rb need their expectations changing to expect 2 calls to the Dir method.
This is probably due to the plist
gem representing the keys as a Hash
. When it writes out the updated file, it iterates through the keys in order. The only practical result is that a diff shows a lot of changes in the settings bundle the first time the action runs. If the settings bundle is only afterward updated by this action, the diffs will be simpler, since the keys will not be reordered each time. Still, it would be preferable to retain the original key order.
I have separate Settings.bundle at different paths and trying to use this plugin and it is failing to update it
New to Fastlane and Ruby, so apologies if I have done something stupid to cause my error.
I have the following in my fastfile:
update_settings_bundle(
xcodeproj: "appdemo.xcodeproj",
key: "pref_env",
value: "QA"
)
When I run my fastfile, I get the following error:
undefined method
[]' for nil:NilClass`
Root.plist is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Version</string>
<key>Key</key>
<string>pref_version</string>
<key>DefaultValue</key>
<string>?????????</string>
</dict>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Environment</string>
<key>Key</key>
<string>pref_env</string>
<key>DefaultValue</key>
<string>?????????</string>
</dict>
</array>
</dict>
</plist>
This is just a place for community comment and review before releasing this gem. Feel free to open other issues for specific things.
Some issues/questions:
value:
argument. See the README. This target
parameter to specify the target by name, though I'm not sure you can have multiple application targets in the same project. If so, they'll share the same Settings.bundle. Specifying the target may be pointless.prefs:
URI still works in iOS 10. Apple seems to have killed this URI scheme.Still to do:
Original Fastlane issue/discussion: fastlane/fastlane#5758
I'd like to generate a whole settings bundle with your tool. Therefore i need to add other options aswell than just textual settings like entering a type (textual read/write, switch), a default value, a secure enter, ...
Will this be available soon?
I noticed an app that has not only a version number but also a build date and release date in the settings bundle. The release date is unspecific ("Nov 2016"), so it's probably not something this app would automate. Otherwise you'd have to have a repackaging job to alter the settings bundle after a release candidate passed QA.
At any rate, there are tons of things that this plugin could conceivably add to a settings bundle, like the current time in a specified format. This could indicate one or more additional actions, but now that the action takes a format, it would be possible to generalize the idea. You have to be able to specify an strftime
format for times. It wouldn't be hard to support things like:
update_settings_bundle xcodeproj: "MyProject.xcodeproj", key: "BuildTime", format: ":time(%Y-%m-%d)"
update_settings_bundle xcodeproj: "MyProject.xcodeproj", key: "SDKVersion", format: "iOS SDK :sdk_version"
update_settings_bundle xcodeproj: "MyProject.xcodeproj", key: "APIHost", format: "api.example.com"
And so on. The last example is already possible, meaning the others are also possible if you obtain the information yourself, e.g.
update_settings_bundle xcodeproj: "MyProject.xcodeproj", key: "BuildTime", format: Time.now.strftime "%Y-%m-%d"
As long as the value specified doesn't contain :build
or :version
, it will be updated in the settings bundle plist specified.
Maybe it makes sense to change The format:
to value:
with the understanding that certain symbols will result in substitutions in the value.format:
argument has been changed to value:
in anticipation of this change. Additional content may wait until after the initial release, depending on interest.
It might also make sense to make the value:
argument required so that for the current functionality, you would use:
The value:
argument is now required:
update_settings_bundle xcodeproj: "MyProject.xcodeproj", key: "CurrentAppVersion", value: ":version (:build)"
WatchKit also supports settings bundles: https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/Settings.html
It's not obvious if this would be a candidate for static settings like version numbers and build dates. It appears to be primarily used to display controls to the user. It would probably be easy enough to support these settings bundles in this plugin if there is a use case for it.
Many Fastlane actions automatically find a project without specifying an argument for the path. The update_settings_bundle action should as well.
Note that you can also set ENV["SETTINGS_BUNDLE_XCODEPROJ"] = "MyProject.xcodeproj"
if you're invoking the action multiple times and want to avoid passing the parameter each time. This is done in the :library_test lane in the fastlane/Fastfile. It would be nice not to have to for simple or default behavior, however.
Hihi, I have a problem executing this.
In this line of the settings_bundle_helper.rb
file, the release_info_plist_path
contains the $(SRCROOT)
text in the file path, so it is throwing a rb sysopen - file not found
error.
This fix made it work
release_info_plist_path = File.join project_parent, release_info_plist_path.gsub("$(SRCROOT)/", "")
but its definitely not right to do it this way.
Am I missing something to make it work?
Many thanks! I looking forward to using this gem it will help me greatly. Thanks for it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.