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
Good Sphere
Jun 16, 2018

My app allows you to optionally share large photos (a UIImage), which sometimes takes time to appear in the UIActivityController for whatever app you choose to share it with. The image is fully rendered and ready beforehand, from which I use a completion handler before the UIActivityController. Is there anyway to show some kind of status activity indicator until the image appears on the UIActivityController? My problem is that if I attempt to share my large image by choosing Messenger, for example, and the image has not appeared yet, and I hit Send, it will never send.

My share function looks like this, and an image can be shared by calling the function like photo.share()

code:
extension Equatable {
	func share() {
		let activity = UIActivityViewController(activityItems: [self], applicationActivities: nil)
		
		UIApplication.topViewController?.present(activity, animated: true, completion: nil)
	}
}

Adbot
ADBOT LOVES YOU

Pulcinella
Feb 15, 2019
Does anyone know how to use custom layout groups in collection views with compositional layout? The WWDC talk mentioned that they can be used for custom layouts like radial layouts alongside horizontal and vertical layouts, but didn’t discuss how to actually do that. The sample app (which is otherwise great) also doesn’t use NSCollectionLayoutGroupCustomItem and there is basically no documentation on Apple’s website.

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

Good Sphere posted:

My app allows you to optionally share large photos (a UIImage), which sometimes takes time to appear in the UIActivityController for whatever app you choose to share it with. The image is fully rendered and ready beforehand, from which I use a completion handler before the UIActivityController. Is there anyway to show some kind of status activity indicator until the image appears on the UIActivityController? My problem is that if I attempt to share my large image by choosing Messenger, for example, and the image has not appeared yet, and I hit Send, it will never send.

My share function looks like this, and an image can be shared by calling the function like photo.share()

code:
extension Equatable {
	func share() {
		let activity = UIActivityViewController(activityItems: [self], applicationActivities: nil)
		
		UIApplication.topViewController?.present(activity, animated: true, completion: nil)
	}
}

Does UIActivityItemProvider not work for you? Pass a thumbnail image for the placeholder data. Or you can use the UIActivityItemSource if you want more control.

Good Sphere
Jun 16, 2018

Simulated posted:

Does UIActivityItemProvider not work for you? Pass a thumbnail image for the placeholder data. Or you can use the UIActivityItemSource if you want more control.

Thanks for your response. I'm not sure why I'm having such a hard time finding out how this works. An example I found for UIActivityItemProvider confuses me because I don't need a url of the image. The image is already stored as a UIImage, so can't I just share that while also providing a smaller thumbnail?

As with UIActivityItemSource, I'm not sure how it will give me more control, or that I should be even using it. According to the docs:

quote:

Because the methods of this protocol are executed on your app’s main thread, you should avoid using this protocol in cases where the data objects might take a significant amount of time to create. When creating large data objects, consider using a UIActivityItemProvider object instead.

UIActivityViewController can work by itself, but if it's a large image, I need to wait for the thumbnail to appear, depending on the app I choose to share with. Sharing to some apps, like Mail have no issue.

For instance, if I select Facebook's Messenger app to share a large image, the thumbnail appears blank:



If I don't wait for the thumbnail to appear, select a person, and hit send, a progress bar will show up top, but never complete.

I can pass what is claimed to be a thumbnail through the applicationActivities parameter, but it seems to have no effect, no matter what image I put in there when I make my own UIActivity class and override var activityImage:UIImage?

Doh004
Apr 22, 2007

Mmmmm Donuts...
I wrote some server-side Swift this weekend for the hell of it with Vapor - seems pretty decent so far but it's still quite nascent. I feel like it's a nice, good language, but it lacks the "need" to use it because there are plenty of already really good languages out there for writing services. Swift worked really well back when it was replacing Objective-C for app development but I'm already really missing all of the out of the box that Rails/DRF provide.

