# Native Build - excluded files not working

**URL:** <https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926>\
**Category:** Native builds\
**Created:** [September 3, 2023, 5:49pm UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926 "2023-09-03T17:49:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kao14](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kao14/32/1339_2.png) [@Kao14](https://forums.solar2d.com/u/Kao14)\
**Post date:** [September 3, 2023, 5:49pm UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/1 "2023-09-03T17:49:56Z")

</div>

Hello,

the excluded files for iOS are not working.  
on Android native build it working fine.  
in the **build.settings:**

```auto
excludeFiles =
{
	-- Exclude unnecessary files for each platform

	ios = { "AndroidResources/*","fire_storage/*", "converter/*", "assets/whitelabels/*"},
	iphone = { "AndroidResources/*","fire_storage/*", "converter/*", "assets/whitelabels/*"},
        [...]
}

```

 ![aaa](https://forums.solar2d.com/uploads/default/original/2X/2/2163a9a01d0d01a97fd479a6afa25d5b5dc3969b.png)

The **converter** folder is not empty  
 ![sasasasa](https://forums.solar2d.com/uploads/default/original/2X/1/1cffb379baae5af9a386311449d8b5e76f994ab9.png)

**Second Test:**

We tested it on a new clean Project. Created an Archive a \*.ipa-file and unzip it, and view package content. The Icon.png is still there:

 ![test1](https://forums.solar2d.com/uploads/default/original/2X/3/3da729f12cf5548f76567ebb1e966e1ae0b5db45.jpeg)

**build.settings:**

```auto

settings =
{
	orientation =
	{
		-- Supported values for orientation:
		-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
		default = "portrait",
		supported = { "portrait", },
	},

	--
	-- Android section
	--
	android =
	{
		usesPermissions =
		{
			"android.permission.INTERNET",
		},
	},

	--
	-- iOS section
	--
	iphone =
	{
		xcassets = "Images.xcassets",
		plist =
		{
			UIStatusBarHidden = false,
			UILaunchStoryboardName = "LaunchScreen",
		},
	},

	--
	-- Plugins section
	--
	plugins =
	{

	},

	--
	-- Project section
	--
	excludeFiles =
	{
		-- Exclude unnecessary files for each platform
		all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", },
		android = { "LaunchScreen.storyboardc", },
	},
}

```

---

<div class="post-metadata">

**Author:** ![elvo](https://forums.solar2d.com/user_avatar/forums.solar2d.com/elvo/32/1367_2.png) [@elvo](https://forums.solar2d.com/u/elvo)\
**Post date:** [September 6, 2023, 9:21pm UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/2 "2023-09-06T21:21:05Z")

</div>

We have the same issue. We’ve also tried to exclude the files through Xcode directly but to no avail. I hope someone can help.

---

<div class="post-metadata">

**Author:** ![Kao14](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kao14/32/1339_2.png) [@Kao14](https://forums.solar2d.com/u/Kao14)\
**Post date:** [September 7, 2023, 3:59pm UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/3 "2023-09-07T15:59:55Z")

</div>

I have a simple solution, to delete the files after build in iOS

Add the script in the follow steps:

Add a script in the build phase in your XCode project:

 ![pic1](https://forums.solar2d.com/uploads/default/original/2X/c/c95e47330c47feca52792b53a4fc3174527c7442.png)

After that drag the script at the very End of the build phases, you can rename it.

 ![pic2](https://forums.solar2d.com/uploads/default/original/2X/d/d9de0672a8e559302be18b591677a668a19badf4.jpeg)

Add the follow Code:

```auto
## Remove not needed files
echo "START FOLDER DELETE"

rootPath="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"

foldersToDelete=("yourDeletefolder1" "yourDeletefolder2" "yourDeletefolder3")

for folderName in "${foldersToDelete[@]}"; do
    folderPathInRoot="${rootPath}/${folderName}"
    
    if [-d "$folderPathInRoot"]; then
        echo "Delete Folder $folderName in App.app"
        rm -rf "$folderPathInRoot"
    else
        echo "Delete Folder $folderName in App.app not found!"
    fi
done

echo "START FOLDER"
for entry in "$rootPath"/*
do
  echo "$entry"
done

echo "END FOLDER"

```

If you had some questions, feel free 🙂

---

<div class="post-metadata">

**Author:** ![elvo](https://forums.solar2d.com/user_avatar/forums.solar2d.com/elvo/32/1367_2.png) [@elvo](https://forums.solar2d.com/u/elvo)\
**Post date:** [September 8, 2023, 7:05am UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/4 "2023-09-08T07:05:40Z")

</div>

Thanks for sharing this! It looks like a nice and easy workaround. We’ll try it. 👍

---

<div class="post-metadata">

**Author:** ![elvo](https://forums.solar2d.com/user_avatar/forums.solar2d.com/elvo/32/1367_2.png) [@elvo](https://forums.solar2d.com/u/elvo)\
**Post date:** [September 26, 2023, 7:48am UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/5 "2023-09-26T07:48:07Z")

</div>

@Kao14 I tried your suggestion for deleting unused folders and it works like a charm! Thank you!

---

<div class="post-metadata">

**Author:** ![elvo](https://forums.solar2d.com/user_avatar/forums.solar2d.com/elvo/32/1367_2.png) [@elvo](https://forums.solar2d.com/u/elvo)\
**Post date:** [September 26, 2023, 7:49am UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/6 "2023-09-26T07:49:09Z")

</div>

@Kao14 Apart from folders, is there a way to delete unused files as well?

---

<div class="post-metadata">

**Author:** ![Kao14](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kao14/32/1339_2.png) [@Kao14](https://forums.solar2d.com/u/Kao14)\
**Post date:** [September 26, 2023, 1:39pm UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/7 "2023-09-26T13:39:21Z")

</div>

@elvo

Here Created by ChatGPT:

Not tested 😉

```auto
## Remove not needed files
echo "START FOLDER DELETE"

rootPath="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"

foldersToDelete=("yourDeletefolder1" "yourDeletefolder2" "yourDeletefolder3")
filesToDelete=("file1.txt" "file2.txt" "file3.txt")

for folderName in "${foldersToDelete[@]}"; do
    folderPathInRoot="${rootPath}/${folderName}"
    
    if [-d "$folderPathInRoot"]; then
        echo "Delete Folder $folderName in App.app"
        rm -rf "$folderPathInRoot"
    else
        echo "Delete Folder $folderName in App.app not found!"
    fi
done

for fileName in "${filesToDelete[@]}"; do
    filePathInRoot="${rootPath}/${fileName}"
    
    if [-f "$filePathInRoot"]; then
        echo "Delete File $fileName in App.app"
        rm "$filePathInRoot"
    else
        echo "Delete File $fileName in App.app not found!"
    fi
done

echo "START FOLDER"
for entry in "$rootPath"/*
do
  echo "$entry"
done

echo "END FOLDER"

```

---

<div class="post-metadata">

**Author:** ![elvo](https://forums.solar2d.com/user_avatar/forums.solar2d.com/elvo/32/1367_2.png) [@elvo](https://forums.solar2d.com/u/elvo)\
**Post date:** [October 9, 2023, 6:46am UTC](https://forums.solar2d.com/t/native-build-excluded-files-not-working/355926/8 "2023-10-09T06:46:28Z")

</div>

@Kao14 Looks legit, I’ll try it. Thanks!
