1

I need to restart my iOS app after changing language direction. This is not possible in pure Swift/ObjC, but using a script (usage of scripts from iOS app is allowed) I think we can do something like this answer for Windows.

Until now, as far as I know, no one could restart an iOS app programmatically. How would you do it?

Need to do it on real iOS devices without being connected to a Mac/Xcode.

Community
  • 1
  • 1
Amr Lotfy
  • 2,937
  • 5
  • 36
  • 56
  • `I need to restart my iOS app` I have doubts about this, really. I'm pretty sure you can do what you actually want to do without wanting to restart the app. What is the real goal here? Refresh some DB? Something else? – Eric Aya May 04 '17 at 11:53
  • Switching app locale to from LTR to RTL @EricAya – Amr Lotfy May 04 '17 at 12:01
  • https://developer.apple.com/library/content/qa/qa1561/_index.html – jscs May 04 '17 at 12:26

1 Answers1

0

The response assumes the application is provided by you and the phone is attached to a Mac that is able to build and run the application on your iPhone/Simulator

Simulator

The "xcrun simctl" command is a great terminal command, introduced with Xcode6

I hope I did not get you wrong. Basically, you can launch your app on the simulator from outside of Xcode.

You should at first get the list fo devices

xcrun simctl list

Then boot your simulator (if its not booted yet)

xcrun simctl boot <deviceudid>

And finally launch your app

xcrun simctl launch booted <com.yourcompany.yourapp>

Real Device

If you want to build and run an application on a real device, you could make use of the terminal command "xcodebuild".

1) Build the app Here is an introduction of how to build the app: https://developer.apple.com/library/content/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-HOW_DO_I_BUILD_MY_PROJECTS_FROM_THE_COMMAND_LINE_

2) You can at least RUN unit test / ui tests https://developer.apple.com/library/content/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-HOW_DO_I_RUN_UNIT_TESTS_IN_OS_X_AND_IOS_FROM_THE_COMMAND_LINE_ If you just want your App to start, I am not quite sure whether it would help you.

A possible attempt would be to start the unit tests and immediately kill the "unit test process" on your Mac. This way the app will not be closed, when the unit tests have finished. Its just an attempt, I haven't tried it.

Lepidopteron
  • 6,056
  • 5
  • 41
  • 53
  • Sorry if I was not clear, I need to do this on real iOS device. – Amr Lotfy May 04 '17 at 12:53
  • I updated the answer, on a real device I think it is a bit tricky. Could you update your question to take care of this requirement? – Lepidopteron May 04 '17 at 13:01
  • I updated question, We shouldn't assume that device is connected to a mac/Xcode. – Amr Lotfy May 04 '17 at 13:30
  • Another way won't work, as even over the air debugging is not possible anymore. You will have to jailbreak your iPhones and write custom scripts for these to start their local apps. – Lepidopteron May 04 '17 at 13:32