Skip to content

Custom iOS plist file names #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ flavorizr:
| key | type | default | required | description |
|:--------------|:-----------|:--------|:---------|:-----------------------------------------------------------------------------------------------|
| buildSettings | Dictionary | {} | false | An XCode build configuration dictionary [XCode Build Settings](https://xcodebuildsettings.com) |
| iOSPListFiles | List | [] | false | A list of custom iOS plist files (including paths) |

```yaml
flavorizr:
app:
android:
flavorDimensions: "flavor-type"
ios:
iOSPListFiles:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename it to infoFiles?

Suggested change
iOSPListFiles:
infoFiles:

- "ios/Runner/Info-Debug.plist"
- "ios/Runner/Info-Profile.plist"
- "ios/Runner/Info-Release.plist"
```

#### macos (under app)

Expand Down
7 changes: 6 additions & 1 deletion lib/src/parser/models/config/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ part 'ios.g.dart';

@JsonSerializable(anyMap: true, createToJson: false)
class IOS with BuildSettingsMixin {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should extend this feature to macos also

IOS({Map<String, dynamic> buildSettings = const {}}) {
IOS(
{Map<String, dynamic> buildSettings = const {},
this.iOSPListFiles = const []}) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer we set the default Info.plist path file here

this.buildSettings = BuildSettingsMixin.iosDefaultBuildSettings;
this.buildSettings.addAll(buildSettings);
}

@JsonKey(disallowNullValue: true, defaultValue: [])
final List<String> iOSPListFiles;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final List<String> iOSPListFiles;
final List<String> infoFiles;


factory IOS.fromJson(Map<String, dynamic> json) => _$IOSFromJson(json);
}
22 changes: 16 additions & 6 deletions lib/src/parser/models/config/ios.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions lib/src/processors/processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,28 @@ class Processor extends AbstractProcessor<void> {
'ios:icons': () => IOSIconsProcessor(
config: flavorizr,
),
'ios:plist': () => ExistingFileStringProcessor(
K.iOSPListPath,
IOSPListProcessor(config: flavorizr),
config: flavorizr,
),
'ios:plist': () => (flavorizr.app?.ios?.iOSPListFiles != null &&
flavorizr.app!.ios!.iOSPListFiles.isNotEmpty
? QueueProcessor(
flavorizr.app!.ios!.iOSPListFiles
.map<ExistingFileStringProcessor>(
(String path) => ExistingFileStringProcessor(
path,
IOSPListProcessor(config: flavorizr),
config: flavorizr,
))
.toList(),
config: flavorizr,
)
: ExistingFileStringProcessor(
flavorizr.app?.ios != null &&
flavorizr.app!.ios!.buildSettings
.containsKey('INFOPLIST_FILE')
? flavorizr.app?.ios?.buildSettings['INFOPLIST_FILE']
: K.iOSPListPath,
IOSPListProcessor(config: flavorizr),
config: flavorizr,
)) as AbstractProcessor<void>,
Comment on lines +253 to +274
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly don't like putting too much logic here as it makes the processor file unreadable.

I think it would be better to create another processor that extends a QueueProcessor (you can follow this PR to better understand what I mean) and add the logic there.

If the user doesn't define a custom set of info files, the processor should process at least the default one.

Question: Why do we need INFOPLIST_FILE in the buildSettings? You should access infoFiles instead

'ios:launchScreen': () => IOSTargetsLaunchScreenFileProcessor(
'ruby',
K.tempDarwinAddFileScriptPath,
Expand Down