I am playing around with SwiftUI and looks pretty interesting however I am facing very annoying performance issues.
When I create a new SwiftUI file or make a large change in a SwiftUI view, XCode would start recompiling everything. It would re-compile pods(I am using Firebase) even if they are not included in the view.
This behaviour is quite painful because it takes a few minutes for the process to finish and more often than not it will result with an XCode error and I will have to click "try again" before I have anything in the Canvas or on the device.
Is there anything I can do to improve performance when developing with SwiftUI?
This is what happens when I create a brand new SwiftUI file
A workaround for this issue is to create another app target that doesn't refer to any pods. This way, you can have fast compile and preview of the pure SwiftUI files as the pods and other files won't be compiled when you switch target.
Related
Whenever I exit the Unreal Engine 5 editor, I've noticed that when I open it up again, my various C++ classes disappear.
Fortunately, all I have to do is re-compile and they will be added back in again. However, it does become a serious inconvenience since I will have to re-attach it to any actors it was a component of and I have to re-do any Detail panel edits I did.
Let's say I'm trying to make a series of moving platforms move for my parkour game, so I make an ActorComponent called PlatformMover. I attach it to different platforms with their own velocities and directions. I then exit the Editor for the day and when I re-open it the next day, PlatformMover is gone. I then re-compile my project and PlatformMover is back, but I now have to re-attach it and re-configure it for every platform again.
It's really inconvenient, so is there any fix for this?
I managed to find out that this is a rather common bug with live coding. Fortunately, the Unreal Engine course I've been taking actually has a video earlier in the course catalog that deals with this, and I can report that the solution provided worked for me.
Close the editor immediately but leave the IDE open.
Build the code with [Project Name]Editor Win64 Development Build.
(Emphasis on the "Editor" part at the end. I thought this didn't work until I realized that I was actually using "[Project Name] Win64" instead of "[ProjectName]Editor Win64"
Open the project again.
I receive this error whenever I try to preview a freshly created swiftui view.
messageRepliedWithError("Connecting to launched interactive agent 9297", Optional(Error Domain=com.apple.dt.ultraviolet.service Code=17 "connectToPreviewHost: Failed to connect to 9297: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 "Target process 9297 exited prematurely, likely crashed" UserInfo={NSLocalizedDescription=Target process 9297 exited prematurely, likely crashed}" UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to connect to 9297: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 "Target process 9297 exited prematurely, likely crashed" UserInfo={NSLocalizedDescription=Target process 9297 exited prematurely, likely crashed}}))
I have no idea how to fix this so I can see previews again. I am on the latest Catalina 10.15.1
I found the Preview Canvas to be extremely buggy as well. Or maybe swiftUI code has a lot of undesired side effects.
In many occasions I found that Clean Build Folder, then kill Xcode, start Xcode, do a full Build may (sometimes) fix the problems. Until I make a tiny change somewhere... Then the whole circus starst again.
In practice this is very time consuming and basically unworkable. I found it more efficient to not use the preview canvas at all and just run the code. It is quicker, more reliable and in the end saves lots of time and frustration.
At the same time I think it is a bit of a shame on Apple. Most frustrating of all (for me at least) is that documentation is virtually non existing. It is all trial and error. Mostly error.
In short: my experience is that it is better not to use swiftUI Previews for anything beyond the very basic (yet).
I had the same problem with mine, I went through a couple of steps, so I will mention everything I did hopefully it helps someone.
But it's worth mentioning that I think the error was caused by Xcode trying to connect to the preview which failed all the time, because I was using an iPhone 8 preview.
Also I was able to use iPhone 8 preview after a while again. This looks like a buggy Xcode.
Steps.
1. Clean build folder and your derived data.
2. Close XCode Completely.
**Key Step. Open Xcode again and change your preview to iPhone XS or iPhone 11.
See the image below.
I had same issue. It was very confusing. I am using FirebaseFirestore pod in my podfile and when I remove FirebaseApp.configure() from AppDelegate didFinishLaunchingWithOptions function preview works.
I have done this 10 times just to make sure that this is an issue, and it was issue for me. So probably any code from Firbase added in that function was problem for me.
So, by checking logs I came across this error:
Crashed Thread: 3 Dispatch queue: com.google.GDTCORFlatFileStorage
Also googling I came across those bugs:
https://github.com/firebase/firebase-ios-sdk/issues/5707
https://github.com/firebase/firebase-ios-sdk/issues/5708
Turning off the thread sanitizer worked for me (I was just playing around with settings against another project that worked), so there's one more thing to try...
My Android app has some slow running functionality. A unit test captures it perfectly. The unit test execution shows that it runs way slower than it should be.
Android Studio keeps offering me next to the run method a menu option: "Profile" instead of run. I select that option, but nothing different than run seems to happen. I expected Android Studio to open a window with the timing of all the method calls after the test completes.
I've searched Google and the Android site. Everything I find talks about profiling in Android Studio in general.
How do I profile an Android unit test? (What does that profile option really do?)
I had the same issue and I decided to investigate a solution because I was thinking that it couldn't be too hard. Boy was I wrong.
My original answer which was never posted contained some awkward fiddling around with Thread.sleep and manual timings and hitting the right button at the right time. This was replaced by a more elegant solution using the Debug API from within the code.
Using Android Studio 3.1.3 these were my steps:
I had to copy my actual unit test into androidTest (because I actually was interested in algorithmic complexity (and not time consumption) I found no way to actually profile inside Android Studio without an emulator. For performance tests this makes sense but in my case I wanted to ensure that even in complex scenarios my methods behave in a predictable fashion.)
To avoid the need of fiddling with with Thread.sleep and log output indicating a start/stop you can use combinations of Debug.startMethodTracing("File"); or Debug.startMethodTracingSampling() and Debug.stopMethodTracing(); or similar (See https://developer.android.com/studio/profile/generate-trace-logs). My code now looks like
#Test
public void Test_Something() throws Exception
{
Debug.startMethodTracing("Predict");
// DO YOUR CODE
Debug.stopMethodTracing();
}
When I now execute the profile I can obtain the .trace generated in the mentioned location on the device as stated in the link above:
(again read the linked page because you will need WRITE_EXTERNAL_STORAGE permission, which my app already had, so it wasn't that much of a hassle in my case.
Double clicking the trace opens it in Android Studio. Unlike stated at the link above I am currently unable to import such a trace in the profiler because either 3.1.3 lacks this function or I am unable to locate it.
Edit: After I upgraded to Android Studio 3.2 I now can indeed load and save sessions and display them in the Profiler. This has improved a lot. And interesting fact: When I opened the trace in Android Studio 3.1.3 I saw the hit count for methods (how often methods were called) and not their clock times. In the profiler on the other hand I was not yet able to find the call times but instead have access to wall clock times. Would be great if someone has a hint on how to display those too.
I am using XCode 5.1.1 to build a multi-platform (Cocos2d-x) project. I am finding that there seems to be a delay before some of my resources are available to be loaded. For example if I try to access a file like this:
std::ifstream t(path);
if(!t) {
std::cout << "Warning - no such file found" << std::endl;
}
...the file will just not be there sometimes. (By which I mean that it sometimes just does not appear to find the file.) If I delay the load for a second then it will be there. Also, if I insert a breakpoint and then resume execution the file will be there. It even seems to happen more often if I am running the application from the iOS springboard rather than debugging in XCode.
This is also happening with loading texture files in my project, using APIs in Cocos2d-x.
EDIT #LearnCocos2D suggested that I may be trying to load the files before the AppDelegate didFinishLaunching function is called. I didn't know about that requirement, but after examining my code I'm pretty sure everything is loaded after that. The textures that are not loading are created for children of a cocos2d::Scene that is created inside the AppDelegate::applicationDidFinishLaunching() function (I started my project based on the HelloWorld example that comes with Cocos2d-x.)
The program flow is something like this:
AppDelegate::applicationDidFinishLaunching()
//...
auto scene = GameScene::createScene();
//... create Sprites etc, but they never show on the screen :(
EDIT Ok, I fixed my problem. It turned out that I was totally wrong about the cause of the problem, and it was actually an initialisation problem that lead to undefined behaviour. However, #LearnCocos2D's comment about having to wait for applicationDidFinishLaunching() before Resources are available is a good tip.
I am having an issue in FB4 where some classes are not accessible through hyperlink navigation (Command-Space) or Open Declaration (F3). The classes ARE available through Open Resource (Shift-Command-R) and the project compiles fine when I use them.
What's especially strange is that only SOME of the classes in each packager are available, but some are not. And the same holds true for auto-complete, i.e. if I begin an import statement, not all of the classes will not be available for auto-complete.
Any ideas?
Thanks,
-Gabriel
http://www.pizmogames.com
Making a change to every .as file in my project fixes this -- but only until the next time I open the project. So, now I have to make a batch change of some kind (appending a return, etc) to all my .as files (unix touch is not enough,... the contents much change) each time I open it. I wish there was a better solution.