iOS - Application debugging on .ipa file - ios

Is there a way to debug a .ipa file after archiving?
I have a bug that I am running into when I archive to .ipa file that doesn't show up in xcode when I am running tests.
Thanks,

Presumably your testing is done with a Debug build, whereas your archive is a Release build? You can check this if you select 'Edit Scheme' from the schemes drop down in Xcode.
To test the archive build, you can change your "Run" setting to use a release build rather than debug - click on Run in the left hand panel from the Edit Scheme screen and then the Info tab and change the Build Configuration to Release.
Don't forget to turn it back to Debug once you have finished.
The thing is - it's pretty rare to find issues like this, could you perhaps explain more about what your problem actually is?

Related

Classes not found when archiving SwiftUI app

I have been working on a 100% SwiftUI app and am fairly into the project.
The project compiles and builds without issues when running on both simulator and device.
However if I try to compile the project I get a bunch of errors stating certain classes cannot be found across the project.
2 of these are CoreData auto generated classes.
1 is a global struct called Globals.swift
Has anyone else encountered this issue with Xcode 12.4?
You have probably changed some architecture settings
Try
Click target next to stop button
Select Edit Scheme
Select Run on the left
Select Info (top center)
Change Build Configuration from Debug to Release
Then build your project as you have been on a Device
If you get the same error you know something is going on between DEBUG and RELEASE builds.
Make a new project and compare the "Build Settings" of your current target and the "Build Settings" of you new empty project.
Pay attention to the ones that have DEBUG and RELEASE options such as
Architectures > Build Active Architectures Only
And anything else you might have changed because of a pod or other dependency.

Archived app wont appear on organizer after a few updates

I was compiling my app and archiving it correctly with no problem whatsoever. I added a charts library to the app, did some stuff with it, archived it fine but Apple didnt let me upload it because the library wasnt correctly referenced in the app.
So I fixed that problem and tried to archive it again, but it just wont appear on the organizer.
Skip install is set to NO
Archive in the scheme is checked
Reveal archive in organizer is also checked
How can I fix this?
Simply try this steps:
Reopen your project
Clean Xcode & Remove derived data
Change build number & version number
Make archive now
Note:
You are able make archive earlier, so it could work perfect after this steps. Unless you have changed any settings in Xcode.
Edit:
Go to targets - build settings & find "Installation Directory". Make sure there is "$(LOCAL_APPS_DIR)" added.
Go to Edit Scheme -> Build tab, Make sure you have archive check box selected. Check image below:
Go to Edit Scheme -> Archive tab & make sure the check box "Reveal in organizer selected"
See below image:
Hope it will help you.
I know this is an old item... However, I encountered the same issue today and tried all the above suggestions and still no luck.
Was able to work around it by using Finder and going to the build > iOS > archive folder of the application. Then right click on the .xcarchive file and open with Xcode.

Xcode project scheme is not currently configured for the test action

I am trying to run an Xcode unit test for my iOS application. I am willing to do it on an iPad connected via USB to a Mac. I am trying to run the test from the command line in order to trigger it from Jenkins later on.
Below is what I'm currently typing into the command line and the error I'm getting. Please help.
The code:
xcodebuild test -scheme MyApplication -destination "platform=iOS,name=iPad"
The error:
Scheme MyApplication is not currently configured for the test action
For me the problem was that no tests were added to my scheme:
By adding test bundles to my scheme via the '+' button then the scheme could be built by Xcode and xcodebuild.
For everyone struggling with this problem.
My solution was to:
Select Test Target
Manage Scheme
Select Run in the left menu
Select Info in the tab
Choose Executable Target from the dropdown menu
Hit Close.
Fixed this up by removing duplicate schemes from Xcode. The schemes can be added/removed/shared/edited in Xcode via Product -> Scheme -> Manage Schemes.
Please follow following steps to resolve this error.
Select your project scheme at the top.
Click on Manage Schemes.
Select your test target in the popup.
Make sure to click on Edit button at the bottom left of popup.
Select Build.
Click the checkbox below "Run"
Close the popup.
You should check your workspace data on Jenkins and see which *.xctest is already uploaded. Then you have to rename your UI/Unit test target to that *.xctest data in your xcode project like what you
have on Jenkins and then push again.
OR wipe out your workspace from Jenkins and push all data again with new UI/Unit test target again.
(Of course you have to ensure that you have already made a scheme for project.)
In my case I had no test file...
Here is a tutorial to perform UI Tests and create screenshots :
https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line
My problem was that the Tests.swift file was importing a module that no longer existed (I renamed the Targets for the project). Check to make sure all test files are importing currently existing modules.
I was getting this similar error, but none of the other solutions helped. Since the error was first noticed while running via Fastlane, I next ran xcodebuild manually using this command to mimic the same.
xcodebuild -workspace Noname.xcworkspace -scheme Noname -enableCodeCoverage YES build-for-testing
I then saw errors regarding: Signing for "Noname-Dependency" requires a development team.
I also so reference to a macosx signing error, which I cannot sadly reproduce having since fixed the issue.
To fix the issue, under Signing & Capabilities for the Target I selected None and then under General I unchecked Mac, as we are not needing/using that but it was selected by default when creating this new project (CocoaPod).
Oddly enough, I added back Mac and things still kept working. I think that there is a oddity with the Xcode project file and/or scheme file(s) such that when you tinker enough with it -- things get reset/fixed.
I had a test plan set up (xctestplan).
I needed a separate configuration for the tests (the test plan) in addition to "Shared Settings".
Please also make sure that the test plan (under Xcode scheme settings) includes a test target AND a configuration.
Screenshots attached:
In my case, it was failing intermittently with this error, turns out I had two schemes with the same name and Xcode sometimes picked the wrong one, so make sure you do xcodebuild -workspace "MyWorkspace.xcworkspace" -list to see all your schemes and find out if you have repeating names.
Your test plan should have at least one custom configuration.
Go to Manage Schemes.
Delete all schemes and click on Autocreate Schemes.