Doctor w-rw-rw-
Jun 24, 2008
Plus a lot of great libraries are not open-source so that kind of takes the wind out of those sails for now. But Lattner's at Google, so here's to hoping they can help make Swift less Apple-only.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Me: “hey this component is only used on Mac so I could use SwiftUI for it!”

Release notes:

quote:

Xcode 11 doesn’t support working with SwiftUI in a Mac Catalyst app.

Good Sphere
Jun 16, 2018

edit: n/m

Good Sphere fucked around with this message at 19:25 on Aug 5, 2019

Good Sphere
Jun 16, 2018

Simulated posted:

Does UIActivityItemProvider not work for you? Pass a thumbnail image for the placeholder data. Or you can use the UIActivityItemSource if you want more control.

After taking some time to try to understand how to set the placeholder data, and had no differences in making the thumbnail appear quickly. It looks like it's still generating a thumbnail from the high quality image. Maybe I'm not doing it correctly?

My subclassed UIActivityItemProvider:

code:
class CustomProvider : UIActivityItemProvider {

    var image : UIImage!

    init(placeholderItem: AnyObject, image : UIImage) {
        super.init(placeholderItem: placeholderItem)
        self.image = image
    }

    override var item: Any {
        return self.image!
    }
}
I have a share function that is an extension. I create a thumbnail image and pass it to the placeholderItem in the CustomProvider function:

code:
extension Equatable {
    func share() {

        let imageData = (self as! UIImage).pngData()!
        let options = [
            kCGImageSourceCreateThumbnailWithTransform: true,
            kCGImageSourceCreateThumbnailFromImageAlways: true,
            kCGImageSourceThumbnailMaxPixelSize: 300] as CFDictionary
        let source = CGImageSourceCreateWithData(imageData as CFData, nil)!
        let imageReference = CGImageSourceCreateThumbnailAtIndex(source, 0, options)!
        let thumbnail = UIImage(cgImage: imageReference)


        let firstActivityItem = CustomProvider(placeholderItem: thumbnail, image: self as! UIImage)

        let activity = UIActivityViewController(activityItems: [firstActivityItem], applicationActivities: nil)

        UIApplication.topViewController?.present(activity, animated: true, completion: nil)
    }
}

Star War Sex Parrot
Oct 2, 2003

Can anyone running a Catalina beta tell me if C++17’s std::aligned_alloc is supported, pretty please?

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?
it’s not the OS that supports it, it’s the C++ standard library

so just download the latest Xcode 11 beta and check :)

Star War Sex Parrot
Oct 2, 2003

eschaton posted:

it’s not the OS that supports it, it’s the C++ standard library

so just download the latest Xcode 11 beta and check :)
Based on discussion last week...

Plorkyeran posted:

The libc++ runtime library is shipped with the OS so everything that isn't purely header-only requires new OS versions. Supporting new language features on older OSes seems to not be a priority at all for Apple, as Swift is now doing the same thing.
...I figured it would be a Catalina change, not Xcode.

Pulcinella
Feb 15, 2019

Star War Sex Parrot posted:

Based on discussion last week...

...I figured it would be a Catalina change, not Xcode.

I do wish that at least the Swift 5.1 standard library was the one that would get bundled with older OS versions rather than 5.0. We have to support the current iOS release and previous ( and some projects require even X-2 or more ). It would have been nice to use Ordered Collection Diffing as a substitute for Diffable Data Sources on older OS versions.

Also I’ve done some more experimenting with compositional layouts and it seems that with NSCollectionLayoutGroupCustomItem you have to set all frames yourself. So it’s custom layout but in a very limiting way. You just pass in a CGRect so I don’t even think you can rotate them. I still need to see if the regular layout methods (e.g layoutAttributesForItem(at:)) work with compositional layouts.

Pulcinella fucked around with this message at 16:14 on Aug 10, 2019

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Star War Sex Parrot posted:

Based on discussion last week...

...I figured it would be a Catalina change, not Xcode.

