Xcode running project on opening it

I started to have a strange problem in Xcode: there is a specific script in my app that whenever I open it in Xcode (double-click on it in the main project window), the entire app is run - and the version of the app is the one built BEFORE any code modification.

Also whenever I try to build the app (not build and run), at half of the building process the previous version of app will be run, and I have to quit it, then the build process continues to generate an updated version of the app.

Is this an Xcode bug or it’s related to the code itself? Anyone has the same problem?

Finally found the answer to this weird problem - turns out I had “tell application “MyApp”” line (assuming MyApp is the current app in development). AS needs to activate the app to check the command I send at compile time.

It’s my bad coding style anyway - removing the statement “fixed” the problem.