Classes not found when archiving SwiftUI app - ios

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.

Related

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 Scheme with multiple targets creates Generic Xcode Archive

Ok, I am almost certain that this thing worked before but I am stuck now...
I have a workspace with multiple targets which I want to archive and submit to appstore simultaneously.
I have created a new scheme, I have all targets selected in there for Archive and I try to execute Archive in order to make all targets to IPAs
I always end up getting an Xcode Generic Archive. The only case I am getting an IPA is to select Skip Install = YES for all targets but one each time, which I suppose it actually means to build just one target so there is no meaning to multi target scheme.
Any clues about that? I checked the size of this Generic Archive and it looks like all apps combined in one file.
Indeed Apple confirmed that this is "impossible because archiving step in a scheme is designed to produce only one archive" and they asked me to build every target separately. I wonder if I can archive every scheme in a workspace automatically from command line to produce the desired result.
In order to create an IPA file using Xcode, we can use commands too. One can follow these steps:
1. Navigate to the App folder in Terminal
2. Run Cordova build command using "cordova build iOS" command
3. Open your iOS Project in Xcode.
4. Choose Product -> Clean. Then Archive.
More detailed screenshots are available here.

xcode 5 archive build fail, but normal build successfully

I can build and run my app on my device, but when I tried to build archive, I got many errors. The errors are about my 3rd library - google protobuf. It showed that #error Host architecture was not detected as supported by protobuf. But what is the difference between archieve and normal build?? After all, I built successfully and ran my app on the device when I choose product=>run (cmd+R).
When you build to run, Xcode usually builds for the active architecture only. When you archive it builds all the architectures specified by the intersection of the Build Settings "Architectures and Valid Architectures".
So it's likely that Xcode is trying to build for some architecture that isn't supported by your protobuf library, e.g. Arm64.
For me the problem was that the scheme for "Archive" was different than the scheme for "Run". When i switched "Archive" to use DEBUG instead of RELEASE it worked.
You can see reasons for failure in Report Navigator present in Navigator window.
Menu -> View -> Navigator -> Hide/Show Navigator
Extra icon will appear/disappear next to Breakpoint icon after Hide/Show Navigator
Open Report Navigator by pressing last button present on list of buttons in Navigator window.
Here you can view reasons either By Group or By Time.

Why are static library symbols not included in dSYM during archive?

We have a pretty major application suite for a client with a couple application targets utilizing several static libraries that we made in house. All targets are contained in one XCode project file.
For some reason when archiving an application the dSYM file does not contain any debug symbols for static libraries. The result is when trying to symbolicate crash logs from field agents we cannot see what is going on inside those static libraries.
I attempted to create a new simple XCode project with one application target and one static library. Even then the debug symbols were missing. I fiddled with the build settings according to this https://github.com/TheRealKerni/QuincyKit/issues/91 without luck.
If I build FOR archiving the debug symbols are included. I ran dwarfdump on the resulting dSYM file and was able to see the symbols for the static libraries implementation files. However when I then attempt to archive the project the symbols are excluded.
Am I missing something? XCode version 4.4.1
I m using XCode 5.1.1 and was having the same problem.
The fix was to set "Strip Linked Product" setting under "Deployment" section to "No" for each dependent library project. For more detail, please see my post at
can i debug ios app installed from ipa archive
This appears to be fixed in a later version of XCode, currently using 4.6 and the problem went away.
If you are stuck using an older version then do the following:
Product > Build For > Archiving
Product > Archive
Open the built product from derived data, you can do this by right clicking on the Youapp.app file in Products group and selecting show in finder. Ensure you are in the Release-xxx folder. Copy the dSYM file generated there and replace the one produced by the archive process. To find where archived files are go to Organizer, Archives tab, right click on an item and show in finder.
Hope this helps.
By default, archive uses release build, which already stripe debug symbols. you can change archive build option to 'not stripe'.

Xcode can build a project but can't run it on simulator

When I download a project from the web, sometimes it can be built but doesn't run (XCode -> Product -> Run is disabled, in grey). This never happens when I create projects myself. What could be the problem? Is it somehow connected with version?
I'm new to iOS development and download projects from the web for studying purposes. It's a pity not to be able to test them on the simulator.
Generally, if you can't Run a project, either:
It doesn't have a build scheme that knows how to "run". Check at the top next to the Run/Stop buttons that there's a profile name and target device shown. If the box says No Scheme then click on it and create a New Scheme. If there IS a scheme, click on the drop-down menu (left divider in Xcode 4.2+, anywhere on the box otherwise) and go to Edit Scheme to make sure the scheme was set up correctly for Running
It doesn't have a build configuration set. You should see this in the Run section of your build scheme. Check there's one selected. If the list is empty, go to the Project icon at the top of the leftmost pane, select the Project, go into the Info section, and create a build configuration, although there should already be at least one if you can build the project
It doesn't have a runnable target at all, which might mean you've got a project which compiles to a static library or framework for use in OTHER projects. If this is the case, you should see the icon for your build Target as a yellow toolbox (framework), or a little white building (a "library", although to me it looks more like the United States Supreme Court Building).
The target isn't valid for the Simulator, which means you might need to add i386 to the list of Architectures and Valid Architectures on the Target before you can run it
The target isn't valid for the currently connected device. For this one, check the Deployment Target number is set back enough to be valid for the device's version of iOS
Xcode can't see the connected device. Try unplugging and plugging it back in. If it still doesn't recognize it, you may have not added it to Xcode (Window -> Devices -> Select the device -> Use for Development)
Make sure that in your Edit Scheme (click on your project name next to stop button -> Edit Scheme), in the Info tab of the Run menu selection, that your .app is selected as the Executable. I had this issue and "None" was selected, happened after refactoring the project's name and reconfiguring the build targets.
you may download a project that the deployment setting (the ios version) is higher than the one your xcode support. if this is your situation, you has two options to sovle the problem.
try run the project in a older deployment option. follow these instructions (
if the project just setting to a higher version but not using any feature of the higher version. this approach should work):
select project file in xcode > select the target you are going to run > select summary tab > in section 'iOS Application Target' > in the combo box about 'Deployment Target' select the version that your Xcode support.
and then you could select and run the project in the simulator.
if the project dose use features in the higher version, then you should update your Xcode in order to run the project.
Hope this helps!
In my case the issue was really simple, I needed to check "Launch: Automatically" check in "Product > Scheme > Edit scheme > Run" menu.
When this setting wasn't checked I cannot find App icon in simulator to launch application.
In My Case Sole by Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...
same as
Go->Target->Architectures->Architecture=select standard architectures(armv7,arm64)...

Resources