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
Luigi Thirty
Apr 30, 2006

Emergency confection port.

Yeah, my first thought was just rendering directly to a CG bitmap. I tried something like that with GDI (decidedly not a fast API) in Windows and it ran at about 1.5fps, presumably because I was doing something wrong. I’ll try it with CG instead. On my G3 iMac I’ve got a QuickDraw program that renders a flat-shaded spinning cube at about 15fps just shoving pixels into a frame buffer.

e: Hey, look at that! I don't have the monitor running yet but I'm drawing to a CGImage from the character ROM.

Luigi Thirty fucked around with this message at 07:30 on Jul 27, 2017

Adbot
ADBOT LOVES YOU

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
Another day, another idiotic limitation of storyboards :sigh:

e: Jesus H. Christ

hackbunny fucked around with this message at 19:04 on Jul 28, 2017

Doc Block
Apr 15, 2003
Fun Shoe
I don't understand why you would want to do that, nor why anyone would think it would work. v:shobon:v

IBOutlets are to link a UI element in IB to view controller code so the code can modify it. Not to pass data from one view controller to another.

This "limitation" has nothing to do with storyboard.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Yeah, pretty sure that's operating as expected.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Yeah this is dumb. Your fault for using storyboards.

(As you’re pushed to do.)

Wonder how many apps that ship with iOS have a storyboard.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
I know you guys all make a lot of noise about how broken storyboards are, but I still use them and generally like them. They were a lot better before Xcode 8 started manipulating half of the coordinates in every storyboard file any time you open it. I'm hoping that's fixed in 9 eventually if not already.

dc3k
Feb 18, 2003

what.
If your app's flows and views are fairly simple, storyboards are fine.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

My emulator uses storyboards :ohdear:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Storyboards are great until they’re not, and then it really sucks breaking things out. My problem is I rarely guess correctly in advance whether a particular screen or part of an app will be manageable as a storyboard.

Storyboard references are great, they let you split up big storyboards without having to glue everything together with code.

Also static tables in storyboards are bad. I’m not sure I’ve ever made one that survived a week before some desired customization made things untenable.

They are fast to assemble though. Storyboards are the counterpoint to "it’s easier to tear something down than build something up".

brap
Aug 23, 2004

Grimey Drawer
Storyboards are very bad and xibs are less but still significantly bad. Write your UI in code.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

fleshweasel posted:

Storyboards are very bad and xibs are less but still significantly bad. Write your UI in code.

No

Axiem
Oct 19, 2005

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

fleshweasel posted:

Storyboards are very bad and xibs are less but still significantly bad. Write your UI in code.

Whenever I deal with storyboards or xibs I end up at this same conclusion.

Especially now with the more modern constraint-building API. A dozen lines of code or so and I have my whole UI that I can easily copy/paste/modify to suit my needs, instead of endlessly futzing around with IB.

Glimm
Jul 27, 2005

Time is only gonna pass you by

fleshweasel posted:

Storyboards are very bad and xibs are less but still significantly bad. Write your UI in code.

I drank this Kool-Aid years ago and haven't looked back. I recommend it as well.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I have this code in my ViewController's viewDidLoad method.

