Posts

Post not yet marked as solved
0 Replies
421 Views
Two days into using Xcode 15 and I'm finding it quite unstable. Firstly there are times where it just crashes. No idea why at the moment, it just goes. Then there are the hangs. 100% CPU on one core and a completely unresponsive UI. Force Quit sees it as not responding and I have to kill it. Every time with this it's been a particular swift source code file that is causing the issue. Opening that file triggers something that hangs the UI, sometimes pretty quickly, sometimes after a few seconds. It's always the same files too. Completely reproducible. Most sources are fine, it's just the odd one that locks up 15. In all cases the sources compile fine. So it appears to be something in Xcode that's getting itself in knots.
Posted
by drekka.
Last updated
.
Post not yet marked as solved
1 Replies
537 Views
We have a large project where we have some View's that are being passed data in their initialisers to setup various @State variables. Recently we added some code to one of these views and the compiler immediately failed to compile it, indicating a compilation failure on a line that had not been changed. After some work to understand the problem we distilled it down to the following examples. Here is some original code that compiles, it sets the State variable in the init() because that matches the much bigger source this was distilled from. struct SomeView: View { @State var anInt: Int init() { anInt = 5. } var body: some View { Text("Hello \(anInt)") } } Now we add a Date variable and the compile fails with an error: struct SomeView: View { @State var anInt: Int let date = Date() /* New variable declaration. */ init() { anInt = 5 /* Compile fails with error: Variable 'self.anInt' used before being initialized */ } var body: some View { Text("Hello \(anInt)") } } This obviously caused much confusion here. Now at this point we managed to fix the code by doing this: struct SomeView: View { @State var anInt: Int let date = Date() /* New variable declaration. */ init() { _anInt = State(initialValue: 5) } var body: some View { Text("Hello \(anInt)") } } However it doesn't explain why the compilation failed in the first place. Nor is it great as it feels like we're going backwards when it's perfectly ok to just set anInt = 5 with the latest compilers. We'd like, if possible, for a Swift compiler engineer to take a look and give us an explanation (so we can better understand the issue) and possible improve the error reporting in future compiler releases. Currently we think it's something to do with Date being a ReferenceConvertable as swapping in other ReferenceConvertable's also trigger the same compiler error.
Posted
by drekka.
Last updated
.
Post not yet marked as solved
0 Replies
543 Views
I have a project where I've been using test plans for the past month (Xcode 13.4.1). Then today they just stopped being available. I was checking one of my schemes and noticed that it didn't have the test plan associated with it. So I went to the Build section and clicked the Add Target + button, but my Test plan files didn't show up. So I went to the Test section and it was showing the test target, not the plan. So I removed the target and hit the Add test target + button and again none of my test plans appeared. The test navigator is no longer showing the test plan above the tests. So I looked in Product - Test Plan and the only enabled menu item was to Create a Test plan. So I tried that and created and brand new test plan. When back to the scheme and still could not add it to the scheme. Nor could I get it to display at the top of the test target. I checked the git changes and it showed a bunch of new schemes which I hadn't created and all my schemes being changed back to from . Yet when I go back to the scheme I'm not offered any option to enable test plans again. And the Product - Test Plan menu items remain disabled. I've tried clearing derived, restarting Xcode, wiping all my test plans and rebuilding but nothing I do is enabling the test plans again. How do I fix this?
Posted
by drekka.
Last updated
.
Post not yet marked as solved
1 Replies
716 Views
I have a SPM framework project that includes both Swift code and JSON file resources. With a package file that looks like this: let package = Package( name: "MyTestData", products: [ .library( name: "MyTestData", targets: [ "MyTestData", ] ), ], targets: [ .target( name: "MyTestData", dependencies: [], path: "Sources", sources: ["ios"], resources: [ .copy("payloads"), .copy("snippets"), ] ), ] ) Now all the SPM packages resolve correctly and the code compiles and works, yet the Xcode workspace is showing errors like this: Now payloads and snippets are not projects and I've tried all sorts of variations of path, sources, exclude, resource in my Package file and either I get the errors and everything works, or the errors disappear and the project doesn't work. I don't know what the issue is and there's nothing in the resolving or build logs. Does anyone know what might be the problem here?
Posted
by drekka.
Last updated
.
Post not yet marked as solved
0 Replies
640 Views
I work with a number of enterprise clients and one thing we often do is have various frameworks that are optional depending on what type of build we are doing. A common example being to include a framework that contains an embedded server for testing, demo or debugging purposes. Prior to SPM we would link those frameworks as "Optional" and run a script phase after the build that removed them from the Frameworks directory of the app if it was a "Release" build. Now I have an Xcode project that includes a number of SPM package, one of which is an embedded server which in turns references several other packages I'd like to exclude form a "Release" build. But I cannot figure out how to do this. Can I make the inclusion of a package optional? Or somehow remove it after linking? In Swift I can write #if canImport(MockServer) but I cannot see how to actually make MockServer an optional include. Any ideas?
Posted
by drekka.
Last updated
.
Post not yet marked as solved
1 Replies
715 Views
HI all, just wondering if anyone else has this. I have the iOS16 and I've just noticed that if I try to download an app from the App Store, it just sits there with the circular waiting indicator spinning forever. The download never starts. Just me or anyone else?
Posted
by drekka.
Last updated
.
Post not yet marked as solved
0 Replies
1.1k Views
Hello everyone. The project I am working on is shifting from using CocoaPods to SPM and there is one "wrinkle" I'd like some advice on. The project has several framework projects containing code as well as the main app project. All of these make use of code generators (RSwift, Sourcery) at some point and these need to be run before the main build starts. The problem is that SPM builds do not support the concept of adding script phases so there appears to be no easy way to incorporate these shell tools into the builds. Particularly in the framework projects which are pure SPM packages and therefore do not have your typical project files and build phases. My question is - how to deal with shell based build phases in an SPM world? Currently we are adding these phases in the main app's build. However they are not run before the builds of the SPM dependencies so effectively we have to run the build twice to ensure the code is up to date.
Posted
by drekka.
Last updated
.
Post not yet marked as solved
0 Replies
725 Views
I have a new SwiftUI project I'm working with on my M1Pro. The project is a simple single screen app and I selected new project app when I created it. Selecting to create unit test targets as well. The app builds and runs. The UI tests build and run successfully. I then attempted to create a simple unit test and run it. However it's not compiling. The apps module name is "PointsMasterII" and when try to add import PointsMasterII to the unit test, I get the error: Could not find module 'PointsMasterII' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator, at: /Users/derekclarkson/Library/Developer/Xcode/DerivedData/PointsMasterII-ahjymfmhybwxvxakiwljcqfzmqea/Index/Build/Products/Debug-iphonesimulator/PointsMasterII.swiftmodule I also had this is the test class: func testPoints() { let calc = Calculator() } And when I checked the log of the build I saw Undefined symbols for architecture arm64:   "type metadata accessor for PointsMasterII.Calculator", referenced from:       Tests_iOS.CalculatorTests.testPoints() -> () in CalculatorTests.o   "PointsMasterII.Calculator.__allocating_init() -> PointsMasterII.Calculator", referenced from:       Tests_iOS.CalculatorTests.testPoints() -> () in CalculatorTests.o ld: symbol(s) not found for architecture arm64 I don't know how to fix this. I would have expected it to work as the unit test target has the PointsMasterII app as a dependency (setup by Xcode) and the app and UI tests run fine. Any pointers as to what to look at?
Posted
by drekka.
Last updated
.
Post marked as solved
11 Replies
5.3k Views
Big Sur is constantly dropping my wifi connection even though I'm less than 10 feet from the router. Sometimes it drops it after only a few seconds, sometimes I can get 20 or 30 seconds and sometimes it shows as connected but I can get any data. Typically this will go on for 10 or 20 minutes then for some reason it appears to stabilise and stay connected. It also fails to connect every time I wake the machine. Anyone else experiencing this?
Posted
by drekka.
Last updated
.
Post not yet marked as solved
0 Replies
734 Views
Hello everyone. I'm in an interesting situation where I'm writing a new version of an app from the ground up because the previous (old buggy) app was written using a technology that's out of date and no-one here understands. Because the app has a local database we want to load into the new app we are keeping the original bundle id. The theory being that the new app overwrite's the old app on a user's device and reads its data. The problem I have is that it appears that the old app had location updates turned on and was (possibly) consuming battery as a result. In the new app I don't think we need this capability any more and I also want to add the "Background Fetch" or "Background Processing" capability to schedule so local notifications. My question is can I change the capabilities of an update to an app in the App Store, or am I restricted to the capabilities of the original app?
Posted
by drekka.
Last updated
.
Post marked as solved
1 Replies
6.3k Views
I created a simple test project in Xcode 11 (on Catalina) and was able to see the previews for the SwiftUI views and their settings etc.I then opened an small established project I have and did all the updates that Xcode 11 suggested to bring it up to spec. Then I added a SwiftUI view using the SwiftUI template. Everything compiles fine, but when I attempt to see the preview of the SwiftUI view I get this error:messageRepliedWithError("Connecting to launched interactive agent 1590", Optional(Error Domain=com.apple.dt.ultraviolet.service Code=17 "connectToPreviewHost: Failed to connect to 1590: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 "Target process 1590 exited prematurely, likely crashed" UserInfo={NSLocalizedDescription=Target process 1590 exited prematurely, likely crashed}" UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to connect to 1590: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 "Target process 1590 exited prematurely, likely crashed" UserInfo={NSLocalizedDescription=Target process 1590 exited prematurely, likely crashed}}))I've tried all sorts of things and looked for settings I might have missed but so far I've not been able to figure this out (also rebooted the machine).Anyone happen to come across this and figure it out?
Posted
by drekka.
Last updated
.