Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
We support building our swift code as every version of swift from 3.1 onward, and these days the differences are sufficiently small that it's pretty painless and most of the #if(swift>=X) checks are for working around bugs in various old versions rather than actual language changes.

A huge difference from the Swift 1/2/3 times when we just plain had separate codebases for each major version.

Adbot
ADBOT LOVES YOU

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

eschaton posted:

There’s not actually something called “XCUITest,” it’s just using XCTest for UI testing.

Unfortunately, "XCUITest blah" tends to get better results when googling than "XCTest UI blah" in my experience. :shrug:

Simulated posted:

The other thing you can do is accept that UI tests are slow and design each functional area of UI testing to be completely isolated. Terminate the previous app instance and launch a new one from scratch for each area.

In the past, I've even gone through Springboard to delete the app off of the device/simulator, to make sure it reinstalls fresh (this mattered at the time because we wanted to do certain things to the keychain, as I recall)

quote:

Have a special argument that nukes the database or otherwise cleans up everything and pass this to the app when you launch it for testing.

Adding on, instead of a single boolean "do I nuke?", it's better to pass some sort of flag that tells the app on launch what state it needs to be in, and it does the needful to get it to that state pretty much immediately in its AppDelegate. This can be helpful especially if you need to pass in essentially random strings (e.g. if you have external resources/UUIDs that the tests know about that can't be hardcoded for whatever reason). On one project, we actually built an entire helper class to de-stringify this and make it a nice enum.

quote:

When testing in the Simulator you can also pass a path to a domain socket and use that to communicate directly between the app and test.

I'd love to get a better of an understanding of this, and how it would look in practice.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

TheReverend posted:

Does anyone have any tips or tricks to make this a pleasant experience?

I've fiddled with UI Testing in a number of different ways, and ultimately, the architecture I liked the best was a "screen-based" one. Essentially, there was a test class (not a test case class) for each screen of the app, and that class knew how to do everything with that screen (they also all inherited from a base class that took in the XCTestCase and the App and a handful of other things). For example, there was typically a function `verify(state:)` that took in an enum (if applicable) and did all of the checks to make sure the screen looked correct for that state (e.g. that labels had the right values, the right buttons were enabled, and so on); and on the "login screen", there was a `login(_)` that took in an enum to indicate whether to try logging in with a correct password or incorrect password (and would take care of typing the thing in and then pressing the button), and so on.