XCode won't run my application on a device/simulator anymore

I am kind of stuck with my XCode problem. First of all: I have a project that contains 5 different targets. Now something went wrong (I can't remember changing anything related to project settings).
If I want to run any target on device or simulator the build succeeds but then nothing happens. Neither the app is started in simulator nor on a device. So I checked the Scheme (-> "Edit scheme") and I could not select my app in the Executable menu. I think I can remember that the .app file was selected there before (as it is if i create any new project). Does anyone know why I can't select anything there?
What I am curious about, is the fact that choosing "Other" in the Executable menu brings me to my DerivedData directory that indeed contains the *.app file resulting from the build. That leads me to my next problem.
If I select this *.app file explicitly and try to run the app XCode gives me the error " does not have an architecture that can execute." But I checked my settings many times and I am definitly using $(ARCHS_STANDARD) in every target.
I am a little bit lost here ... does anyone has a hint, what could have messed up my project and how to fix it?
Might not work, but I've found a lot of bugs in xcode which simply require quitting it, and reopening.
You could also try clearing out the DerivedData directory. Do a full clean build (hold down option key when selecting clean build).
And lastly, reset the simulator via the menu iOS Simulator > Reset Content and Settings.
I got this when I changed the name of my App on one development machine and then tried to work on it a few months later on another machine. I fixed it by deleting the old scheme and Autocreating the new scheme. The settings are under Product - Scheme - Manage Schemes.
OK I solved the problem by myself. I was on the right track before. I did compare the project.pbxproj file again using FileMerge. I merged all lines related to an *.app file from the working version into my corrupt project file. After that my project was fixed. The *.app files showed up under the "Product" group in XCode and I could run the application on simulator/devices again. It seems that I forgot something while I was merging the files via copy & paste. ;)
Rather than cleaning out the DerivedData directory from Xcode, have you tried the "old fashioned" way from Finder? Try quitting Xcode, nuking ~/Library/Developer/Xcode/DerivedData/ModuleCache from Finder, and restarting Xcode.

Can I debug iOS app installed from IPA archive?

I m having some problem with my app which reproduces only when i install it ad hoc, but doesn't reproduce if i just run the app from Xcode. I would like to debug this problem, but so far i m not having any luck. I m using Xcode 5.1.1. Here is what i did:
1) Go to Product->Scheme->Edit Scheme->Archive and set build
configuration to Debug.
2) Code signing identity is set to iPhone Developer.
3) Generate Debug Symbols is set to Yes.
4) Go to Product->Archive and after it is archived, click
"Distribute", then choose "Save for Enterprise or Ad Hoc Deployment".
5) My development provisioning profile is selected.
6) Click "Export" and export the .ipa file.
7) Use iPhone configuration Utility to install the app onto the
device.
8) Run the app on the device.
9) In Xcode, go to Debug->Attach To Process->By PID or Name, enter the
app name. Xcode attaches successfully and says running the app on
iPad.
10) However, i cannot hit any breakpoints which should be hit when i
do certain actions in my app (if i install and run the app from Xcode
instead, all breakpoints are hit).
Am i missing something?
You don't have any debug information for the app at this point, and since most apps are pretty thoroughly stripped, there won't even be symbols for lldb to hook on to. So we're not going to be able to successfully set breakpoints.
When you built the app, Xcode produced a dSYM file (MyApp.app.dSYM) which has the debug info in it, so all is not lost. Problem is when you attach to some - to Xcode - random app on the device, Xcode has no way to know where to find its debug info.
You can add the debug info into your debug session in lldb by using the command:
(lldb) add-dsym <PathTo.dSYM>
You have to do this after you have attached.
lldb also uses SpotLight to find dSYM's so if you put the dSYM somewhere that SpotLight knows to search (like your Desktop or a folder under your User directory) then lldb should pick it up automatically.
You can tell whether lldb has successfully read in the dSYM by doing:
(lldb) image list <AppName>
If lldb found the dSYM, it will list the path to it on a separate line after listing the path to the AppName binary.
Jim Ingham, thanks for your answers.
I found the reason why i was unable to debug into static libraries. In each Xcode project, there is a setting called "Strip Linked Product" under "Deployment" section. In all my projects this setting was set to "Yes".
In order to debug into static libraries for an app built by archiving, i set this setting to "No" in each dependent library project (as well as the main project). This can also be set differently for Debug/Release modes. After this, i see the library symbols built during archiving and i m able to debug into library code. I hope this helps someone.
Unfortunately (or maybe fortunately) the bug i was trying to debug no longer reproduces when the library symbols are not stripped. Maybe something happens when the symbols are stripped, i will need to investigate further.
I was struggling with the same problem, and just launching my app from Xcode was not an option - I had to build the IPA, sideload it on an iOS device, and then debug. Eventually I was able to make that work with the following steps:
1) Set the scheme archive target to Debug
2) Change the following settings for the Debug builds
Keep Private External Symbols (KEEP_PRIVATE_EXTERNS) : YES
Enable Bitcode (ENABLE_BITCODE) : NO
Strip Linked Product (STRIP_INSTALLED_PRODUCT) : NO
3) Rebuild, archive, and deploy the resulting IPA file to your iOS device.
4) Launch the app, and in Xcode, select Debug/Attach to Process/YourAppName(id)
5) Break into the debugger - you should be able to see the code, put and use breakpoints, etc.
If you want to debug your code from the very beginning, just put a loop that sleeps for a second or two and then checks a flag at the top of your main function - when you break into the debugger, just change the flag to let it escape the loop.

Resources