Bookstore

Recent

Author Topic: (SOLVED) Clean the project - remove unnecessary components  (Read 259 times)

AsleyCruz

  • Jr. Member
  • **
  • Posts: 62
    • Graphic and apps designer
(SOLVED) Clean the project - remove unnecessary components
« on: February 26, 2020, 10:27:55 pm »
Hi team

We sometimes add components in our project, but in the end, we decided not to use that component.
But we still have its unit in "Uses" section or in the section "Required packages" and this makes the .exe size increase.

Is there a way to remove automatically that unnecessary components that our project does not need?

Thanks in advance.
« Last Edit: February 27, 2020, 01:16:28 am by AsleyCruz »
AsleyCruz - Graphic and apps designer
-
http://www.asleycruz.com/

lucamar

  • Hero Member
  • *****
  • Posts: 2588
Re: Clean the project - remove unnecessary components
« Reply #1 on: February 26, 2020, 10:41:35 pm »
To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units", which can also be accessed through the pop-up menu of the editor.

If that doesn't work then you'll have to do it by hand, deleting the offending references in the source. Note that hovering the mouse pointer over a control/component class will tell you (most of the time) in which unit it's declared. Also, compiling after each deletion will allow you to ascertain whether the deleted unit is still "used", somehow, in your code (look for "Identifier not found" errors).

Package dependencies can be deleted in the Project Inspector (menu Project->Project Inspector). Again. compiling after each deletion will tell you whether the dependency was really needed.

HTH!
« Last Edit: February 26, 2020, 10:48:23 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8099
Re: Clean the project - remove unnecessary components
« Reply #2 on: February 26, 2020, 10:41:50 pm »
No, this is not really easy to do components might be added runtime.

howardpc

  • Hero Member
  • *****
  • Posts: 3358
Re: Clean the project - remove unnecessary components
« Reply #3 on: February 26, 2020, 10:44:06 pm »
There is no way to remove unnecessary components, except manual deletion.
 Only the developer knows whether a component is needed. If it is not needed, just delete it.

How can the IDE read your mind to know whether you need it or not?

jamie

  • Hero Member
  • *****
  • Posts: 2490
Re: Clean the project - remove unnecessary components
« Reply #4 on: February 26, 2020, 10:58:37 pm »
Deleting it via the OI does work but you still have the units behind in the uses list however, the warnings tell you that it's not being used and thus it should be ok.
Number 1 at blue screen app creations!

AsleyCruz

  • Jr. Member
  • **
  • Posts: 62
    • Graphic and apps designer
Re: Clean the project - remove unnecessary components
« Reply #5 on: February 27, 2020, 01:16:04 am »
To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units", which can also be accessed through the pop-up menu of the editor.

If that doesn't work then you'll have to do it by hand, deleting the offending references in the source. Note that hovering the mouse pointer over a control/component class will tell you (most of the time) in which unit it's declared. Also, compiling after each deletion will allow you to ascertain whether the deleted unit is still "used", somehow, in your code (look for "Identifier not found" errors).

Package dependencies can be deleted in the Project Inspector (menu Project->Project Inspector). Again. compiling after each deletion will tell you whether the dependency was really needed.

HTH!

Thanks a lot guys
This helped me a lot... with maybe 1MB of my project...

Code: Text  [Select]
  1. To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units"

« Last Edit: February 27, 2020, 01:20:41 am by AsleyCruz »
AsleyCruz - Graphic and apps designer
-
http://www.asleycruz.com/