Error generating .ipa: "remove ... directory not empty" - xcode

I'm trying to generate an .ipa file from xcode, version 10.
Certainly I am using the option "Archive" under "Product" menu option, towards a Generic iOS Device.
The problem comes when it starts building it. The following error appears:
I have tried cleaning the build folder, removing the folder mentioned in the error (it gets regenerated after I press Archive), I also tried deleting DerivedData folder, changing it's destination...
What am I doing wrong? How would I go to generate an .ipa file?
I have read a lot of questions here in SO about this but none of them worked for me.
Thank you.

I ended up being able to generate the .ipa with the legacy build system.

Related

SceneKit: imported dae file not copied to app bundle

Got a weird scenekit asset problem... I’ve got an assets file (catalog.scnassets) that seems to be fine in Xcode. I’ve added to it a dae file which also opens fine in Xcode.
However, the file doesn’t seem to get copied into the app bundle when I build (mac app), even though the build logs show it happening:
copySceneKitAssets: Copy plants.dae
copySceneKitAssets: Running scntool on /Users/jason/Library/Developer/Xcode/DerivedData/FirstPersonGame-fxynipfnexmczbgnujwuiqxtiogd/Build/Products/Debug/FirstPersonGame.app/Contents/Resources/catalog.scnassets/plants.dae
When I check that directory in the build folder, catalog.scnassets is there, but it’s empty. Any ideas what might be going on?
Here’s what the file looks like in Xcode’s Identity inspector:
It’s simple!
I was seeing a bunch of warnings like:
scntool: warning: Could not load ModelIO.framework ((null)) (etc)
which led me to this StackOverflow post which solved it for me.
In short: check in Xcode Preferences -> Locations. For me, the “Command Line Tools” had nothing selected (somehow!), so selecting a value there (in my case, Xcode 10.1), then doing a clean build, fixed the issue.
Had the same issue on Xcode 11.3.1 but command line tools are set. Had to uncheck "prefer compressed textures" to make Xcode import the file. This will also make a json file to show up!?

Problems after upgrading to Xcode 10: Build input file cannot be found

