Massive difference in time taken to scan contacts/perform action in Xcode versus TestFlight

I'm looking at some inefficient code that somebody wrote that repeatedly searches contacts within a loop, and that loop can execute hundreds or thousands of times.

If I run the app via Xcode then its taking 20-30 seconds to execute, but if the app is downloaded from Testflight and run, the same code runs in less than a second.

I'm presuming this difference is due to the scheme being debug for Xcode run but release for the archive scheme?

Can the debug scheme really have such an enormous impact?

Replies

You could try updating the optimization to match the release settings. I have a media player program using a fairly large core data database and they made a large difference.

  • @jlilest could you describe further what you mean?

  • See reply below...

Add a Comment

Click on the project in the project navigator. Click on the target. Click on build settings. Be sure the all tab is selected, just above build options next to the + button Selecting combined next to that makes it easier to compare. In the filter on the right, type "optimization level" without the quotes.

Under Apple Clang and Swift compiler there will be drop downs to select the optimization level.

For debug configuration the defaults will be none. Release ones "fastest, smallest" and "optimize for speed" respectively.

Be aware that setting debug to other than none may impact breakpoint behavior as well as the ability to read variables due to code optimization.