In this specific case it’s a C11 thing that got pulled into C++17. macOS has had a C11 standard library for a long time, so the only change needed is to expose it in c++ mode. Since that’s purely a header thing, it should just be the Xcode version that matters.

duck monster
Dec 15, 2004

This whole "Your app can't know the wifi SSID" thing in IOS 13 is going to really gently caress us at work. Our app is for flashing bios on our IOT controllers and part of it involves scanning SSIDs looking for it when out of the box. We're kind of scratching our heads wondering how to proceed on this one. Theres one alternative that has the device start its own WIFI hotspot, unfortunately some fuckhead put a patent on "IOT device has its own hotspot". because clearly thats a novel idea :rolleyes:

Is there a way to contact apple and get clarification on the change and what the exceptions (apparently VPN apps might) will be?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

duck monster posted:

This whole "Your app can't know the wifi SSID" thing in IOS 13 is going to really gently caress us at work. Our app is for flashing bios on our IOT controllers and part of it involves scanning SSIDs looking for it when out of the box. We're kind of scratching our heads wondering how to proceed on this one. Theres one alternative that has the device start its own WIFI hotspot, unfortunately some fuckhead put a patent on "IOT device has its own hotspot". because clearly thats a novel idea :rolleyes:

Is there a way to contact apple and get clarification on the change and what the exceptions (apparently VPN apps might) will be?

Does this help?

quote:

The first step is in Xcode you have to add the capability to access Wi-Fi information to add the entitlement to your project, and then your app must meet one of three other criteria.

If the user has given your app location access, then you can access the Wi-Fi network information.

If your app is the currently enabled VPN app on the device, you can access the information.

And finally, if your app is in any hotspot configuration app, then it can also access the information but only for the networks that it has configured.

From https://asciiwwdc.com/2019/sessions/713

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<
Sometimes if I'm going through 2FA and I'm prompted to enter a PIN, the ios keyboard will suggest the number I just got in a text, like this:



Which is cool. Is there a name for what's causing this prompt/suggest? I'm trying to learn more about it and what I can do with it. For example I only know of it working through the Messages app, and I wonder if suggestions can come from a non-ios app, or the clipboard.

dc3k
Feb 18, 2003

what.
https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view

You can hook it up to a password management app, but I’m pretty sure the 2FA code bit is only supported via messages.

Zeluth
May 12, 2001

by Fluffdaddy
I just want batteries.

duck monster
Dec 15, 2004

jackpot posted:

Sometimes if I'm going through 2FA and I'm prompted to enter a PIN, the ios keyboard will suggest the number I just got in a text, like this:



Which is cool. Is there a name for what's causing this prompt/suggest? I'm trying to learn more about it and what I can do with it. For example I only know of it working through the Messages app, and I wonder if suggestions can come from a non-ios app, or the clipboard.

I noticed recently some of our devices offering to put wifi passwords into other text boxes. Not sure if this is "user did a stupid" or "device is doing a stupid" on this one yet. But if its device stupid, its a goddamn horrible security leak

Good Sphere
Jun 16, 2018

How can you rewrite EXIF data on videos in Swift? I probably posted about this at least one other time, but it's still haunting me, after two years.

I recently commented out code that I thought was causing the problem of videos being flipped upside down when sent from my iPhone app to Facebook or Messenger, but it turns out I needed it for selfie videos to be correctly horizontally flipped :doh:

code:
let assetWriterVideoInput = AVAssetWriterInput(mediaType: AVMediaType.video, outputSettings: videoSettings)

if isFrontCamera {

	var transform: CGAffineTransform = .identity

	if selectedInterfaceOrientation == interfaceOrientations.portrait ||
            selectedInterfaceOrientation == interfaceOrientations.portraitUpsideDown {
		transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
	}
	else if selectedInterfaceOrientation == interfaceOrientations.landscapeLeft ||
                    selectedInterfaceOrientation == interfaceOrientations.landscapeRight {
		transform = CGAffineTransform(scaleX: 1.0, y: -1.0)
	}

	assetWriterVideoInput.transform = transform
}
Inspecting the front camera video vs the back camera video with EXIFTool, I found that the only difference is:

