Xcode iOS project: What is the meaning of "fopen failed" and "Invalidating cache..." at start of console log when running debug build? - ios

I have an iOS app project in Xcode 12. It is set up as an iPhone-only app that supports iOS 12.4 and later. It uses the CoreData and PDFKit frameworks, as well as two proprietary Swift Packages. All of the source code is Swift.
When I run a debug build of the app, in a simulator or on a physical iPhone device, I always get the following lines at the start of the console log:
2020-11-20 13:14:52.785201-0700 [name of my app] fopen failed for data file: errno = 2 (No such file or directory)
2020-11-20 13:14:52.785318-0700 [name of my app] Errors found! Invalidating cache...
2020-11-20 13:14:52.895737-0700 [name of my app] fopen failed for data file: errno = 2 (No such file or directory)
2020-11-20 13:14:52.895847-0700 [name of my app] Errors found! Invalidating cache...
These lines don't seem to affect the app's functionality adversely, but I am wondering what they mean and where they are coming from. I have seen the same lines in console logs in other questions posted to the Internet, but have never seen a question where someone was asking specifically about the meaning of the lines (the questions were always asking about some other problem, and their log just happened to have these lines in it).

I had the same error when I ran Flutter-generated app on 'iOS module in Xcode' from Android Studio SDK. My errors are cleared up after I ran 'Product' -> 'Clean Build Folder' in Xcode.
My set ups are: Catalina 10.15.7, Android Studio 4.0, Flutter 2.01,and Xcode 12.4.

Metal is one possible culprit. If you're importing Metal, try omitting it to see if the error goes away. Also, edit your scheme diagnostics (command<, then click the Diagnostics tab) and deselect Metal API Validation if it's selected.
Not certain about the cause, but it looks like in some situations Metal tries to read a file from the Caches directory before it exists. In that case, the error should only appear the first time you run your app.
Regardless, I believe that it's safe to ignore this error, but check your Target Build Settings for MTL_ENABLE_DEBUG_INFO and make sure Release is set to "NO".
If none of this applies to your situation, try stepping through your code while watching your app Caches directory to see which frameworks are using it.

Related

Xcode Instruments Unknown Addresses

I'm using the Xcode Instruments tool to Time Profile my application. Unfortunately, no matter how much I interact with the application while recording, I don't see a comprehensive break down of function calls in the profile. Instead, I see these <Unknown Address> [inlined] messages.
Running on Simulated iPhone on Mac:
Running on actual iPhone:
I verified that under the Xcode build options DWARF with dSYM File is selected for both Debug and Release and that the file exists. I'm using the IOS deployment target that matches the current version I have running on my iPhone and I have the latest (13.2.1) Xcode Command Line Tools selected.
I also took a look in Instruments > File > Symbols and noticed that there was a perms issue with what seems to be the CLT - not sure if this is at all related?
When I select the app name below Unknown, there isn't a dSYM path selected. However, every time I select it /Users/username/Library/Developer/Xcode/DerivedData/AppName-<sequence of characters>/Build/Products/Debug-iphoneos/AppName.app.dSYM I see a message "1 library will be symbolicated". However, this path doesn't seem to work because there is no behavior change in instruments AND it never sticks - it shows as empty if I open the window again.
Any suggestions would be greatly appreciated!

Issue with using On-Demand Resource through Xamarin.iOS on iOS simulator