I upgraded my Xcode SDK to version 10 last night and then find I cannot build.
I'm getting this error:
Build input file cannot be found:
'/Users/call01/Library/Developer/Xcode/DerivedData/Comp-Lite-Apps-gytvmossqptokeafrddvvmnlzadk/Build/Products/Debug-iphoneos/SG11.app/SG11
which did not exist before my upgrade and I'm tempted to revert back but would like to stick with version 10 if I can resolve this issue.
Try to switch back to the Legacy Build System (File > Project Settings > Workspace Settings > Legacy Build System)
For Swift files or files that belong to the project such as:
Build input file cannot be found: PATH/TO/FILE/FILE.swift
This issue can happen when files or folders have been removed or moved in the project.
To fix it:
Go in the project-navigator, select your project
Select Build Phasestab
In Compile Sources section, check for the file(s) that Xcode is complaining of
Notice that the file(s) have the wrong path, and delete them by clicking on the minus icon
Re-add the file(s) by clicking the plus icon and search in the project.
Product > Clean Build Folder
Build
You generally find these missing files in the Recovered References folder of Xcode in the project tree (look for the search bar at the bottom-left of Xcode and search for your complaining file):
Deleting them from this folder can also solve the error.
For me In Xcode 10, this solution worked like a charm. Just go to the Recovered References folder and remove all files in red color and add it again with proper reference.
If Recovered References folder was not found: Check for all missing files in the project (files in red colour) and try to add files references again.
Just check the path to .plist file in Build Settings of your target
Funnily, closing Xcode and reopening it might also be enough.
This worked for me in Xcode 10:
Click Project icon/name in your Xcode project
Go to General tab
Click [Choose info.plist File] under Identity section
Select the info.Plist file
Check Info tab to see if info.plist was loaded successfully
Build and run
This is an architecture problem. Do not change to legacy build system!
I got the same error, but what solved it for me was this:
The top says architectures in VALID_ARCHS are also excluded in EXCLUDED ARCHS. I was messing around with them to get a Swift Package to compile in Xcode 12, and have spent hours on this.
It would compile on the simulator and not on a device.
The Solution:
Go to Build Settings
Ensure "Architectures" contains 1 entry : $(ARCHS_STANDARD)
Ensure there is nothing in "Excluded Architectures"
Now scroll right to the bottom of Build Settings.
Make sure the VALID_ARCHS is exactly the same as this screenshot.
The arm stuff is $(ARCHS_STANDARD) again.
If VALID_ARCHS doesn't exist, add it with the + button.
Clean (cmd-shift-K)
Your project should now build perfect on both the simulator and device!
If it doesn't work, you need to make sure all these settings are the same both in your target build settings and the project build settings.
Note, if you have a Mac with Apple silicon, you may not need to do any of this.
The above solution eventually works for me; however, I need to do some more extra steps to finally make it to compile successfully. (These extra steps were required even on Xcode 9.)
Xcode: File -> Workspace Settings -> Build System: Legacy Build System
Xcode: Product -> Clean
Rotate to compile thru different emulator types, such as "iPhone 8", "iPhone 8 Plus", etc. (They might fail or might not.)
Eventually compile on "Generic iOS Device"
I fixed this issue this way: go to your project's Build Phases (click on project icon at the top, and then click on Build Phases). Search for your file there. If it's there (it'll be grayed out), delete it. Then clean (shift + alt + command + k), and run! Hope it helps.
If the error says it can't find Info.plist and it's looking in the wrong path, do the following:
Select your project from the navigator, then select your target
Select "Build Settings" and search "plist"
There should be an option called Info.plist File. Change the location to the correct one.
None of the above worked for me, but this did:
Open project in Finder, right click on your .xcodeproj file and show package contents
Open project.pbxproj in a text editor
Find the reference to your missing file
Edit path = "path/to/file.swift" to the actual location on disk and save the file.
Rebuild the project
In my case I had a build script that generated the .app binary (Buck).
The Buck build script ran in parallel with Swift Embed build step. Because the .app binary was not generated yet the Swift step would fail.
In my build script I added "$BUILD_PRODUCTS_DIR/$EXECUTABLE_PATH" under "Output Files".
This tells Xcode's New Build System that this script will output the app Binary and in turn Xcode will make sure to synchronize any build steps that depend on this artifact.
I ran into this error after renaming a file. Somehow Xcode didn't correctly rename the actual file on disk.
So it wasn't able to find the file. Sometimes the files gets highlights with a red text color. At other times the Swift icon in front of the file was getting a gray overlay.
The fix was simple.
Look into the error and see exactly which file it's unable to find.
Select the file that can't be found.
Go to the 'File Inspector'. It's on Xcode's right navigation pane.
Click on the folder icon.
Select the correct file.
Clean build and run it again.
Open the right navigation pane where your project files exist
OR JUST click on cmd + 1. Then search for "Recovered References" folder. Open it and delete all red files, then everything will work so fine.
I had this happen for building my unit tests. This may have happened because I deleted the example tests.
I removed the Unit test bundle then re-added it as shown in the pictures below and all was well again.
I had a similar issue after upgrading to a new swift version recently.
Moving files around caused my xcode project to reference items that were no longer in the project directory giving me the Error Code Build Input File Not Found.
In my situation I somehow had multiple files/images that were being referenced as described below:
In the image above.
Navigate to your Targets page.
Then Click on the Build Phases tab on the top.
Scroll Down to Copy Bundle Resources
Find the affected files and remove them. (hit delete on them or select them and hit the minus button )
It was in here that I somehow had multiple files and images that were being referenced from other folders and the build would fail as they could no longer find them. And I could not find them either! or how Xcode was still referencing them
I hope this helps someone else !
This worked for me
try deleting the red colored files
delete the files in derived data
clean the build folder
then try building by using "new build system" from file->workspace settings
I had the same issue. The problem was that I didn't have any file under the Target > Build Phases > Compile Sources. The problem was solved after I added at leas one file to Compile Sources.
Not that I did anything wrong, but I ran into this issue for a completely different reason and kinda know what caused this.
I previously used finder and dragged a file into my project's directory/folder. I didn't drag into Xcode. To make Xcode include that file into the project, I had to drag it into Xcode myself later again.
But when I switched to a new branch which didn't have that file (nor it needed to), Xcode was giving me this error:
Build input file cannot be found:
'/Users/honey/Documents/xp/xpios/powerup/Models
Extensions/CGSize+Extension.swift'
I did clean build folder and delete my derived data, but it didn't work until I restarted my Xcode.
In my case, the file (and the directory) that XCode was mentioning was incorrect, and the issue started occurring after a Git merge with a relatively huge branch. To fix the same, I did the following steps:
Searched for the file in the directory system of XCode.
Found the errored file highlighted in red (i.e, it was missing).
Right clicked on the file and removed the file.
I tried building my code again, and voila, it was successful.
I hope these steps help someone out.
What Xcode was complaining about was a XIB file I got it working by going to Project -> Build Phases -> Copy Bundle Resources, removing the "problematic" XIB, cleaning (CMD+Shift+K), building and adding it back again.
There is also one possibility that sometimes when you move your files to different folder and especially when you move your info.plist to other folder, you need to define the location of that file. To solve this problem, simply click on your project blue icon on the top, and you will see a button in place of project name and bundle id, click on it and locate the info.plist file there, clean and compile happily.
I ran into this problem soon after upgrading to Xcode 10, but that was not the issue.
I tried changing the build system, but that gave me a separate error that meant the same thing. Generally saying "File X can not be found".
There are multiple things to check when a file can not be found.
Recovered references Folder
Apple does this nice thing where if it detects a reference to a file that doesn't exists it will add this reference into a group called "Recovered References"
That is nice of Apple but it doesn't always work.
Build Phases Compile Sources
In this list, there could be meta data for a file that the project is suppose to compile, but the file does not actually exists and it's attempting to find the file at the given path. In this list it will be dimmed out, delete them and re-add them by toggling the file's target dependencies or manually removing it and dragging it in.
File's Path
Double check the file path that the error is printing out and the file path for the file in finder. You can easily see this by clicking on the file in Xcode and checking the "Show the file inspector" tab (the left most tab). If these paths are correct then you are good!
Dimmed out files in your project that are not in recovered references or red
This one pissed me off because it's not obvious about what happened, but basically if you go into finder and move a file to a different location with out updating the reference in the project it will throw the error as the file no longer exists there. The only indication I have found for that is that the file in the "Project Navigator" tab (left most tab) is very slightly dimmed, but when you go to delete this file Xcode doesn't prompt you to delete the reference or send to trash. You can fix this by deleting the file and re-adding it to the project or going to the "File Inspector" tab and click the folder icon next to the path and change it to the proper location.
Either way, the error indicates that it can't find a file, switching to the old build system is a bandaid for a more concrete issue. We as developers understand that a compiler just wants an artifact to be listed at the end of a file path. Somewhere the path is not correct! We have to find where that is!
My issue was resolved with item 4 listed above. Hope this helps somebody.
In my case I accidentally deleted one third-party xcodeproj folder I used in my app.
If you tried profiling, and then it didn't work, and now you cannot build, go into your Target pane (via the Project Icon), Switch to the Build Settings tab, search for PROFILE - and set CLANG_USE_OPTIMIZATION_PROFILE to "No".
In my case, I had created a new test target and deleted the default swift file so it was left with just the info.plist. Adding a new file fixed this.
The "Legacy Build System" solution didn't work for me. What worked it was:
Clean project and remove "DerivedData".
Remove input files not found from project (only references, don't delete files).
Build (=> will generate errors related to missing files).
Add files again to project.
Build (=> should SUCCEED).
I know that this is an old subject, but I found the issue with xcode 12.3 and was related to an error while doing the CopyPlist of the main.Storyboard during compilation.
Actually, changing the build settings to "Legacy Build Setting" worked, but it is deprecated, so I discarded it because is a short term solution.
Check this:
With that setting, worked for me. Before I had "Copy plist".
After struggling with this issue for about 45mins, here is a super easy solution that worked for me.
On the project explorer, click on the file/folder that is in red colour (means project is not able to locate the file)
Look at the details tab in the file inspector (generally to the right of the screen - see the attached screenshot)
Click on the folder icon and locate the real file/folder in your local machine.
That is it. This should do the trick. Basically help your xcode locate the directories and update the reference cache.
Random, for Cocoapods: I hadn't added my test target to my Podfile.

XCode, Swift (Domain = NSPOSIXErrorDomain, Code = 22)

My friend came to me with a small request of creating a video portfolio app. I thought it was a good excuse to try out Swift, which is what I did. (The app is not intended for release on the app store, only to distribute via Testflight)
I've run into some trouble where I'm getting the following error when trying to run my project:
An error was encountered while running (Domain = NSPOSIXErrorDomain, Code = 22)
The error appeared after adding a directory with .mp4 video files to my project in my "Bundle Resources". It concerns 6 .mp4 files at around 1.2gb in total.
As I couldn't figure out why the error happened in the first place, I decided to re-do my entire project (copying over bits and pieces). The project ran just until the part where I added the folder containing the videos.
I've tried removing both the reference and the folder, but the error consist. I really want to get to the bottom of this, so that I instead of having to create a new project, I can just remove whatever files are creating the problem.
Thanks in advance.
In my case, I had created the directory "Resources" absentmindedly and added it as a reference to my project. Renaming this folder, cleaning the project, and deleting the derived data (~/Library/Developer/Xcode/DerivedData/) fixed it for me.
Check infoplist file under TARGETS -> General - > Identity.
Please add the new infoplist file if missing in project folder. For new info plist values you can create new dummy project and copy, rename the infoplist file from there.
Maybe the files with the extension ".m" are not in "Compile Sources".
Click in the Target > Build Phrases > Compile Source and look if "main.m" and others ".m" files are added here.
in my case, i missed the bundle ID. check if you have filled the bundle ID field in your project.
(In my case ,it is becasue cloud_firestore)
Did you import cloud_firestore?
if yes ,please Try low version

Multiple errors ocurred while copying files - but, can I see what they are?

There were around 200 files I had to delete in my Xcode project (and yeah, they were deleted properly), and now I have to copy 200+ files are supposedly replace the ones I just deleted.
I keep getting "Multiple errors occurred while copying files". The Xcode window doesn't show the newly-added files, but if I explore the project folder using the Finder, I can see that the files were indeed added - well, there most likely was a certain file that could not be copied and thus caused the error. Problem is, I have no idea which one nor why.
Now then, is it possible to get Xcode to tell me what the problem is rather than telling me there is one?
Edit: Okay, I did discover that some of the new files shared the same name as some files that were not listed in Xcode, which explains the error. However, I am still interested in knowing whether there is a way to know that the "Multiple errors" actually are whenever Xcode says t his.
When Xcode finds a duplicate file, it generates this error, and then it fails to add references for the files that it did manage to copy.
Rather than deleting files from the finder and starting over, you can do this:
Open the Finder for your project, where your source files are located
Command-click the ones for which your references are missing (and if you click others, it won't really matter)
Drag them into Xcode. When the confirmation dialog comes up, unset the "Copy items into destination group's folder (if needed)" checkbox. This will tell Xcode to make references only.
I deleted the files from finder and then added again the files via Xcode, that worked for me.
This error sometimes occurs when the code is not merged properly. The missing files will not be available in Xcode but once you open the finder containing this project, you will be able to spot the missing file.
The simplest way to add these missing files back to the project is:
1) In your Xcode, navigate to Build Phases Tab.
2) Under Compile Sources, tap on '+' to add back the missing file.
Sometimes the missing files will be greyed out in the build phases, just tap on '-' and add them back.
For me this is worked. I tried to add files which are already in my bundle. So make sure you are not adding files which are already added. I hope it helps someone.

Xcode - File not found but build successful

In my project, I've include a full "shared" folder by link (not copy) that is outside my project folder.
In the .pch file, I have #import "MyStandardHeader.h"
My Build settings does not have any search path to the "shared" folder.
In the "MyStandardHeader.h", I have #import "NSMutableArrayCustom.h" that is inside a subfolder of "shared".
I use in my code a NSMutableArrayCustom class.
I never include NSMutableArrayCustom.h
I've clean the project, quitted XCode, launched it again, build, run on both iPhone and simulator : everything works fine, but I have a red compile error: MyStandardHeader.h - No such file or directory
I've tried in the build settings Always search user pathat YES and NO, it's the same.
What is the problem? Why do I have this error? How make it disappear?
I tried the steps mentioned above, but to fix the error I had to remove the file from "Copy Bundle Resources" in the project "Build Phases".
I've seen this too: files that clearly exist get wonky. Oddly, sometimes it fixes itself. It may be an Xcode bug, since the build always succeeds. I've had success with touching the file. sometimes a clean helps. and sometimes quitting xcode helps.... Voodoo really.
You could try to remove the index by deleting everything in ~/Library/Developer/Xcode/DerivedData
That directory is a combined version of the old Build and Intermediates directories from Xcode 1,2 and 3. Basically it's all the temporary and generated files from your project: object files, indexes, etc.
Another thing to try -- just deleting Derived Data wasn't working for me, but this did:
Delete Derived Data using the Organizer window, Projects tab.
In your target settings delete the value (path) set for "Prefix Header"
Close XCode and restart. Reload your project. Let it re-index.
Restore the "Prefix Header" setting.
What a major PITA.
If deleting data and Prefix Header path doesn't work then, try to click on the File (that is not found) in the Project Navigator and uncheck the target under Target Membership in File Inspector. Then deleted the files from Project Project Navigator and add again. This is the only thing that worked for me.
Merely closing XCode (6.4) fixed my particular case of this issue. I opened it back up, cleaned the project, and built. Warnings were gone! Before I closed XCode, I cleaned and built and the warnings would not leave. So something about closing XCode did it. Hope this helps others!
I deleted the #import, then moved to a different line and used autocomplete to reenter the import. That error and all others like it disappeared. Strange bug.

Resources