- front-facing videos that were flipped with the code above will change the "Matrix Structure" attribute with "0 -1 0 -1 0 0 -1280 0 1"
- back-facing videos untouched will have a "Matrix Structure" attribute of "0 -1 0 1 0 0 1280 0 1"

The "rotation" attribute is the same between both videos. This means some applications depend on the rotation attribute for playback/encoding and some depend on the Matrix Structure. Applying a transform on AVAssetWriterInput does not alter the "Matrix Structure" attribute, so for the love of god, I need to do overwrite this with my own custom value!

But at least when I'm finished making an AVMutableComposition with the AVAsset, there is no metadata I can find:

code:
var metadataAttachments: [AVMetadataItem] = mixComposition.metadata
		
for md in metadataAttachments {
	print(md) // never gets here
} 
I wanted to inspect that first so I can actually understand the metadata, and maybe see what the attributes are called so I can write the correct one.

Good Sphere fucked around with this message at 23:13 on Sep 3, 2019

lord funk
Feb 16, 2004

Think this is an Xcode problem more than a Git one, so posting here.

Why does Xcode have two source controls even though I only have one? I have a Github origin, and pushing to both of them updates the origin, but only one gets updated within Xcode.

Anyone run into this? Fixes?

Only registered members can see post attachments!

Stringent
Dec 22, 2004


image text goes here
Dunno if this constitutes a solution, but I've always just done all my source control stuff with the cli. The Xcode interface scares me.

dc3k
Feb 18, 2003

what.

Stringent posted:

Dunno if this constitutes a solution, but I've always just done all my source control stuff with the cli. The Xcode interface scares me.

This + GitUp if I want to do stuff like splitting a big rear end WIP commit into reasonable commits

brap
Aug 23, 2004

Grimey Drawer
How many remotes do you have?

lord funk
Feb 16, 2004

Just the one. I tried just deleting .git from my project folder, but one of the repositories still remains. My theory is that somewhere buried in a subfolder is another local .git repo...

fankey
Aug 31, 2001

I have an app that works fine in the emulator, fine on my device connected to XCode but fails when running the exact same codebase via TestFlight. Is there a way to reproduce what is being run via TestFlight without going throught the whole cycle of uploading the app, etc? The app draws a bunch of stuff via CoreGraphics and in this case fail means doesn't draw all the elements.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Sounds like something is getting cut out when compiling in release mode. Those are tough bugs.

Glimm
Jul 27, 2005

Time is only gonna pass you by

fankey posted:

I have an app that works fine in the emulator, fine on my device connected to XCode but fails when running the exact same codebase via TestFlight. Is there a way to reproduce what is being run via TestFlight without going throught the whole cycle of uploading the app, etc? The app draws a bunch of stuff via CoreGraphics and in this case fail means doesn't draw all the elements.

Switching the build configuration in your scheme to your production config might help.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

lord funk posted:

Just the one. I tried just deleting .git from my project folder, but one of the repositories still remains. My theory is that somewhere buried in a subfolder is another local .git repo...

find path/to/project -name .git

fankey
Aug 31, 2001

Glimm posted:

Switching the build configuration in your scheme to your production config might help.

That worked - I can now reproduce bad behavior in the simulator. Now the problem is I have no idea what's going on. It's probably something obvious but here's my code.
code:
        // defined elsewhere
        // float pad
        // int ix
        // CGRect rc
        // float size

        NSLog(@"draw pad %f or.y %f ix %i sz %f", pad, rc.origin.y, ix, size);
        float y = rc.origin.y + ix*(size+pad);
        NSLog(@"draw y %f", y);