I have run into an issue where I am unable to access assets tagged for use in Apple’s On-Demand Resource feature through a Xamarin.iOS app, but only when run on the simulator. This only occurred after updating my environment. I was previously on Visual Studio for Mac version 8.3.9 and Xcode version 11.2.1, and my app was able to access ODR resources without issue on both simulator and physical device.
Now I am on Visual Studio version 8.4.2 and Xcode version 11.3.1, and my app is not functioning correctly. However, I am only seeing issues when running on an iOS simulator (for any iOS version). I can build and run on a physical device (running iOS version 13.0)and am seeing no problems.
I am creating and tagging an asset for use in Apple ODR through Visual Studio for Mac. I have a ZIP file that I add into my app’s iOS project directly as a resource. In its properties, I set the BuildAction as BundleResource, select “Do Not Copy” to output directory, and give it an On-Demand Resource tag.
When I build my solution, I can see this ZIP file nested in a *.assetpack directory under bin/iPhone/Debug/device-builds/iphone12.3-13.0/OnDemandResources. I believe it is supposed to be put in bin/iPhone/Debug/OnDemandResources/ instead. When I run the code that calls NSBundleResourceRequest’s BeginAccessingResourcesAsync, it seemingly does nothing. I see the following error message in the Application Output debug window in VS after that function is called:
Begin: Request 0x0x600002566100 response: Error: Error Domain=NSCocoaErrorDomain Code=4994 "The requested application data doesn’t exist." UserInfo={NSLocalizedFailureReason=InvalidTag}
There’s no other error or exception being thrown. When I try to get the resource path from the NSBundleResourceRequest.Bundle object, it expectedly returns null.
Any reason why this is happening, and why this is only occurring on the iOS simulator and not on a physical device? I haven’t been able to find anything useful when searching for the above error message. Did something change in Visual Studio regarding how bundled assets are built in Debug mode?
Not really an answer, but more of a workaround. Using version 8.3.9 of VS for Mac seems to not throw this error, so I reverted back to that version

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.

Xcode won't run app on simulator

