Xcode: error: failed to launch with duplicated target. Original target runs fine in Xcode/gdb - ios

I have an app that I want to be able to build two different versions. One a "test" version that hits test databases, populates a test analytics backend, etc, and then the "live" version which its the production database and analytics backend.
So I duplicated my target, made appropriate changes, and I can build both, and both get installed on the phone, and I can run both manually on the phone. However, when I try to run it in Xcode on the device in order to debug with gdb or lldb (same error happens with both), the original target runs fine. However, the duplicated target (the "test" one) gives an error when running on the device (both run fine in the simulator, the problem is only running on the device)
lldb gives: [APPNAME] is the overall app name -- the test version has product set to [APPNAME]Test
error: failed to launch '/Users/chad/Library/Developer/Xcode/DerivedData/[PROJNAME]-ezbuaazlwmgdwydjykcufhicaspu/Build/Products/Debug-iphoneos/[APPNAME]Test.app/[APPNAME]Test'
gdb basically gives a dialog box that says that the same path cannot be found.
However, that path actually DOES exist. If I cut and past the path from the Xcode debugger window and go to Terminal and type % ls -a '/Users/chad/Library/Developer/Xcode/DerivedData/[PROJNAME]-ezbuaazlwmgdwydjykcufhicaspu/Build/Products/Debug-iphoneos/[APPNAME]Test.app/[APPNAME]Test'
it finds it just fine. I can also click in Xcode in the file list under the Products folder and click on [APPNAME]Test.app and choose in the contextual menu to "Show in Finder" and it finds it just fine.
AND the app does get copied to the phone and it shows up in the organizer and I can manually launch the app and it runs on the device. It just won't auto launch in Xcode on the device for the copied target, while the original target runs just fine in Xcode.
I'd appreciate any insight into this. This is my first real time playing with multiple targets on an iPhone project I created (versus working on a team on a project someone else created). Thanks.

Wouldn't you know. Xcode crashed (for some totally other reason when I was doing something different unrelated to this) and now both targets will launch and run from Xcode. So I guess the solution is to quit Xcode after duplicating a target if you have problems with the target launching from Xcode.

Related

Migrating SceneKit app from xc10 > xc11, I encounter "xcrun: error: unable to find utility "scntool", not a developer tool or in PATH"

Due to character limits in the title, allow me to elaborate on what is happening.
I have an application that builds with no warnings & errors while using Xcode 10.2.1, but I would like to test it in the latest Xcode 11 beta.
However, it produces an error during the build process, yet oddly enough, the app properly launches and is usable on a simulator.
The error:
xcrun: error: unable to find utility "scntool", not a developer tool
or in PATH
Initially, I thought it was possible that the spaces in my app's name were a problem, so I quickly renamed it to use _ in place of the spaces, but that did not work.
Rebuilding the app after I removed the spaces also shows the following warning:
copySceneKitAssets: warning: Failed to copy SceneKit assests because
scntool failed to process the following resources:
/Users/someidiot/Library/Developer/Xcode/DerivedData/Build/MyAmazingApp/Products/Debug-iphonesimulator/My_Amazing_App.app/art.scnassets/Game.scn
And yes, the file is there:
Out of curiosity, I purged my derived data in case something was causing problems there.
rm -rf ~/Library/Developer/Xcode/DerivedData
However, the same scenario as before... warnings & errors upon building, but the app successfully launches on the simulator.
My concern here is that if something is genuinely wrong, I'd like to fix it before it becomes an issue, but at the same time, the app does launch successfully.
Unfortunately, I do not have access to an iOS 13 device at this time to test on hardware.
After any new Xcode installation, or even when switching between versions of Xcode, always go into Xcode's Preferences and, under Locations, adjust the Command Line Tools pop-up menu to point to the version of Xcode you are using.
Otherwise, something like xcrun, which means "run a tool inside Xcode", will be looking in the wrong Xcode.

Is it possible to run an app on two devices with one click on the build and run button in Xcode 5?

Is it possible to run an app on two devices with one click on the build and run button?
E.g. I have an application that has to run on two devices to test some networking functions between the devices.
It is really annoying to select each device separately from the scheme selector and then click the "build and run"-button.
So I'd like to configure my build process to let the app automatically build and run on both devices. Is this possible? And if it is, how?
Versions: Xcode5, OSX Mavericks
I found this Question but it doesn't seem to work anymore since I get the the following error message when I open the .app file:
You can’t open the application “Run” because the Classic environment is no longer supported.
Furthermore I can't select the .app file for the launch application service in the automator.
I don't know if it's possible, but perhaps to speed it up, a quick keyboard shortcut:
Switch build target HOLD: cmd + opt + ctrl THEN PRESS [ or ] -- switches target
Then, build it with cmd + r
Not exactly what you're looking for, but should cut your time fairly significantly!
Choose your Device at the top, build and run (Cmnd+R) and while running it, select a different device without stopping the other device, then build and run it again (Cmnd+R) on that device.
It definitely works with a real device and a simulator, but I don't know about 2 real devices.
Goodluck! :)