prints
code:
draw pad 0.517500 or.y 0.000000 ix 6 sz 9.297188
draw y nan
How does adding and multiplying valid numbers result in a nan?

lord funk
Feb 16, 2004

rjmccall posted:

find path/to/project -name .git

This worked. There were no more .git projects in the folder, but it was including one that was a directory next to the containing directory of the project. ✅

fankey
Aug 31, 2001

Digging into this more, this code
code:
        NSLog(@"pad %f : 0x%08x", pad, *((uint32_t*)(&pad)));
        NSLog(@"rc.origin.y %f : 0x%08x", rc.origin.y, *((uint32_t*)(&rc.origin.y)));
        NSLog(@"size %f : 0x%08x", size, *((uint32_t*)(&size)));
        float y = rc.origin.y + ix*(size+pad);
        NSLog(@"y %f : 0x%08x", y, *((uint32_t*)(&y)));
produces
code:
pad 0.517500 : 0x3f047ae1
rc.origin.y 0.000000 : 0xfd802000
size 9.297188 : 0x4114c148
y nan : 0x7fc00000
rc.origin.y isn't actually zero but a really small negative number ( -2.1288417E37 ). Is this and underflow case that is triggering a NAN? If so, is there a way to disable underflow checks? I tried casting everything to doubles but it appeared to have the same behavior.

Doc Block
Apr 15, 2003
Fun Shoe
It’d probably be a good idea to clamp some of those values to sane ranges before doing any math on them, like maybe not allowing sizes smaller than 1 or something.

edit: also, you're mixing doubles, floats, and integers. There's bound to be an unintended precision problem because of this.

rc.origin.y is a CGFloat, which is typedef'ed to double on 64-bit platforms, not float. So your cast would need to be to a uint64_t, and your format string needs %016llx

edit 2: using your supplied values, I can't get your results, even compiling with -O3 and -ffast-math

edit 3: even plugging in your hex NaN value for Y, printf() shows 2143289344.0

set a breakpoint somewhere in there and see where the NaN is coming from; they're like viruses, and will "infect" all downstream math.

Doc Block fucked around with this message at 19:02 on Sep 6, 2019

fankey
Aug 31, 2001

Doc Block posted:

It’d probably be a good idea to clamp some of those values to sane ranges before doing any math on them, like maybe not allowing sizes smaller than 1 or something.

edit: also, you're mixing doubles, floats, and integers. There's bound to be an unintended precision problem because of this.

rc.origin.y is a CGFloat, which is typedef'ed to double on 64-bit platforms, not float. So your cast would need to be to a uint64_t, and your format string needs %016llx

edit 2: using your supplied values, I can't get your results, even compiling with -O3 and -ffast-math

edit 3: even plugging in your hex NaN value for Y, printf() shows 2143289344.0

set a breakpoint somewhere in there and see where the NaN is coming from; they're like viruses, and will "infect" all downstream math.
Figured out the problem - I'm an idiot and rc was uninitialized so in release mode it was a NaN. Printing out the CGFloat as a uint64 made it obvious. On the plus side I learned more about floating point binary formats...

lord funk
Feb 16, 2004

What do you all use for crash reporting? I'm re-integrating Crashlytics, but don't really like having to go through all the Google Firebase stuff to do it. Is there a more lightweight option out there that's good?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I’m riding the non-Firebase Crashlytics train into the sunset, then I’ll probably just rip it out and scavenge on App Store Connect.

lord funk
Feb 16, 2004

Yeah, I really don't like that we went from Crashlytics >> Fabric >> Firebase ANALYTICS TRENDS A/B TESTING BUSINESS GROWTH

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
AppCenter crash reporting might be decent by then, if that’s more palatable than Firebase.

Adbot
ADBOT LOVES YOU

Good Sphere
Jun 16, 2018

Is there any way to make Xcode's breakpoints work consistently? I'm getting to the point of building my project up to 5 times before breakpoints actually work.

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