iOS app suddenly can't find file - ios

Original post:
I've got an iOS app which happily loads files successfully a few times and then all of a >sudden, with no apparent reason, fails to load the files again. The paths all seem correct >seeing as they load successfully to start with... does any one know of any reason this could >happen?
I first noticed this running the app on an ipod touch but it also happens in the iphone >simulator as well. I'm using XCode 4.2 and iOS6.
Edit:
It turns out that the audio system I was using wasn't releasing the audio player objects properly so presumably they ended up keeping file handles open or something, resulting in new files failing to open. Adding in a release to the audio players when they finished seems to have solved the problem or at least significantly reduced the likelihood of it happening!
If you run into similar problems where files won't open you can check to make sure file handles aren't being left open (each fopen should have a fclose with it when the file is no longer needed).

Related

Image.file() Showing Blank When Specified File Was Explicitly Created

In the iOS variant of my Flutter app, when I explicitly create a .jpg file using
File(path.join(filePath, fileName))
..createSync(recursive: true)
..writeAsBytesSync(buffer);
the widget that renders the file (by calling Image.file(), passing to it the file as an argument) results with a blank image.
No exception was thrown indicating that the file was not found or file contents was invalid. Its behaving as if the file is blank, but when I browse to the file using Finder, the file is there and when I click on the image, Preview renders the expected image.
When the same code is executed when the image comes from the device camera or device gallery, it works and when the same code is executed in the Android variant with the file being explicitly created, it works too.
The only thing I can think of is that it has to do with creating the image deep inside my iOS simulator directory structure
ie-/Users/joselitope/Library/Developer/CoreSimulator/Devices/F2AE8082-E670-498B-B2C6-9A83BE1855A4/data/Containers/Data/Application/7B01A347-69AE-4A1F-8567-7FCC256013F5/tmp/comp_image_cropper_2CC9EEFB-A126-4811-BD80-485B4C41F3A2-18523-00001C049E5AAE85.jpg
but again, the file is visible using Finder so this may not be the reason.
Maybe I have to set certain permissions when creating the file in iOS or perhaps settings applicable to iOS in my pubspec.yaml?
All help is greatly appreciated.
My environment is as follows:
Catelina 10.15.7,
Flutter 1.22.5 channel stable,
XCode 12.3,
Simulator: iPhone 12 Pro Max - 14.3,
Someone posted a suggestion that prompted me to look into this problem again. (That someone has since removed his suggestion so I am unable to thank him.)
Anyways, when I tried to reproduce the problem it wasnt happening anymore even in the exact use case it was happening previously.
So the question remains is why and the only thing I ruled out that it wasnt a race condition as this code has been running on Android for quite some time on various devices.
This is what I could come up with:
Knowing the filepath I was writing to, I realized that I was writing to the app's /tmp directory which iOS periodically empties out. I am thinking that I shouldn't be putting stuff there. Instead, I've been writing to the app's documents directory and it hasnt happened since.
The initial /tmp directory was chosen for me by a package I was using and since it was so long and Im new to iOS, I didn't really look into it all that much, caring only that the file was there, which it was.
Anyways, keeping my fingers crossed that the fix sticks.

What's wrong with this aupreset for AUSampler?

I created this aupreset to be loaded into an AUSampler in iOS. I followed the process outlined here and used the EPSSampler class for the same post. So, if I run my app in the iOS simulator, on iOS 9, the aupreset loads and I get to play notes. If I run the same app on a device running iOS 6, the preset loads but I get no sound. I have used the same process on simulator and device in the past, but always by filtering the built-in sine wave generator, never with audio samples. Can someone spot what I'm doing wrong?
EDIT I have no way of testing the app on any device running iOS above 6, at least for now.
EDIT 2 To clarify further, this is how my project looks in Xcode, so you know that my files are going to the right places – i.e. the audio files are going to the Sounds folder within the app bundle (I double checked, just to be sure).
EDIT 3 So, I took the Trombone.aupreset from LoadPresetDemo and manually plugged my audio files into it. Magically, it worked. So I figured I'd load it into the AUSampler's GUI through AU Lab, and make whatever changes I needed to make it sound right – i.e., increasing the release time. It stopped working. So, i manually tweaked the working copy to roughly match what I needed (the docs on aupresets plists are surprisingly unhelpful) and I'm rolling with it. It would seem that AUSampler is messing up the preset, at least for iOS 6 on device, which, currently, is the only device I have to test on. Insights?
I didn't really look that deeply, but the file://localhost//Library/Audio/Sounds/C.caf in your file references looks a little fishy. Mine looks like this /Users/dave/Library/Audio/Sounds/C6.wav. Maybe the file:// part is throwing it off.
Create a directory in your iOS project named Sounds (just like your image shows) and put your caf files in there. The URLs will be groked by iOS.
Here is a post that goes into detail.

How to get SKAction(name:) to work reliably?

I've been working through the DemoBots example and having a lot of trouble getting it to work on all devices.
https://developer.apple.com/library/prerelease/ios/samplecode/DemoBots/Introduction/Intro.html
The current problem I'm having is that on an iPad Mini the app launches but crashes when loading animations. It crashes in AnimationComponent.swift on the line that loads an action from a file:
let bodyAction: SKAction?
if let name = bodyActionName {
// crash here
bodyAction = SKAction(named: name)
}
else {
bodyAction = nil
}
Debugging the app reveals that its trying to load an SKAction called "ZappedShake" but crashing with an array out of bounds exception.
On an iPhone 5S it runs fine. My best guess is its race condition with the faster iPhone 5S is loading the file with the action serialized in it, and by the time execution reaches this point the action is available. But on the single core older iPad the file is not yet loaded and the call fails.
Both are real hardware running iOS9 13A4325c, compiled on XCode Version 7.0 beta 4 (7A165t).
Making the problem more difficult is that I can't see where the file that apparently creates the "ZappedShake" - ReferenceActions.sks - is actually loaded. Its referred to by ReferenceScene.sks but nowhere in any of the code or anywhere else in the project can I see that file being referred to.
Is there some sort of name convention magical file loading mechanism for SKActions? Why does it work on the iPhone 5S and not on the iPad?
UPDATE: Found more on this here: http://asciiwwdc.com/2015/sessions/604
Also this year we focused on referencing and instancing.
We know you spend a lot of time designing high-quality content and animations for your games and we want you to let you reuse that content anywhere where you would like to.
We're allowing you to create serialized data files for your nodes and your actions and then add them as a reference instead of just loading them into your scene.
This way, every time you make a change to the source asset that is automatically reflected in the content of your game.
How do I do this for nodes? For nodes I design part of my scene, maybe a background element, or some scenery in our editor with an Xcode and then I can just drag-and-drop those files into my main scene in Xcode and it will automatically create a reference and it is all set up for you.
If you want to do this in code you can as well, you can manually construct an SKReferenceNode, assign it a file name or even a URL and when that content is first presented in your game we'll load in that content based on the latest version of the file that's in your bundle.
We can also do the same thing for actions. With actions go check out our great new action editor and beyond creating and composing the actions in Xcode you can give all them names.
These names are the key to using them in your game. We have added a selector to SKAction called actionNamed. This works just like it does for SKTexture and textureNamed.
You pass in the name of the action you want. We're going to automatically look inside of your app bundle in all of the serialized action files, find the one with the appropriate name and then surface that to the application.
This looks great but I can't find any documentation on it, or figure out how to debug it when it goes wrong.
It's not you, it's iOS. There's a bug with action references affecting 32-bit devices (like the iPad Mini.)
This issue has been fixed in iOS 9.2 Beta 1, according to this thread on the Apple developer's forum:
https://forums.developer.apple.com/thread/17267
Try running on a more recent 64-bit device (like iPhone 6) in the simulator. Or try upgrading your iPad Mini to iOS 9.2 Beta 1. Or just wait for the next iOS release to fix the problem.
The DemoBots game seems to run reliably when compiled with Xcode Version 7.0 beta 6 (7A192o).
Using a different machine (my home laptop) with a fresh install of Xcode the problem goes away. I also note that the first time I tried there were a few minor compile fixes I had to do such as renaming CGPoint.zero to CGPoint.zeroPoint which I guess should have sounded warning bells that there was some sort of version conflict. This time with the fresh install it compiled and ran out of the box.
I still don't completely understand how the reference actions are getting picked up but at least I now have multiple working versions of Demobots so I can just duplicate the working code there.

Flash as3 ios: error #2007: parameter possible symbol clash in multiple swfs, abc env must be non-null

I'm developing an app for iOs using flash air, version 3.8, this version allow me to load a externals swf with assets, flash professional cs6 and flash builder 4.7
I have some kind of lobby where the user select a differents games. If I deploy the app just with 1 game (1 swf), I would loaded a game without problem
But, If I deploy the app with other games, I would just loaded 1 of them swf, but the other games give me this error:
error #2007: parameter possible symbol clash in multiple swfs, abc env must be non-null
The parameter abcenv doesn't exist in my code.
Thanks in advance
I have found exactly the same issue it also happens with AIR 3.9 You can only do this by embedding the game logic into your main menu and constructing classes as you need to. I know this makes the initial part of say your menu heavier.
You can however load in swfs as library assets, if you need this. I think the bug has to do with swfs and a restriction of overlapping classes and the fact that you can only use one Application Domain. But this is my best guess on the underlying restriction with this. If you do find a work around let us know.
I encountered this error and solved it today. After Google I found nothing can help. Now maybe I'm the only person that solved the problem easily. This is my story:
Working on a AIR actionscript mobile project.
In ad-hoc package for iOS, loading multiple SWF files successfully, except two. Those two cause the "Error #2007: parameter possible symbol clash ......" error.
Found there is a very small difference between the normal SWF and the error one: in the error SWF, one MovieClip is 3D transformed, I saw there are three 3D axis above the MovieClip. Then I deleted the MovieClip from stage and Library and replaced with a new one. Problem solved.
Note that I didn't re-name anything, or delete any duplicated things. In fact there are many duplicated things (image file with same name, and MovieClip copied between the SWFs) in the SWF files.
I ran into this same issue. The issue is that AIR for iOS has to compile ALL of the external .swfs together, so if there are naming conflicts, that can cause trouble. This especially seems to be a problem if two or more of the .swfs were made from the same cloned .fla, even if one of the files had changes made to it.
In my case, it turned out that there were several unused earlier versions of .swfs in the folder of .swfs to be loaded (such as external_movie-prev.swf). I was able to solve the problem quite easily just by deleting these extra files.
This is a common technique in development, just to rename a previous version of a file and add in a new version to the folder for testing. In normal software development these extraneous versions do no harm. But in the case of AIR for iOS, this situation can cause your app to inexplicably freeze when you try to go a movie that also has an unused previous version in your assets folder. This took me several hours to chase down, so I hope it helps someone else.

app.xml consistently overwritten

I am building an IOS app using Flash Professional 5.5.
The building goes fine, however, I am needing to edit the app.xml file to make a couple of things work. When I do this, save it and then publish the app, the app.xml file is overwritten and the changes I made are gone.
How do I get Flash to keep using the app.xml file I have created rather than it rebuilding a new one every time I publish the app?
I had the same issue, related to this other issue: http://kb2.adobe.com/cps/909/cpsid_90916.html. I followed the tutorial many times, but every time the file was overwritten and I could not publish with AIR. How I solved: I changed the contents of the file the way I needed, then I write-protected the file (then I compiled again). This way, Flash could not overwrite it anymore.

Resources