Xcode 5 cannot run using selected device on iOS si

2019-06-14 04:18发布

So this seems to be quite a common question but all the answers I found were related to getting "xcode cannot run using selected device" when trying to run it on a connected device. My issue is getting this error just trying to run it in the iOS simulator.

Some background is that app was running in simulator fine, and then I changed the Project Name, the Target name and the Scheme name and that is when the problems started to occur.

I tried many of the different solutions in some of the other threads such as: Clean, Delete Derived Data, restart Xcode, restart computer, make sure using Default LLVM, remove Info.plist then re-add it into project again. None of them worked.

I finally discovered the problem and was able to get it working and will post my solution below.

2条回答
不美不萌又怎样
2楼-- · 2019-06-14 05:01

I ran into this and had to change the deployment target (iOS version) in the general tab of the project options menu. Apparently xcode had been updated to support iOS 8.2, but my simulator had not, therefore nothing appropriate was showing up in the list of simulator targets. Changing the deployment target to 8.1 fixed the issue. I'm sure that keeping my Mac up to date would also help.

查看更多
Juvenile、少年°
3楼-- · 2019-06-14 05:11

What I discovered to be the problem, was that in the Info.plist file the Executable File (CFBundleExecutable) was hard coded as "MyAppName". When I changed the Project name and Target name and Scheme name, this hardcoded value was not changed, but still had the original app name in it.

So I changed Executable File (CFBundleExecutable) in the Info.plist file to be this constant:

    ${EXECUTABLE_NAME}

And the problem was solved :)

EDIT:

I had the problem occur again on a different project, however the above was already set to ${EXECUTABLE_NAME}.

So I went searching and found that under Build Settings > Build Options > Compiler for C/C++/Objective-C was set to UNSUPPORTED.

I changed this setting to DEFAULT and the problem was solved :)

EDIT:

I had the problem occur again and the above two things did not fix it.

So I went and made sure that the info.plist was removed (unticked) from any Target Membership, and this solved the problem. It seems that there are multiple things that will cause this issue, so try all the solutions!

查看更多
登录 后发表回答