@@ -21,24 +21,28 @@ use crate::config::Config;
2121use crate :: utils:: args:: ArgExt ;
2222use crate :: utils:: chunks:: { upload_chunks, Chunk , ASSEMBLE_POLL_INTERVAL } ;
2323use crate :: utils:: fs:: get_sha1_checksums;
24+ #[ cfg( target_os = "macos" ) ]
25+ use crate :: utils:: fs:: TempDir ;
2426use crate :: utils:: fs:: TempFile ;
2527#[ cfg( target_os = "macos" ) ]
26- use crate :: utils:: mobile_app:: handle_asset_catalogs;
27- use crate :: utils:: mobile_app:: {
28- ipa_to_xcarchive, is_aab_file, is_apk_file, is_apple_app, is_ipa_file, is_zip_file,
29- } ;
28+ use crate :: utils:: mobile_app:: { handle_asset_catalogs, ipa_to_xcarchive, is_ipa_file} ;
29+ use crate :: utils:: mobile_app:: { is_aab_file, is_apk_file, is_apple_app, is_zip_file} ;
3030use crate :: utils:: progress:: ProgressBar ;
3131use crate :: utils:: vcs;
3232
3333pub fn make_command ( command : Command ) -> Command {
34+ #[ cfg( target_os = "macos" ) ]
35+ let help_text = "The path to the mobile app files to upload. Supported files include Apk, Aab, XCArchive, and IPA." ;
36+ #[ cfg( not( target_os = "macos" ) ) ]
37+ let help_text = "The path to the mobile app files to upload. Supported files include Apk, Aab, and XCArchive." ;
3438 command
3539 . about ( "[EXPERIMENTAL] Upload mobile app files to a project." )
3640 . org_arg ( )
3741 . project_arg ( false )
3842 . arg (
3943 Arg :: new ( "paths" )
4044 . value_name ( "PATH" )
41- . help ( "The path to the mobile app files to upload. Supported files include Apk, Aab, XCArchive, and IPA." )
45+ . help ( help_text )
4246 . num_args ( 1 ..)
4347 . action ( ArgAction :: Append )
4448 . required ( true ) ,
@@ -97,22 +101,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
97101
98102 let normalized_zip = if path. is_file ( ) {
99103 debug ! ( "Normalizing file: {}" , path. display( ) ) ;
100-
101- // Handle IPA files by converting them to XCArchive
102- if is_zip_file ( & byteview) && is_ipa_file ( & byteview) ? {
103- debug ! ( "Converting IPA file to XCArchive structure" ) ;
104- let temp_dir = crate :: utils:: fs:: TempDir :: create ( ) ?;
105- ipa_to_xcarchive ( path, & byteview, & temp_dir)
106- . and_then ( |path| normalize_directory ( & path) )
107- . with_context ( || format ! ( "Failed to process IPA file {}" , path. display( ) ) ) ?
108- } else {
109- normalize_file ( path, & byteview) . with_context ( || {
110- format ! (
111- "Failed to generate uploadable bundle for file {}" ,
112- path. display( )
113- )
114- } ) ?
115- }
104+ handle_file ( path, & byteview) ?
116105 } else if path. is_dir ( ) {
117106 debug ! ( "Normalizing directory: {}" , path. display( ) ) ;
118107 normalize_directory ( path) . with_context ( || {
@@ -190,6 +179,25 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
190179 Ok ( ( ) )
191180}
192181
182+ fn handle_file ( path : & Path , byteview : & ByteView ) -> Result < TempFile > {
183+ // Handle IPA files by converting them to XCArchive
184+ #[ cfg( target_os = "macos" ) ]
185+ if is_zip_file ( byteview) && is_ipa_file ( byteview) ? {
186+ debug ! ( "Converting IPA file to XCArchive structure" ) ;
187+ let temp_dir = TempDir :: create ( ) ?;
188+ return ipa_to_xcarchive ( path, byteview, & temp_dir)
189+ . and_then ( |path| normalize_directory ( & path) )
190+ . with_context ( || format ! ( "Failed to process IPA file {}" , path. display( ) ) ) ;
191+ }
192+
193+ normalize_file ( path, byteview) . with_context ( || {
194+ format ! (
195+ "Failed to generate uploadable bundle for file {}" ,
196+ path. display( )
197+ )
198+ } )
199+ }
200+
193201fn validate_is_mobile_app ( path : & Path , bytes : & [ u8 ] ) -> Result < ( ) > {
194202 debug ! ( "Validating mobile app format for: {}" , path. display( ) ) ;
195203
@@ -211,15 +219,22 @@ fn validate_is_mobile_app(path: &Path, bytes: &[u8]) -> Result<()> {
211219 return Ok ( ( ) ) ;
212220 }
213221
222+ #[ cfg( target_os = "macos" ) ]
214223 if is_ipa_file ( bytes) ? {
215224 debug ! ( "Detected IPA file" ) ;
216225 return Ok ( ( ) ) ;
217226 }
218227 }
219228
220229 debug ! ( "File format validation failed" ) ;
230+ #[ cfg( target_os = "macos" ) ]
231+ let format_list = "APK, AAB, XCArchive, or IPA" ;
232+ #[ cfg( not( target_os = "macos" ) ) ]
233+ let format_list = "APK, AAB, or XCArchive" ;
234+
221235 Err ( anyhow ! (
222- "File is not a recognized mobile app format (APK, AAB, XCArchive, or IPA): {}" ,
236+ "File is not a recognized mobile app format ({}): {}" ,
237+ format_list,
223238 path. display( )
224239 ) )
225240}
0 commit comments