Yesterday I uninstalled my App Store install of XCode and installed it manually from the Apple developer site.
I had 9.4.1 and downloaded 9.3
Ever since I've not been able to run any apps on the simulator.
I see the following error in xcode:
I see this error in the Xcode logs:
iOSSimulator: 56E6A4AD-4D6F-4CB4-A666-E1DE0D49B101: Failed to launch app with identifier: com.mikevelu.Test and options: {
"activate_suspended" = 0;
arguments = (
);
environment = {
"DYLD_FRAMEWORK_PATH" = "/Users/mikemurray/Library/Developer/Xcode/DerivedData/Test-fqvnwaelkrhrooepamzxmakiidkf/Build/Products/Debug-iphonesimulator";
"DYLD_INSERT_LIBRARIES" = "/Applications/Xcode9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Develope<…>
and I see this error in the simulator logs:
(UIKitApplication:com.mikevelu.Test[0xf61e][2808][2983]): Service could not initialize: 99Z999: xpcproxy_sim + 9282 [1524][AF02A7E2-099C-3F21-AB91-5AA7DB3FFA58]: 0x5
I've tried the usual culprits, removing derived data/cleaning build folder/restarting simulator/restarting xcode/restarting macbook.
I've also tried completely uninstalling xcode and reinstalling (uninstalled 9.3 and tried installing 9.4.1), doesn't seem to make any difference.
Seen a few similar questions posted and one of the most common fixes seems to be removing any checked blank environment variables in the scheme, I can't find any to remove. I've tried running both in debug and release, I've tried disabling Debug executable and selecting the executable on launch. Also tried deleting the scheme and creating a new one.
Also set verbose logging on the simulator and I didn't get any more illuminating information.
If if install the app manually using simctl and launch it using simctl it will launch without complaints (that's what prompted me to try disabling debug executable).
I see this issue regardless of which project/workspace I have open in Xcode, the example I'm using currently is just a blank project I created to try and get to the bottom of the issue.
I'm edging closer and closer to a complete restore being the most logical next step, but I'd like to avoid that if possible.
*EDIT - Discovered the issue was with anti virus not liking it when xcode wasn't named Xcode.app. Sigh.
So, it looks like renaming the Xcode.app file now leads to some pretty ropey behaviour.
Up till now when managing multiple installs of xcode I'd just rename the files to something like Xcode.9.4.1.app, not sure when/if that's changed but the only way I can fix the simulator issue is to keep the Xcode.app filename.

Unable to run app in simulator

Today, when I try to run my app in simulator, it simply tells me
Unable to run app in Simulator
An error was encountered while running
(Domain = NSPOSIXErrorDomain, Code = 22)
And the error dialog looks like this:
I've tried many things:
Restart Xcode
Restart Simulator
Reboot
Reset content and settings of simulator
None of above works. And I looked into log, I found these are those records has something to do with this issue
2014/10/15 9:09:40.964 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
2014/10/15 9:09:40.964 Xcode[1983]: [MT] iPhoneSimulator: Unable to connect to "com.apple.instruments.deviceservice.lockdown" (Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7fcf6fc24190 {NSLocalizedDescription=Unable to lookup in current state: Shutdown})
2014/10/15 9:09:40.980 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
2014/10/15 9:09:42.351 launchd_sim[2047]: assertion failed: 13F34: libxpc.dylib + 29453 [75E30F22-514B-3A20-B82C-EDA43AF5C35C]: 0x8d
2014/10/15 9:09:42.362 com.apple.CoreSimulator.CoreSimulatorService[979]: Could not register service com.apple.coreservices.lsuseractivity.simulatorsupport: Failed to lookup com.apple.coreservices.lsuseractivity.simulatorsupport: 0x44e
I also found some other people had the same issue here : https://gist.github.com/bdeshong/2dd90add09b7287a9a85
No luck to find solution after Googling around.
Here is my environment information
OSX 10.9.5
Xcode 6.0.1
iOS Simulator 8.0 (550.1)
Any ideas?
I found the root causes, and I also found the solution. First thing I've done is to ensure this has something to do with Xcode rather than a problem relative to the project itself. I tried to create a new project, and it works perfectly fine. So I assume that is caused by something in my project.
I actually added a resources reference folder to my project. So I think the problem has something to do with it. However, even I removed the folder from project, the problem is still there. In the end, it turns out, the resources folder could live in
Built App folder
App folder in simulator
Since Xcode may simply copy and overwrite target App bundle folder, so the resources folder may still there in the App bundle folder. So after removing the resources folder, you need to
Ensure the build is cleaned
Ensure the app in simulator is deleted
And for the reason the App cannot be launched correctly, that's because it appears resources is actually a reserved folder name in the bundle structure. By adding a folder named resources into the bundle, somehow ruined the normal structure. To solve the problem, I changed the name from resources to app_data, or whatever it is, that all work.
I got the same. I just did force quit xcode and simulator then worked for me.
I got the exact same error. When browsing in my project info I inadvertently deleted the bundle identifier; hence the "ErrorDomain".
to correct, goto project data; info; set bundle identifier to whatever it was. it worked for me.
You are doing everything correct but Xcode and Swift are still in their early stages, means they are a little buggy right now. Maybe try restarting your Xcode and iOS Simulator once more.
This can happen for a couple of reasons:
You quit the iOS Simulator.app while Instruments was trying to use it.
You changed the booted device in the iOS Simulator.app while Instruments was trying to use another one.
If neither of those is the case, take a look at ~/Library/Logs/CoreSimulator/*.log for more information that might help debugging and include it in your question.
Root cause in my case was slightly different. In the project file, the iOS deployment target was set to 8.0 for the test target and 8.1 for the main target. We were running Xcode 6.0.1 (6A317) with 8.0 simulators on our build servers, which all started failing after the main build target was set to 8.1.
I'm not sure whether it was the fact that the target and tests were using different iOS deployment targets, or whether the 8.1 set in the project file conflicted with the 8.0 simulators, but it was this change which broke the simulators across several machines.
Unfortunately after setting the iOS Deployment Target back to 8.0 in the project, it still required a reinstall of Xcode (I also removed the ~/Library/Developer/Xcode directory) to return simulators to a functional state.
Check if you have proper permissions on your /private/tmp folder, should be writable and executable for all users.
Clear all files in
/Users/XXXXX/Library/Developer/CoreSimulator/Devices
Restart Xcode and Simulator.
Now it will work.

Resources