code:
    override func viewDidLoad() {        
        super.viewDidLoad()

        let debuggerStoryboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Debugger"), bundle: nil)
        debuggerWindowController = debuggerStoryboard.instantiateInitialController() as! DebuggerWindowController
        debuggerWindowController.showWindow(self)
        
        // Do view setup here.
        self.view.addSubview(computer.emulatorView)
        computer.emulatorView.display()
        
        self.frameTimer = Timer.scheduledTimer(timeInterval: 1/60, target: self, selector: #selector(runEmulation), userInfo: nil, repeats: true)
    }
    
    @objc func runEmulation() {
        AppleI.sharedInstance.runFrame()

/* ??? */
        computer.emulatorView.setNeedsDisplay(computer.emulatorView.frame)
        computer.emulatorView.layer!.setNeedsDisplay(computer.emulatorView.layer!.frame)
        computer.emulatorView.display()
    }
computer.emulatorView is a subclass of NSView. AppleScreenViewDelegate is a CALayerDelegate that draws the emulated screen. The problem is that the layer's draw(_ layer: CALayer, in ctx: CGContext) never gets called more than once. I invalidated the view as shown there but .display() doesn't cause it to redraw? I'm confused. I'm doing what it says in the NSView documentation.

e: I got it. I needed to setNeedsDisplay on the layer in the NSView's draw function, not outside it.

Luigi Thirty fucked around with this message at 20:46 on Jul 29, 2017

Doc Block
Apr 15, 2003
Fun Shoe
edit: never mind, I'm dumb

Doc Block fucked around with this message at 08:34 on Jul 29, 2017

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?

fleshweasel posted:

Storyboards are very bad and xibs are less but still significantly bad. Write your UI in code.

Nope.

Doctor w-rw-rw-
Jun 24, 2008

Autolayout being unpredictable in its resolutions, unpredictably slow, or over-constrained so they don't actually help when resizing the layout, but they sure are hard to debug
Xcode updating otherwise unchanged files
Complete inability to scale past a certain complexity: Xcode breaks down, startup cost.

This eventually necessitates a migration to code. The transitory period is far worse than just xib/storyboards or just code could ever be, especially if it lingers, because properties might be set any number of locations.

Designers get more value out of better, richer design tools, especially where prototyping animations is concerned; interface builder no longer cuts it and since it has to get replaced eventually anyways, it stops being a useful for anyone after a certain level of complexity. And building complex animations often requires some amount of code, and for complex views, some amount of systematizing things into specific states, which is totally unmanageable in IB.

Apple has a great SDK but that doesn't mean it doesn't have hard edges. Storyboards are a soft edge that sharpens with complexity, full stop.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
Turns out for once, the storyboard was right (or reasonable): I can't get an instance to the view controller, because the view controller has multiple instances. On the other hand:

Doc Block posted:

IBOutlets are to link a UI element in IB to view controller code so the code can modify it. Not to pass data from one view controller to another.

How then am I supposed to pass data from one view controller to another? And you're forgetting view controllers embedded with child views

Doctor w-rw-rw-
Jun 24, 2008
https://twitter.com/twolivesleft/status/889700754998542336

I don't use Xcode betas. Is this true, and if so is this a bug or is this a terrible mistake? :(

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I got the screen working on my Apple I emulator :toot: As I expected according to the profiler, converting raw 32bpp bitmap data to a CGImage 60 times a second is... suboptimal. But now that I've got the slow, dumb way working I can figure out how to do it more faster. (And I think I have some CPU bugs to fix still.) It turns out my MBA doesn't support Metal since it's got Intel HD 3000 graphics. :(

Luigi Thirty fucked around with this message at 04:01 on Jul 30, 2017

Doh004
Apr 22, 2007

Mmmmm Donuts...
We use a combination of Storyboards, NIBs and UI code.

It's amazing that we have the ability to choose what works best for a certain situation!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doh004 posted:

We use a combination of Storyboards, NIBs and UI code.

It's amazing that we have the ability to choose what works best for a certain situation!

Woah woah woah let’s not say anything too radical!

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?

Doctor w-rw-rw- posted:

https://twitter.com/twolivesleft/status/889700754998542336

I don't use Xcode betas. Is this true, and if so is this a bug or is this a terrible mistake? :(

I would assume it's just a matter of priorities (functional parity first) and if people care and file reports about it, it'll be back.

Also, you should try Xcode betas. They can coexist with release versions, letting you try them out and report any issues you run into is exactly why.

edit: Oh yeah, you realize the "poof" is a system animation that any app can use for that purpose, right?

Doh004
Apr 22, 2007

Mmmmm Donuts...

pokeyman posted:

Woah woah woah let’s not say anything too radical!

And sometimes, we'll use all 3 in a single view controller! :boom:

Doc Block
Apr 15, 2003
Fun Shoe

hackbunny posted:

How then am I supposed to pass data from one view controller to another? And you're forgetting view controllers embedded with child views

The same way you pass data from any object to another: functions, properties, KVO/KVC, or some combination thereof depending on the objects and your application. Either in your segue transition whatever code if using storyboards, or in the callback method for the button that's responsible for transitioning to a new view controller if using XIBs/code. Or the viewcontroller setup code in the case of passing data to a child view controller. Or wherever else is appropriate.

Doc Block
Apr 15, 2003
Fun Shoe

Luigi Thirty posted:

I got the screen working on my Apple I emulator :toot: As I expected according to the profiler, converting raw 32bpp bitmap data to a CGImage 60 times a second is... suboptimal. But now that I've got the slow, dumb way working I can figure out how to do it more faster. (And I think I have some CPU bugs to fix still.) It turns out my MBA doesn't support Metal since it's got Intel HD 3000 graphics. :(



Why are you converting to a CGImage? If you create a CGBitmapContext (which IIRC can be used in place of a regular CGContext), you can supply a pointer to your own memory, which you can then manipulate however you want and that will be reflected the next time the CGBitmapContext is drawn (and vice-versa: you can do Core Graphics drawing in it, and then access the pixel data to get the drawing results). Or, if you need a CGImage, you should be able to create one that uses a custom direct access data provider that just hands it a pointer to your own memory buffer, so you can update the pixels in it without having to copy (and maybe convert) the pixel data, and those changes to the pixel data will be shown the next time it's drawn.

Doc Block fucked around with this message at 09:08 on Jul 31, 2017

FAT32 SHAMER
Aug 16, 2012



Axiem posted:

UI Testing, which got a huge update in Xcode 9. The docs are here.

Hey so this is an ancient post, but I want to play with UI Testing by automating some button presses in an app like Gmail. Is there a way to do this with an already existing app that I have no source code for or am i pretty much hosed?

Kallikrates
Jul 7, 2002
Pro Lurker
I was able to use UI Test recording on an app I don't develop. Apps can't be installed to simulator via the app store so it would require a real device.

FAT32 SHAMER
Aug 16, 2012



Kallikrates posted:

I was able to use UI Test recording on an app I don't develop. Apps can't be installed to simulator via the app store so it would require a real device.

Ok cool, thanks!

Glimm
Jul 27, 2005

Time is only gonna pass you by

In the past year or so every new app my company has launched that includes IAPs has been stopped at review for not properly supporting IPv6. We test the apps using the IPv6 network setup instructions Apple provides: https://developer.apple.com/library...Transition.html

The weird thing is we never have the issue when we test it. The last 2 times we took screenshots of the settings and of us getting through the IAP screen and sent them to the resolution center and Apple has waited awhile and then approved them without sending us further information.

Is this just us? Has anyone else had this happen? I feel like we must be doing something wrong but we make no changes and Apple approves us. I think this is specific to IAPs because we have launched many apps without them and had no issues.

This only ever comes up when launching the app as well - no issues for updates.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Doc Block posted:

Why are you converting to a CGImage? If you create a CGBitmapContext (which IIRC can be used in place of a regular CGContext), you can supply a pointer to your own memory, which you can then manipulate however you want and that will be reflected the next time the CGBitmapContext is drawn (and vice-versa: you can do Core Graphics drawing in it, and then access the pixel data to get the drawing results). Or, if you need a CGImage, you should be able to create one that uses a custom direct access data provider that just hands it a pointer to your own memory buffer, so you can update the pixels in it without having to copy (and maybe convert) the pixel data, and those changes to the pixel data will be shown the next time it's drawn.

Right now I'm drawing to a sublayer of an NSView. My emulated screen is in a CVPixelBuffer containing ARGB32 pixels. If I can just shovel my pixels at my draw context with pointer magic that would work. Right now I have this:

code:
    func draw(_ layer: CALayer, in ctx: CGContext) {
        CVPixelBufferLockBaseAddress(pixels!, CVPixelBufferLockFlags.readOnly)
        let pixelBase = CVPixelBufferGetBaseAddress(pixels!)
        let pixelRef = CGDataProvider(dataInfo: nil, data: pixelBase!, size: sourceRowBytes * bufferHeight, releaseData: releaseMaskImagePixelData)
        
        renderedImage = CGImage(width: AppleIBitmapDisplay.PIXEL_WIDTH,
                                    height: AppleIBitmapDisplay.PIXEL_HEIGHT,
                                    bitsPerComponent: Int(BitmapPixelsARGB32.bitsPerComponent), //8
                                    bitsPerPixel: Int(BitmapPixelsARGB32.bitsPerPixel), //32
                                    bytesPerRow: AppleIBitmapDisplay.PIXEL_WIDTH * Int(MemoryLayout<BitmapPixelsARGB32.PixelData>.size),
                                    space: BitmapPixelsARGB32.colorSpace, //RGB
                                    bitmapInfo: bitmapInfo, //ARGB32
                                    provider: pixelRef!,
                                    decode: nil,
                                    shouldInterpolate: false,
                                    intent: CGColorRenderingIntent.defaultIntent)
        
        ctx.draw(renderedImage!, in: layer.bounds)
        
        CVPixelBufferUnlockBaseAddress(pixels!, CVPixelBufferLockFlags(rawValue: 0))
    }

Mikey-San
Nov 3, 2005

I'm Edith Head!

FAT32 SHAMER posted:

Hey so this is an ancient post, but I want to play with UI Testing by automating some button presses in an app like Gmail. Is there a way to do this with an already existing app that I have no source code for or am i pretty much hosed?

In Xcode 9, we introduced an initializer for XCUIApplication that allows you to query and control applications that are already installed on the device. You can refer to apps like Safari and Settings this way.

https://developer.apple.com/documentation/xctest/xcuiapplication/2879415-init

E.g.,

code:
XCUIApplication *safari = [[XCUIApplication alloc] initWithBundleIdentifier:@"com.apple.mobilesafari"];
[safari activate]; // or -launch, look at XCUIApplication.h to see how they differ

// this will give you a picture of how UIs look in XCTest. do not use this for actual test code.
NSString *hierarchy = safari.debugDescription;
You might find it easier to experiment with UI testing with something less complex than Gmail.

Mikey-San fucked around with this message at 21:15 on Jul 31, 2017

NoDamage
Dec 2, 2000
Xcode 9 beta 4 always locks up whenever I add a comment to the end of a line of code. It's fine if the comment is on its own line. Anyone else running into this?

Doc Block
Apr 15, 2003
Fun Shoe

Luigi Thirty posted:

Right now I'm drawing to a sublayer of an NSView. My emulated screen is in a CVPixelBuffer containing ARGB32 pixels. If I can just shovel my pixels at my draw context with pointer magic that would work. Right now I have this:

code:
    func draw(_ layer: CALayer, in ctx: CGContext) {
        CVPixelBufferLockBaseAddress(pixels!, CVPixelBufferLockFlags.readOnly)
        let pixelBase = CVPixelBufferGetBaseAddress(pixels!)
        let pixelRef = CGDataProvider(dataInfo: nil, data: pixelBase!, size: sourceRowBytes * bufferHeight, releaseData: releaseMaskImagePixelData)
        
        renderedImage = CGImage(width: AppleIBitmapDisplay.PIXEL_WIDTH,
                                    height: AppleIBitmapDisplay.PIXEL_HEIGHT,
                                    bitsPerComponent: Int(BitmapPixelsARGB32.bitsPerComponent), //8
                                    bitsPerPixel: Int(BitmapPixelsARGB32.bitsPerPixel), //32
                                    bytesPerRow: AppleIBitmapDisplay.PIXEL_WIDTH * Int(MemoryLayout<BitmapPixelsARGB32.PixelData>.size),
                                    space: BitmapPixelsARGB32.colorSpace, //RGB
                                    bitmapInfo: bitmapInfo, //ARGB32
                                    provider: pixelRef!,
                                    decode: nil,
                                    shouldInterpolate: false,
                                    intent: CGColorRenderingIntent.defaultIntent)
        
        ctx.draw(renderedImage!, in: layer.bounds)
        
        CVPixelBufferUnlockBaseAddress(pixels!, CVPixelBufferLockFlags(rawValue: 0))
    }

I made a little project that shows how to create a custom direct data provider that just supplies your own memory buffer as the data for CGImage. Then you just manipulate the pixels in the buffer and call setNeedsDisplay:YES on the view. It's in Objective-C (sorry, I don't know Swift) and the code isn't great, but it's reasonably fast and doesn't involve any copying of the pixel data beyond having to actually put it on screen (which you could probably greatly accelerate with OpenGL or Metal).

Here it is. The magic happens in DrawView and DrawViewController.

FAT32 SHAMER
Aug 16, 2012



Mikey-San posted:

In Xcode 9, we introduced an initializer for XCUIApplication that allows you to query and control applications that are already installed on the device. You can refer to apps like Safari and Settings this way.

https://developer.apple.com/documentation/xctest/xcuiapplication/2879415-init

E.g.,

code:
XCUIApplication *safari = [[XCUIApplication alloc] initWithBundleIdentifier:@"com.apple.mobilesafari"];
[safari activate]; // or -launch, look at XCUIApplication.h to see how they differ

// this will give you a picture of how UIs look in XCTest. do not use this for actual test code.
NSString *hierarchy = safari.debugDescription;
You might find it easier to experiment with UI testing with something less complex than Gmail.

Nice man, cheers!

epswing
Nov 4, 2003

Soiled Meat

Plorkyeran posted:

Xcode 6 is currently the minimum supported version for submitting to the app store, but expect that to go up to 7 in a few months when 9 comes out.

OK awesome. Is there a specified date when the minimum supported version will go up to 7? I can't seem to find this on Apple's site. When I try to follow the advice of this page to test legacy support, the Archive option under the Product menu is greyed out.

Doc Block
Apr 15, 2003
Fun Shoe
They haven't given an exact date when Xcode 9 will be released.

