The short answer is: of course GDP can grow without foreign investment.
A main driver of GDP growth is an increase in productivity in other words: more output from the set of inputs. The essential inputs are resources (people and materials) and the efficient application of resources (knowledge). Often the inputs are said to be labor and capital but notice that labor is already represented in my definition of resources. Notice capital is already represented in my definition of resources when you observe that capital is materials and the things knowledgeable people create.
The other main driver of GDP growth is workforce growth or in the short term actual employment growth. The factors in this are the birth rate and net immigration and longevity and health and what factors make people want to immigrate or emigrate.
It doesn't matter whether the investment (usually financial capital and knowledge) is domestic or foreign it can still be incremental to GDP. You mentioned developing countries. Welcoming foreign investment is partly a matter of ambition and impatience. Discouraging foreign investment might be a sign of complacency: the elites might be comfortable enough. Another reason to discourage foreign investment might arise from the domestic assets being unique or irreplaceable or having unknowable value. Often both kinds of countries whether developing or already highly developed will balance the benefits of inward investment against their concern about loss of control in companies or industries and perhaps loss of influence. Ceding control and influence to foreigners might be essential to attracting investment and it may also be essential to the success of the investment after it is made.
Foreign investor control and influence is of course tempered because the domestic government will still have control over the legislature, courts, tax collector, police, and military.
It makes sense for a developing country to attract foreign investment if that developing country is poor, the locals may not have amassed the capital to invest in all of the opportunities that exist. The locals will eventually amass capital but when will they. This is why ambition and impatience matter. It matters whether a developing country government will be ambitious and impatient on behalf of all of its people when the elites might be more complacent.