33// SPDX-License-Identifier: MIT
44
55use crate :: {
6- helpers:: { app_paths:: tauri_dir, config:: Config as TauriConfig } ,
6+ helpers:: {
7+ app_paths:: tauri_dir,
8+ config:: { Config as TauriConfig , ConfigHandle } ,
9+ } ,
710 interface:: { AppInterface , AppSettings , DevProcess , Interface , Options as InterfaceOptions } ,
811} ;
12+ #[ cfg( target_os = "macos" ) ]
13+ use anyhow:: Context ;
914use anyhow:: { bail, Result } ;
1015use heck:: ToSnekCase ;
1116use jsonrpsee:: core:: client:: { Client , ClientBuilder , ClientT } ;
@@ -277,7 +282,13 @@ pub fn get_app(config: &TauriConfig, interface: &AppInterface) -> App {
277282 } )
278283}
279284
280- fn ensure_init ( project_dir : PathBuf , target : Target ) -> Result < ( ) > {
285+ #[ allow( unused_variables) ]
286+ fn ensure_init (
287+ tauri_config : & ConfigHandle ,
288+ app : & App ,
289+ project_dir : PathBuf ,
290+ target : Target ,
291+ ) -> Result < ( ) > {
281292 if !project_dir. exists ( ) {
282293 bail ! (
283294 "{} project directory {} doesn't exist. Please run `tauri {} init` and try again." ,
@@ -286,6 +297,51 @@ fn ensure_init(project_dir: PathBuf, target: Target) -> Result<()> {
286297 target. command_name( ) ,
287298 )
288299 }
300+
301+ let tauri_config_guard = tauri_config. lock ( ) . unwrap ( ) ;
302+ let tauri_config_ = tauri_config_guard. as_ref ( ) . unwrap ( ) ;
303+
304+ let mut project_outdated_reasons = Vec :: new ( ) ;
305+
306+ match target {
307+ Target :: Android => {
308+ let java_folder = project_dir
309+ . join ( "app/src/main/java" )
310+ . join ( tauri_config_. identifier . replace ( '.' , "/" ) ) ;
311+ if !java_folder. exists ( ) {
312+ project_outdated_reasons
313+ . push ( "you have modified your \" identifier\" in the Tauri configuration" ) ;
314+ }
315+ }
316+ #[ cfg( target_os = "macos" ) ]
317+ Target :: Ios => {
318+ let project_yml = read_to_string ( project_dir. join ( "project.yml" ) )
319+ . context ( "missing project.yml file in the Xcode project directory" ) ?;
320+ if !project_yml. contains ( & format ! (
321+ "PRODUCT_BUNDLE_IDENTIFIER: {}" ,
322+ tauri_config_. identifier
323+ ) ) {
324+ project_outdated_reasons
325+ . push ( "you have modified your \" identifier\" in the Tauri configuration" ) ;
326+ }
327+
328+ println ! ( "{}" , app. lib_name( ) ) ;
329+ if !project_yml. contains ( & format ! ( "framework: lib{}.a" , app. lib_name( ) ) ) {
330+ project_outdated_reasons
331+ . push ( "you have modified your [lib.name] or [package.name] in the Cargo.toml file" ) ;
332+ }
333+ }
334+ }
335+
336+ if !project_outdated_reasons. is_empty ( ) {
337+ let reason = project_outdated_reasons. join ( " and " ) ;
338+ bail ! (
339+ "{} project directory is outdated because {reason}. Please run `tauri {} init` and try again." ,
340+ target. ide_name( ) ,
341+ target. command_name( ) ,
342+ )
343+ }
344+
289345 Ok ( ( ) )
290346}
291347
0 commit comments