FAT32 SHAMER
Aug 16, 2012



The documentation for UITest is really bad

Or at least it's bad to me, a beginner

Mikey-San
Nov 3, 2005

I'm Edith Head!

FAT32 SHAMER posted:

The documentation for UITest is really bad

Or at least it's bad to me, a beginner

It's not you! We think there's a lot of room for improvement in our UI testing documentation. The class reference documentation does what it does, but one can imagine a variety of improvements that would help people go from 0 to 60 much more quickly.

There are a few WWDC sessions from the past that are worth watching:

https://developer.apple.com/videos/play/wwdc2015/406/
https://developer.apple.com/videos/play/wwdc2016/409/
https://developer.apple.com/videos/play/wwdc2017/409/

They cover a wide variety of topics at various levels of expertise, so come back to them as you get more comfortable. (The 2017 session, for example, is geared toward an audience with prior experience using XCTest for unit and UI tests.)

If you have specific questions, at any level, post 'em here and I'll do my best.

Adbot
ADBOT LOVES YOU

bumnuts
Dec 10, 2004
mmm...crunchy

Mikey-San posted:

It's not you! We think there's a lot of room for improvement in our UI testing documentation. The class reference documentation does what it does, but one can imagine a variety of improvements that would help people go from 0 to 60 much more quickly.

There are a few WWDC sessions from the past that are worth watching:

https://developer.apple.com/videos/play/wwdc2015/406/
https://developer.apple.com/videos/play/wwdc2016/409/
https://developer.apple.com/videos/play/wwdc2017/409/

They cover a wide variety of topics at various levels of expertise, so come back to them as you get more comfortable. (The 2017 session, for example, is geared toward an audience with prior experience using XCTest for unit and UI tests.)

If you have specific questions, at any level, post 'em here and I'll do my best.

Is it possible to UI test the iPad's new drag and drop across apps? I know you can activate other apps via bundle ID, so that seems like a logical next step.

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