The Record Button is not Enabled With iOS Simulator

I've installed Monkeytalk on my machine, it has OS X 10.8.5
I had a successfully run an automatized test on Android with Monkeytalk, so I moved on X Code 5.0.2. Created a sample application (iOS 7.0), added the required targets, changed the Schema name too. Also added into Buid Phases the required libraries, mentioned here, as well as the Build Settings' Other Linker Flag option (-all_load). Now, I can successfully build the app to the new Monkey target, appears on the simulator correctly. But after selecting the iOS Simulator in the Monkeytalk IDE, however the console's output is "Connected to Device: iOS Simulator", the record button is not enabled.
I've watched the tutorial video about running Monkeytalk on iOS simulator too, the linker flag mentioned there is -all_load lstdc++ if I understood correctly (the quality of the video wasn't the best and I could not read the line). Did you ever get this problem?
Edit: I've tried to run via networked device, the Monkeytalk is successfully connected to the device, but the record button is still not enabled.
Did you get message in XCode's log output like the last photo of Installing the MonkeyTalk iOS Agent?(Sorry, I don't get the permission to attach images here yet)
If not, make sure you added all the required libraries into Buid Phases and run in CORRECT target first(I met this problem once because of this :<). Then you can check the log output and google these messages for help.

Xcode-Instruments cannot run app on simulator with the app target I choose

I am trying to run an automation on an iOS App using UIAutomation with Instruments.
It had worked well when I had tried it out a few weeks back. However, I tried out another automation testing framework (KIF from Square) in the meantime, and now when I try and run Automation with Instruments, it refuses to work.
When it had worked, I had carried out the following steps:
Open my app in Xcode
Run the app
Quit the iOS simulator
Open Instruments (not necessarily through Xcode, but just by searching for Instruments in Spotlight), choose Automation
Instruments opens, and when I click on Choose target, I do not need to browse for the target. I can see the name of my app in the list (description: the app name is without the .app extension and has an icon before the name like the icon which appears at the top of the output window in Xcode - a black and white icon with a gradient) even though I haven’t opened it before i.e even when I had opened Instruments for the first time.
I choose this target from the list, choose a javascript file for the automation to run, and then click ‘Record’. The automation used to run and I could see it run in the simulator which used to open up.
However, opening Instruments no longer shows me the target in the list of targets anymore.
I have tried choosing a target from my filesystem (from the Derived Data folder) as well as from the iPhone Simulator applications folder; but no luck. The target does not appear as it used to before (in the description above), but appears with a .app extension and with the typical application icon. The automation does start and open up the simulator, but gives the following message: (although the page or the script haven't changed at all)
Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().elements()[2]
(Would have liked to post images, but can't, since I am a new user and do not have the required permissions yet - hope the description makes up for it)
Have been stuck on this issue for long and any help would be appreciated! Thanks so much!
I just profiled the app using Product -> Profile in Xcode, and that opened up Instruments with the target. The target was the Unix executable under Derived Data -> MyApp -> Build Products -> Release-iphonesimulator -> MyApp.app -> MyApp unix executable.
Also, while using KIF, I had enabled accessibility labels for some views in the storyboard. While running the automation tests in Instruments, the app seemed to somehow consider the views which had the accessibility labels set as one single element and could not access sub-elements on this view. In order to run with Instruments, I just disabled the accessibility labels for the views and it worked like a charm again!

iPad2 device build does not update when I do a new build

I am having a consistent problem with multiple different apps that the build on the device does not update when I make code changes. Here's my set up:
OSX Lion
Xcode 4.1
iOS 4.3.5
I build, and then run, the app launches on the device but it still runs the last installed version. In order to get the build to update, I have to do the following...
Remove the app from the device (press and hold on the icon, and click the x)
Clean and then build in Xcode
At this point if I try and run the app does not run. Xcode log says the app has started and stopped. If I restart Xcode and run, then the app runs successfully and is the updated version
If I make a single line of code change I have to go through all the steps above to get the app to update. The project is very large so a clean build takes 2-3 minutes.
Any ideas?
Update
I found the solution, this is related to the use of static libraries. The following article helped me solve this:
Changing the source of a static library needs clean and build in xcode 4
and for general background this was very helpful too:
http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/
Double check your provisioning files and targets. Be extra sure to check the App ID in your targets, and Bundle ID in info.plist. Did you change any of that info before you saw this problem? I've noticed strange behavior like what you mentioned when updating those specific pieces of data.
Command+Shift+K -- Clean. I have found that you have to do a manual clean every time now to ensure that the build updates correctly.
In the event that xCode does not run at all, you just have to restart xCode.

Resources