It ultimately made tests look something like this:
pre:
func testThing() {
    loginScreen.verify(.fresh)
    loginScreen.login(.incorrect)
    loginScreen.verify(.incorrectPassword)
    loginScreen.login(.correct)

    homeScreen.verify(.nomessages)
    homeScreen.sendMessage()

    messageScreen.verify(.nomessages)
A couple of notes to this approach:
1. I took heavy advantage of the fact that you can pass up the #file and #line into pretty much everything in XCTest itself; so all of the functions in each of the screen classes included `file: String = #file, line: UInt = #line` (or whatever the correct types on those are). This meant that when there was a failure, it showed up in the test rather than buried in a utility function.
2. I don't currently have access to the code where I did this, and even if I did, I couldn't share it. I've been meaning to put up a public example of this, but I haven't gotten around to it yet. Sorry; it makes much more sense when you see it rather than having it explained out like this.
3. The app where I did this was a heavily screen-based app with a very limited number of discrete states per screen. I've given some thought to how it would work to apps that had fewer screens that did more per screen, and it may actually break down with larger apps with more things going on. Your mileage may vary, though I'd love to see how it gets adapted out.
4. Doing any UI Testing against a server is...uh...painful. This is true even outside of XCTest. I haven't really seen a good solution to this (i.e. one that doesn't have significant other drawbacks), short of having the server in a Docker (or whatever) container and booting it up with the exact desired test data before the test, and making sure the UI test hits the containerized server. If you're doing stuff with Swift on the Server, cool! You might be able to do this! Otherwise, uh, good luck. If you figure something out, I'd love to know.
5. There was a fair amount of heavy lifting in the `setup()` method of each test case class (which all inherited from a base XCTestCase subclass to do the repeated heavy lifting over and over again); I've neglected that here.
6. UI tests are slow and more likely to be brittle compared to unit tests. Pull them out into their own target, and make sure they get their own scheme for running that target; you don't want to run them with the frequency that you run unit tests. Also, beware the temptation to write tons and tons and tons of UI tests—if they take 5 hours to complete, they're not as useful as if they take 30 minutes. Hit your major flows and your most-likely-to-break flows; trying to use UI tests to cover every single random corner case is, in my opinion, not a good idea.
7. UI Tests output a bunch of stuff in the test output directory, and your CI should be vacuuming that up and putting it somewhere useful. You can then use something like [ulr=https://github.com/TitouanVanBelle/XCTestHTMLReport]this[/url] to look through failures better. But, it's still a bit of an awkward pain, though it's getting better. :shrug:
8. Probably other stuff I'm forgetting.

Hopefully you have good luck/experience with your UI Testing. If you put in the effort early to get a good architecture and set up to be smoother, you'll enjoy it a lot more and be more productive in the long run; it can sometimes be tricky convincing the Powers That Be that you should take that much time. Your mileage may completely vary.

TheReverend
Jun 21, 2005

Thanks for all the UI testing info!

Axiem, If you ever get a small sample of your architecture that's fit for the public I'd love to see it!

I'm going to experiment around myself and see what I can come up with.

Thanks!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Yeah this talk has actually made me vaguely interested in trying again someday. I have no doubt I was doing it wrong (or at least poorly) in the past.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Plorkyeran posted:

We support building our swift code as every version of swift from 3.1 onward, and these days the differences are sufficiently small that it's pretty painless and most of the #if(swift>=X) checks are for working around bugs in various old versions rather than actual language changes.

A huge difference from the Swift 1/2/3 times when we just plain had separate codebases for each major version.

That's good to hear.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

TheReverend posted:

Axiem, If you ever get a small sample of your architecture that's fit for the public I'd love to see it!

I'll see what I can do.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Axiem posted:

I'd love to get a better of an understanding of this, and how it would look in practice.

To be fair you are somewhat on your own here but you'd create the socket file and pass its path as an argument to the app, then shove JSON or Property Lists down the socket. You could also use a pipe if you like.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

Simulated posted:

To be fair you are somewhat on your own here but you'd create the socket file and pass its path as an argument to the app, then shove JSON or Property Lists down the socket. You could also use a pipe if you like.

I...think that makes sense? I've never actually worked with socket files or pipes particularly in all my years of programming. Would that just be using...uh...is there an Apple library / 3rd party library for that sort of thing?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Axiem posted:

I...think that makes sense? I've never actually worked with socket files or pipes particularly in all my years of programming. Would that just be using...uh...is there an Apple library / 3rd party library for that sort of thing?

A pipe is probably easier than a unix domain socket. Use mkfifo(2) to create a named pipe somewhere. Pass the path as the argument to the process under test.

Then create an NSFileHandle from it. For each message, serialize the dictionary to a Data. Send the size of the data (as a UInt64) over the pipe, followed by the data. (Use the file handle's write method).

On the receive side read 8 bytes (the size of the UInt64), then use that to know how big a buffer to malloc and read that many bytes into it using an NSFileHandle again. Hand that off to Data (bytesNoCopy, and set the dealloc function to free). Deserialize back into a property list.

This can be wrapped into a single class included in both targets and made bi-directional if needed.

toddy.
Jun 15, 2010

~she is my wife~

Dirk Pitt posted:

I work on a social network and we have a consultant who won’t shut the gently caress up about adding rxswift. Am I too biased at this point?

I don’t want to add the burden of learning RX to our already odd architecture added by prior consultants. And I think the lessons are good and can be done in normal cocoa without adding another goddamn pod and paradigm.

In terms of reactive programming libraries for Swift it's one of the worse ones out there. Only reason I've seen advocacy for using it in Swift so an iOS app could mimick the architecture of an Android app (RxJava/Kotlin is a lot more common because screw AsyncTask). Make a case for PromiseKit or ReactiveSwift if they're hellbent on introducing reactive libraries, every company has at least one of those people.

I'd... stay away from the reactive UI kits though - those get kinda messy.

lord funk
Feb 16, 2004

I'm at the point with my current project where I'm creating the document structure, and just wanted to check: what's the current sleekest way to do this? Is it UIDocument / NSCoding, or JSON-based, or something else entirely?

Eventually I want to include file sharing between users, maybe with a central server somewhere down the line. Also considering (but really hesitant to implement) some kind of cloud backup.

GenJoe
Sep 15, 2010


Rehabilitated?


That's just a bullshit word.
UIDocument is really just a way to serialize and deserialize from a file, you're in charge of how the data gets read and written. Implementing it is a huge benefit if you want to make your documents syncable or share-able via iCloud Drive though, because it registers itself as an NSFilePresenter, and exposes methods that let you react when another process on the system (the iCloud Drive daemon, Files app, etc) writes to or deletes the file while you have it open.

Workaday Wizard
Oct 23, 2009

by Pragmatica
Does iOS support Wifi Direct AKA Wifi P2P?

Dog on Fire
Oct 2, 2004

I have this set-up:
1. My developer account has been invited to the client's App Store Connect team.
2. They haven't invited me to their actual development team.
3. They've sent me the provisioning profile and the cert + private key for their app.
4. I've resigned an existing .ipa file using that provisioning profile and cert.
5. I'm trying to upload the .ipa to their App Store Connect using Application Loader.

And now when I try to upload the .ipa to their App Store Connect I get the error that the bundle ID can't be found on their account. It's the right ID though. Plus I also get the same error when I try uploading the last .ipa file that went through this phase during uploading. My own guess is that this might have something to do with the App Store Connect user management changes that Apple are introducing. But maybe someone has other ideas?

The error looks like this:

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Shinku ABOOKEN posted:

Does iOS support Wifi Direct AKA Wifi P2P?

Yeah...sorta. There’s MultipeerConnectivity and the lower-level stuff it’s based on (name escaping me at the moment). It uses Bluetooth and Bonjour announces to set up a connection.

Edit: NSNetService...it's NSNetService.

ultramiraculous fucked around with this message at 15:05 on Aug 3, 2018

Froist
Jun 6, 2004

Dog on Fire posted:

And now when I try to upload the .ipa to their App Store Connect I get the error that the bundle ID can't be found on their account. It's the right ID though. Plus I also get the same error when I try uploading the last .ipa file that went through this phase during uploading. My own guess is that this might have something to do with the App Store Connect user management changes that Apple are introducing. But maybe someone has other ideas?

The error looks like this:


We hit this error last week. Signing out and back into Xcode solved it for us.

Dog on Fire
Oct 2, 2004

Froist posted:

We hit this error last week. Signing out and back into Xcode solved it for us.

Ha, yes, reopening Xcode got rid of this. Thanks a bunch!

lord funk
Feb 16, 2004

@GenJoe thanks.

Metal people: I cannot figure out how to stop rendering when the device goes to sleep. I have my MTKView view controller follow the UIApplicationWillResignActive notification to set mtkView.isPaused = true. I also tried doing that in viewWillDisappear. However, it always tries to render a frame before those are called, but after the screen is gone, so it crashes when it tries to get the currentDrawable, as expected.

What gives? It seems like UIApplicationWillResignActive would be the way to do this.

Kallikrates
Jul 7, 2002
Pro Lurker
Dear Apple people. Whoever fleshed out all the multi cursor bindings in the new editor thank you!

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

I'm trying to make a program that can identify what UI object the mouse is currently over, similar to this demo from Apple

https://developer.apple.com/library/archive/samplecode/UIElementInspector/Introduction/Intro.html
(AppDelegate.m, the method updateCurrentUIElement is what I was working off of)

However, my program doesn't seem to work. It outputs this:

code:
2018-08-08 23:03:01.881838-0400 MouseTracker[737:12287] Creating system wide accessibility object
2018-08-08 23:03:01.881874-0400 MouseTracker[737:12287] <AXUIElement System Wide 0x600000059770>
2018-08-08 23:03:02.434334-0400 MouseTracker[737:12287] Accessibility Error Code: -25200
2018-08-08 23:03:02.434375-0400 MouseTracker[737:12287] Description: (null)
2018-08-08 23:03:04.386557-0400 MouseTracker[737:12287] Accessibility Error Code: -25200
2018-08-08 23:03:04.386622-0400 MouseTracker[737:12287] Description: (null)
2018-08-08 23:03:04.902849-0400 MouseTracker[737:12287] Accessibility Error Code: -25204
2018-08-08 23:03:04.902935-0400 MouseTracker[737:12287] Description: (null)
2018-08-08 23:03:05.886137-0400 MouseTracker[737:12287] Accessibility Error Code: -25200
The errors are:

kAXErrorFailure = -25200
kAXErrorCannotComplete = -25204

Specifically, this line doesn't appear to be copying the element to the elementUnderCursor variable

code:
        AXUIElementRef elementUnderCursor = NULL;
        // grab what is under the current mouse location
        accessibilityErrorCode = AXUIElementCopyElementAtPosition(_systemWideAccessibilityObject, carbonPoint.x, carbonPoint.y, &elementUnderCursor);
   
It's like I'm missing something basic with how the variables are initialized or copied. Maybe something to do with disabling ARC so UIElementUtilities.h/m would compile (copied from the Apple example)

Here's the whole program:

https://pastebin.com/QrdpAkiR

dizzywhip
Dec 23, 2005

Kallikrates posted:

Dear Apple people. Whoever fleshed out all the multi cursor bindings in the new editor thank you!

Yeah this has been my #1 Xcode feature request for a long time. I've been keeping Sublime open and copying stuff back and forth whenever I really need multi cursor editing. Super excited to fully migrate to Xcode 10.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
Glad to hear! When I’m back in town I’ll let the folks responsible know.

(It should work with Xcode Source Editor Extensions, too!)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Bob Morales posted:

It's like I'm missing something basic with how the variables are initialized or copied. Maybe something to do with disabling ARC so UIElementUtilities.h/m would compile (copied from the Apple example)

I can't help with the specific API problem, but I will point out that ObjC ARC doesn't do anything for CF types like AXUIElementRef, so it seems unlikely that turning off ARC would have anything to do with it.

By the way, I'm pretty sure all those return values from CFCopyDescription are being leaked.

Good Sphere
Jun 16, 2018

How can an imagePickerView show your photos in the correct orientation, when two photos there appear to have the same orientation have an entirely different UIImageOrientation assigned to them? It's become a problem for me when attempting to apply CIFilters the same way I would through the camera.

To explain more thoroughly, my photos app will display two portrait photos perfectly fine, but when I read the encoded orientation on these images, they are both entirely different. So it makes me wonder how the photos app can display it correctly. EXIF info?

I even found some other people having the same problem, and tried a "fixOrientation" function as an extension to UIImage, but it doesn't seem to fix anything.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
A UIImage can have an orientation, which is read by e.g. UIImageView, UIGraphicsRenderer. If you’re using the underlying image data directly, you’ll need to check the orientation and apply an appropriate transform. The Photos framework has a similar means of reporting orientation metadata. And ImageIO has some functions to help you read metadata from any old pile of bytes you have sitting around.

And yep, EXIF or XMP or whatever is where that metadata often ends up.

Good Sphere
Jun 16, 2018

I ended up not assigning an orientation at all from imported photos and apply the filters as if the device is in a left orientation and it works perfectly!

I feel so relieved now that I stripped away so much code that used to apply the filters differently whether the source image was from taking a photo, realtime input or importing.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Bob Morales posted:

The errors are:

kAXErrorFailure = -25200
kAXErrorCannotComplete = -25204

Specifically, this line doesn't appear to be copying the element to the elementUnderCursor variable



Welp, fixed it. My project was sandboxed by default. Works as expected now.

2018-08-11 19:37:21.647256-0400 MouseTracker[9731:4462376] <AXUIElement 0x600000444fe0> {pid=340}
2018-08-11 19:37:22.646985-0400 MouseTracker[9731:4462376] Accessibility Code: 0
2018-08-11 19:37:22.647085-0400 MouseTracker[9731:4462376] <AXUIElement 0x600000444f80> {pid=332}
2018-08-11 19:37:23.151946-0400 MouseTracker[9731:4462376] Accessibility Code: 0

Good Sphere
Jun 16, 2018

I'm getting my app ready for TestFlight, so I'm archiving my app and trying to upload it, but I'm getting an error "Your app can’t contain standalone executables or libraries". The answer that I can find so far to fixing that is to not have libraries included in Copy Bundle Resources, which I don't.

I've had a heck of a time getting it to archive at all with the FBSDK libraries I have included in my project, but it seems I've fixed it where I can both build and run to my device as well as archive. I just can't get past this error when uploading.

edit: I don't think it has to do anything with the FBSDK. The file that it's having problem with is named "[app name]Prefs.o" which I cannot find anywhere.

Good Sphere fucked around with this message at 22:41 on Aug 14, 2018

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
If you grep the build log for that filename does it show up?

Good Sphere
Jun 16, 2018

pokeyman posted:

If you grep the build log for that filename does it show up?

Yes! Twice. I don't know what it means, or if it says anything significant. If it's somewhere, is it okay to try to temporarily remove? I guess I'm not sure where to go from here. These are both under "CompileSwift normal arm64".

quote:

"/Users/Admin/Library/Developer/Xcode/DerivedData/App_Name-fglhwhjmskcjuedbcbpinrnjxaet/Build/Intermediates.noindex/ArchiveIntermediates/App Name/IntermediateBuildFilesPath/App Name.build/Release-iphoneos/App Name.build/Objects-normal/arm64/AppNamePrefs.o" -o

Both times it's shown appear to be the same.

Good Sphere
Jun 16, 2018

Really stupid an obvious, but somehow a swift file with a similar name ended up in my Copy Bundle Resources! I don't know how it got there, but I removed it, archived, and I was able to upload. :)

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Good find!

Small White Dragon
Nov 23, 2007

No relation.
So I re-wrote a couple of small Objective C apps in Swift, and I noticed they're substantially larger, I think primarily due to the inclusion of several swift dylibs in the IPA. Wouldn't this be something that would normally be included in the OS?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
Yes, if Swift had a stable ABI (Application Binary Interface).

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It's something we have concrete plans to fix in Swift 5, which is expected sometime early next year. You haven't doomed yourself to permanently inflated app sizes.

Good Sphere
Jun 16, 2018

I really don't get how to add new Groups to my build in TestFlight, or if that's not allowed until I submit a new build. Seems really lame since it hasn't even been approved yet.

Here, I see my app's icon. I click on that,


and I get this, but I have one more group that I made since I submitted it with Application Loader that I don't see in the list below, so I try to click the circular plus (+) sign,


but it says "You can only submit one build from version 1.1 to Beta App Review"


Wha?? I clicked on Group's plus button. I'm trying to add a group, not a build! I guess I'm confused, and furthermore, I often see people talking about "adding a build to their group" and not "adding groups to their build" which sounds backwards.

So I'm unsure if this a bug, maybe that clears up once it's approved, or I don't understand what it's saying.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
To send a build to external testers you need to go through beta app review. Typically takes a day.

Only one build for each version goes through the full review. Subsequent builds will be automatically approved in seconds.

If you try to add a group of testers to a build, and any of those testers are external, and that build has not gone through (either the long initial or the automatic subsequent) beta app review, the build gets put through review.

If you already have a build awaiting review, you cannot add another.

Does any of that help explain what you’re seeing?

Good Sphere
Jun 16, 2018

Small White Dragon posted:

So I re-wrote a couple of small Objective C apps in Swift, and I noticed they're substantially larger, I think primarily due to the inclusion of several swift dylibs in the IPA. Wouldn't this be something that would normally be included in the OS?

Have you got to the point of archiving it? It allows you to "strip Swift symbols" which could change the size a good amount.

Also I've noticed a significant increase in size when not considering how much of it was documents and data, much of which could be purged.

Adbot
ADBOT LOVES YOU

Good Sphere
Jun 16, 2018

pokeyman posted:

To send a build to external testers you need to go through beta app review. Typically takes a day.

Only one build for each version goes through the full review. Subsequent builds will be automatically approved in seconds.

If you try to add a group of testers to a build, and any of those testers are external, and that build has not gone through (either the long initial or the automatic subsequent) beta app review, the build gets put through review.

If you already have a build awaiting review, you cannot add another.

Does any of that help explain what you’re seeing?

Good info!

e2: Here it is! I need to wait for it to be approved, then I should be able to select it here.



Old:

e: I think you meant it will need to be long-approved for any version change, no matter if it's major or minor. If I just submitted a build with the same version number, it wouldn't take so long. However, I don't understand why I can't add a different group of testers not shown in my list on my image to the build. The message that pops up doesn't make sense; I'm trying to add a group to the build, not trying to add another build.

Each version needs to go through a full review, as in major, i.e. 1.1 to 2.0 vs 1.1 to 1.2?

This version is 1.1, and it's the second version going through an approval process, which confuses me based on what you said above. 1.0 was approved. I made some changes, and changed the version to 1.1, archived, and used the Application Loader to push it to App Store Connect, and now it seems to be going through another long approval process.

Good Sphere fucked around with this message at 21:38 on Aug 17, 2018

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply