mirror of
https://github.com/kiwix/kiwix-apple-custom.git
synced 2025-08-03 10:36:02 -04:00
Dynamically replace info plist values for custom apps, cutting out audio background if needed, removing live activity for all
This commit is contained in:
parent
583b9e0637
commit
a6464a5a50
@ -41,6 +41,7 @@ existing one if you need to create a new custom app.
|
|||||||
- **"neverLoad"**: it won't ask the user, and won't open any external links. This is handy if the external links handling is already contained in the zimfile itself, and we don't want to trigger any system level behaviour.
|
- **"neverLoad"**: it won't ask the user, and won't open any external links. This is handy if the external links handling is already contained in the zimfile itself, and we don't want to trigger any system level behaviour.
|
||||||
- `settings_show_external_link_option` - **true/false** in the app settings, the user is allowed to change the external link handling behaviour. If we want to restrict that and remove this option from the settings UI (so that the user cannot change the value), we can do that by setting this value to false.
|
- `settings_show_external_link_option` - **true/false** in the app settings, the user is allowed to change the external link handling behaviour. If we want to restrict that and remove this option from the settings UI (so that the user cannot change the value), we can do that by setting this value to false.
|
||||||
- `settings_show_search_snippet` - in most cases this should be **false** for a custom app. This removes the snippet from the search, which is used to filter the search results by ZIM files in the Kiwix app. Since custom apps come with a single ZIM file, this filter is not needed.
|
- `settings_show_search_snippet` - in most cases this should be **false** for a custom app. This removes the snippet from the search, which is used to filter the search results by ZIM files in the Kiwix app. Since custom apps come with a single ZIM file, this filter is not needed.
|
||||||
|
- `uses_audio` - (true | false) this will enable or disable the [UIBackgroundModes](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes) audio property in the final .plist file. Please note if the custom app is not using any media playback, it's recommended to turn this off, otherwise the release build might be rejected by Apple with: "The app declares support for audio in the UIBackgroundModes key in your Info.plist but we are unable to locate any features that require persistent audio."
|
||||||
- `zim_url` - this **is required** for a custom app, without this, it is not a custom app at all. This is used in a download step to create the custom app, and then bundled into the app itself. The **filename must end with the date format: YYYY-MM-DD.zim or with: YYYY-MM.zim**, as the version of the app is dictated by this. See more on that in the "Versioning and creating the app" section below.
|
- `zim_url` - this **is required** for a custom app, without this, it is not a custom app at all. This is used in a download step to create the custom app, and then bundled into the app itself. The **filename must end with the date format: YYYY-MM-DD.zim or with: YYYY-MM.zim**, as the version of the app is dictated by this. See more on that in the "Versioning and creating the app" section below.
|
||||||
If your download requires standard http authentication, see `zim_auth`.
|
If your download requires standard http authentication, see `zim_auth`.
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"settings_default_external_link_to": "alwaysLoad",
|
"settings_default_external_link_to": "alwaysLoad",
|
||||||
"settings_show_external_link_option": false,
|
"settings_show_external_link_option": false,
|
||||||
"settings_show_search_snippet": false,
|
"settings_show_search_snippet": false,
|
||||||
|
"uses_audio": false,
|
||||||
"zim_auth": "HTTP_BASIC_ACCESS_AUTHENTICATION",
|
"zim_auth": "HTTP_BASIC_ACCESS_AUTHENTICATION",
|
||||||
"zim_url": "https://www.dwds.de/kiwix/f/dwds_de_dictionary_nopic_2025-02-11.zim"
|
"zim_url": "https://www.dwds.de/kiwix/f/dwds_de_dictionary_nopic_2025-02-11.zim"
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,16 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import plistlib
|
import plistlib
|
||||||
|
|
||||||
|
PLIST_KEY_BACKGROUND_MODES = "UIBackgroundModes"
|
||||||
|
PLIST_KEY_LIVE_ACTIVITY = "NSSupportsLiveActivities"
|
||||||
|
PLIST_KEY_LIVE_ACTIVITY_FREQUENT = "NSSupportsLiveActivitiesFrequentUpdates"
|
||||||
JSON_KEY_ZIM_URL = "zim_url"
|
JSON_KEY_ZIM_URL = "zim_url"
|
||||||
JSON_KEY_AUTH = "zim_auth"
|
JSON_KEY_AUTH = "zim_auth"
|
||||||
JSON_BUNDLE_ID = "bundle_id"
|
JSON_BUNDLE_ID = "bundle_id"
|
||||||
JSON_KEY_APP_NAME = "app_name"
|
JSON_KEY_APP_NAME = "app_name"
|
||||||
JSON_KEY_ENFORCED_LANGUAGE = "enforced_lang"
|
JSON_KEY_ENFORCED_LANGUAGE = "enforced_lang"
|
||||||
JSON_KEY_DEVELOPMENT_TEAM = "development_team"
|
JSON_KEY_DEVELOPMENT_TEAM = "development_team"
|
||||||
|
JSON_KEY_USES_AUDIO = "uses_audio"
|
||||||
CUSTOM_ZIM_FILE_KEY = "CUSTOM_ZIM_FILE"
|
CUSTOM_ZIM_FILE_KEY = "CUSTOM_ZIM_FILE"
|
||||||
JSON_TO_PLIST_MAPPING = {
|
JSON_TO_PLIST_MAPPING = {
|
||||||
"app_store_id": "APP_STORE_ID",
|
"app_store_id": "APP_STORE_ID",
|
||||||
@ -43,10 +47,18 @@ class InfoParser:
|
|||||||
self.version = Version.from_file_name(file_name=self.zim_file_name,
|
self.version = Version.from_file_name(file_name=self.zim_file_name,
|
||||||
build_number=build_number)
|
build_number=build_number)
|
||||||
self.development_team_id = self._development_team()
|
self.development_team_id = self._development_team()
|
||||||
|
self.uses_audio = self.data[JSON_KEY_USES_AUDIO] == True
|
||||||
|
|
||||||
def create_plist(self, based_on_plist_file):
|
def create_plist(self, based_on_plist_file):
|
||||||
with based_on_plist_file.open(mode="rb") as file:
|
with based_on_plist_file.open(mode="rb") as file:
|
||||||
plist = plistlib.load(file)
|
plist = plistlib.load(file)
|
||||||
|
# handle Background mode audio:
|
||||||
|
if self.uses_audio == False:
|
||||||
|
plist[PLIST_KEY_BACKGROUND_MODES].remove("audio")
|
||||||
|
# remove live activity for custom apps:
|
||||||
|
plist.pop(PLIST_KEY_LIVE_ACTIVITY, None)
|
||||||
|
plist.pop(PLIST_KEY_LIVE_ACTIVITY_FREQUENT, None)
|
||||||
|
# replace plist values according to custom json:
|
||||||
for keyValues in self._plist_key_values():
|
for keyValues in self._plist_key_values():
|
||||||
for key in keyValues:
|
for key in keyValues:
|
||||||
plist[key] = keyValues[key]
|
plist[key] = keyValues[key]
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
"settings_default_external_link_to": "alwaysLoad",
|
"settings_default_external_link_to": "alwaysLoad",
|
||||||
"settings_show_external_link_option": true,
|
"settings_show_external_link_option": true,
|
||||||
"settings_show_search_snippet": false,
|
"settings_show_search_snippet": false,
|
||||||
|
"uses_audio": true,
|
||||||
"zim_url": "https://dev.kiwix.org/apple/custom/test/wikipedia_en_ray_charles_maxi_2023-12.zim"
|
"zim_url": "https://dev.kiwix.org/apple/custom/test/wikipedia_en_ray_charles_maxi_2023-12.zim"
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
"settings_default_external_link_to": "alwaysLoad",
|
"settings_default_external_link_to": "alwaysLoad",
|
||||||
"settings_show_external_link_option": true,
|
"settings_show_external_link_option": true,
|
||||||
"settings_show_search_snippet": false,
|
"settings_show_search_snippet": false,
|
||||||
|
"uses_audio": true,
|
||||||
"zim_url": "https://mirror.download.kiwix.org/zim/.hidden/custom_apps/mdwiki_en_all-app_maxi_2024-03.zim"
|
"zim_url": "https://mirror.download.kiwix.org/zim/.hidden/custom_apps/mdwiki_en_all-app_maxi_2024-03.zim"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user