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
chaosbreather
Dec 9, 2001

Wry and wise,
but also very sexual.

Yo, am I missing something obvious here? I'm trying to make a SwiftUI wrapper for an NSView and it's driving me crazy.

Swift code:
struct HexView: NSViewRepresentable {
    typealias NSViewType = NSTextView
    
    var data: Data

    func makeNSView(context: Context) -> HFTextView {
        let view = HFTextView()
        view.data = data
        return view
    }
    
    func updateNSView(_ nsView: HFTextView, context: Context) {
        nsView.data = data
    }
}
It gets me these errors:
Type 'HexView' does not conform to protocol 'NSViewRepresentable'
Candidate has non-matching type '(Context) -> HFTextView' [with Coordinator = Void]
Candidate has non-matching type '(HFTextView, Context) -> ()' [with Coordinator = Void]

I tried swapping out HFTextView with NSTextView in case it was the view and I'm getting the same error. Copying and pasting example code gets the same error. It's got to be something fundamental or obvious but I am just not seeing it. I'm using Swift 5, Xcode 13.3, building for Mac.

edit: if I copy the minimal solution with NSTextView to a playground it runs fine. If I remove the : NSViewRepresentable it compiles fine. WTH is going on?

chaosbreather fucked around with this message at 07:39 on Mar 30, 2022

Adbot
ADBOT LOVES YOU

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull

Lady Radia posted:

i dunno about all that, that's a nice story but steve jobs is also famous for "your holding it wrong", "your jeans are too tight", so

You know that whole "land of contrasts" meme? I have met several people who worked directly with Steve Jobs in my career, and based on the tales I've heard I think "land of contrasts" was invented to describe Steve Jobs.

haveblue
Aug 15, 2005



Toilet Rascal
Close, but it's actually the word "mercurial"

brand engager
Mar 23, 2011

chaosbreather posted:

Yo, am I missing something obvious here? I'm trying to make a SwiftUI wrapper for an NSView and it's driving me crazy.

Swift code:
struct HexView: NSViewRepresentable {
    typealias NSViewType = NSTextView
    
    var data: Data

    func makeNSView(context: Context) -> HFTextView {
        let view = HFTextView()
        view.data = data
        return view
    }
    
    func updateNSView(_ nsView: HFTextView, context: Context) {
        nsView.data = data
    }
}
It gets me these errors:
Type 'HexView' does not conform to protocol 'NSViewRepresentable'
Candidate has non-matching type '(Context) -> HFTextView' [with Coordinator = Void]
Candidate has non-matching type '(HFTextView, Context) -> ()' [with Coordinator = Void]

I tried swapping out HFTextView with NSTextView in case it was the view and I'm getting the same error. Copying and pasting example code gets the same error. It's got to be something fundamental or obvious but I am just not seeing it. I'm using Swift 5, Xcode 13.3, building for Mac.

edit: if I copy the minimal solution with NSTextView to a playground it runs fine. If I remove the : NSViewRepresentable it compiles fine. WTH is going on?

Your typealias doesn't match what you're using in the rest of the struct, if your NSViewType is NSTextView then makeNSView and updateNSView must also use NSTextView

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Or delete the typealias and see if it can be inferred?

KidDynamite
Feb 11, 2005

does nsviewrepresentable need a coordinator like uiviewrepresentable as well?

brand engager
Mar 23, 2011

It provides a default Void coordinator if you aren't using one

chaosbreather
Dec 9, 2001

Wry and wise,
but also very sexual.

brand engager posted:

Your typealias doesn't match what you're using in the rest of the struct, if your NSViewType is NSTextView then makeNSView and updateNSView must also use NSTextView

Oh right, sorry, that was half actual code and half sanity test. Here's the sanity test:

Swift code:
import SwiftUI
import Cocoa

struct TestView: NSViewRepresentable {
    func makeNSView(context: Context) -> NSTextView {
        NSTextView()
    }
    
    func updateNSView(_ nsView: NSTextView, context: Context) {
    }
    
    typealias NSViewType = NSTextView
    
    
}
This runs fine in a playground, in a new Multiplatform app when compiling on the mac, or a new Mac app project, but not my current project. I guess I have to start a new project but it was so much fiddling to get this stupid framework to compile.

pokeyman posted:

Or delete the typealias and see if it can be inferred?

Yeah this is super interesting too – in my project it can't be inferred, but in new projects/playgrounds it can.

Boy I wish that I didn't keep running into these 'everything's hosed' scenarios in apple dev

chaosbreather fucked around with this message at 00:46 on Mar 31, 2022

Glimm
Jul 27, 2005

Time is only gonna pass you by

Has anyone run into an issue where an ipa created in CI has proper entitlements (e.g., push notifications) - validated by unzipping the ipa and inspecting it - but after uploading to the AppStore (TestFlight) the entitlements are gone?

We are moving from GitLab CI (and self-hosted runners) to Azure DevOps (MS runners) and for some reason, our builds in TestFlight no longer have push capability (or any entitlements). It's strange because we're able to download the ipa we create, unzip it, and can see the provisioning looks correct.

We use this Azure Extension to do the upload: https://marketplace.visualstudio.com/items?itemName=ms-vsclient.app-store which looks like it uses Fastlane, maybe folks have seen this with Fastlane, too.

Would this be worth a TSI? I've never really used it but I'm pretty lost on what to try next.

Glimm fucked around with this message at 02:21 on Apr 1, 2022

brand engager
Mar 23, 2011

chaosbreather posted:

Oh right, sorry, that was half actual code and half sanity test. Here's the sanity test:

Swift code:
import SwiftUI
import Cocoa

struct TestView: NSViewRepresentable {
    func makeNSView(context: Context) -> NSTextView {
        NSTextView()
    }
    
    func updateNSView(_ nsView: NSTextView, context: Context) {
    }
    
    typealias NSViewType = NSTextView
    
    
}
This runs fine in a playground, in a new Multiplatform app when compiling on the mac, or a new Mac app project, but not my current project. I guess I have to start a new project but it was so much fiddling to get this stupid framework to compile.

Yeah this is super interesting too – in my project it can't be inferred, but in new projects/playgrounds it can.

Boy I wish that I didn't keep running into these 'everything's hosed' scenarios in apple dev

If that exact code works everywhere but your existing project then it's probably something with the build config/extensions/etc

fankey
Aug 31, 2001

Any idea what Project setting would break using c++ 14 features in .mm files? I have a project that has a .mm file which then includes a .h file with the following
code:
#ifndef Test_h
#define Test_h
template<typename T>
constexpr auto enum_flag2(const T n) { return 1 << n; }

enum control_direction2_e {
  foo = 0
  bar = enum_flag2(0),
};

#endif /* Test_h */
And when compiles errors out with
code:
Test.h:12:11: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
constexpr auto enum_flag2(const T n) { return 1 << n; }
          ^
XXX/Test.h:15:10: error: missing ',' between enumerators
  foo = 0
         ^
         , 
XXX/Test.h:16:9: error: no matching function for call to 'enum_flag2'
  bar = enum_flag2(0),
        ^~~~~~~~~~
3 errors generated.
I have set the C++ Language Dialect to GNU++17 and if I include the file in a .cpp file it compiles without any issue. If I create a brand new Project things work correctly as well so I'm guessing that the issue is related to a specific Project setting. This particular Project has been drug through various versions of Xcode ( likely since the iPad was first released or so ) and it has a bunch of settings that don't exist in the brand new project, though none of the settings seem particularly suspicious.

Working Project :


Broken Project :

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
No idea but have some uninformed flailing: is the header ever included or imported in a non-c++ context (don't forget about bridging headers)? Does renaming it to .hpp change anything?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
These investigations should always start by looking at the build log to find the command line that leads to the error. Then you can figure out why the command line isn’t what you expect.

fankey
Aug 31, 2001

Changing to .hpp didn't help. As far as I can tell the command line looks correct - both are specifying -std\=gnu++1z. For testing I added a new .h and .mm file that aren't referenced anywhere else so the header is only included in this single .mm file.

Here's the good build
code:
CompileC /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/x86_64/CppWrap.o /Users/XXXXXX/TestApp/TestApp/TestApp/CppWrap.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'TestApp' from project 'TestApp')
    cd /Users/XXXXXX/TestApp/TestApp
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
    -x objective-c++ 
    -target x86_64-apple-ios15.4-simulator 
    -fmessage-length\=0 
    -fdiagnostics-show-note-include-stack 
    -fmacro-backtrace-limit\=0 
    -std\=gnu++1z 
    -fobjc-arc 
    -fobjc-weak 
    -fmodules 
    -gmodules 
    -fmodules-cache-path\=/Users/XXXXXX/Library/Developer/Xcode/DerivedData/ModuleCache.noindex 
    -fmodules-prune-interval\=86400 
    -fmodules-prune-after\=345600 
    -fbuild-session-file\=/Users/XXXXXX/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation 
    -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module 
    -Werror\=non-modular-include-in-framework-module 
    -Wno-trigraphs 
    -fpascal-strings 
    -O0 
    -fno-common 
    -Wno-missing-field-initializers 
    -Wno-missing-prototypes 
    -Werror\=return-type 
    -Wdocumentation 
    -Wunreachable-code 
    -Wquoted-include-in-framework-header 
    -Wno-implicit-atomic-properties 
    -Werror\=deprecated-objc-isa-usage 
    -Wno-objc-interface-ivars 
    -Werror\=objc-root-class 
    -Wno-arc-repeated-use-of-weak 
    -Wimplicit-retain-self 
    -Wno-non-virtual-dtor 
    -Wno-overloaded-virtual 
    -Wno-exit-time-destructors 
    -Wduplicate-method-match 
    -Wno-missing-braces 
    -Wparentheses 
    -Wswitch 
    -Wunused-function 
    -Wno-unused-label 
    -Wno-unused-parameter 
    -Wunused-variable 
    -Wunused-value 
    -Wempty-body 
    -Wuninitialized 
    -Wconditional-uninitialized 
    -Wno-unknown-pragmas 
    -Wno-shadow 
    -Wno-four-char-constants 
    -Wno-conversion 
    -Wconstant-conversion 
    -Wint-conversion 
    -Wbool-conversion 
    -Wenum-conversion 
    -Wno-float-conversion 
    -Wnon-literal-null-conversion 
    -Wobjc-literal-conversion 
    -Wshorten-64-to-32 
    -Wno-newline-eof 
    -Wno-selector 
    -Wno-strict-selector-match 
    -Wundeclared-selector 
    -Wdeprecated-implementations 
    -Wno-c++11-extensions 
    -DDEBUG\=1 
    -DOBJC_OLD_DISPATCH_PROTOTYPES\=0 
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk 
    -fasm-blocks 
    -fstrict-aliasing 
    -Wprotocol 
    -Wdeprecated-declarations 
    -Winvalid-offsetof 
    -g 
    -fvisibility-inlines-hidden 
    -Wno-sign-conversion 
    -Winfinite-recursion 
    -Wmove 
    -Wcomma 
    -Wblock-capture-autoreleasing 
    -Wstrict-prototypes 
    -Wrange-loop-analysis 
    -Wno-semicolon-before-method-body 
    -Wunguarded-availability 
    -fobjc-abi-version\=2 
    -fobjc-legacy-dispatch 
    -index-store-path /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Index/DataStore 
    -iquote /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/TestApp-generated-files.hmap 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/TestApp-own-target-headers.hmap 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/TestApp-all-target-headers.hmap 
    -iquote /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/TestApp-project-headers.hmap 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Products/Debug-iphonesimulator/include 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/DerivedSources-normal/x86_64 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/DerivedSources/x86_64 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/DerivedSources 
    -F/Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Products/Debug-iphonesimulator 
    -MMD 
    -MT dependencies 
    -MF /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/x86_64/CppWrap.d --serialize-diagnostics /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/x86_64/CppWrap.dia -c /Users/XXXXXX/TestApp/TestApp/TestApp/CppWrap.mm -o /Users/XXXXXX/Library/Developer/Xcode/DerivedData/TestApp-hgfiuoofzaxvlkgeuwokrndcoitb/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/x86_64/CppWrap.o -index-unit-output-path /TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/x86_64/CppWrap.o
and the bad
code:
CompileC /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/Objects-normal/x86_64/Test.o /Users/XXXXXX/XXXXXX/software/Apple/XXXXXX\ UCI/Util/Test.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'XXXXXX Controller' from project 'XXXXXX UCI')
    cd /Users/XXXXXX/XXXXXX/software/Apple/XXXXXX\ UCI
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
    -x objective-c++
    -target x86_64-apple-ios12.0-simulator 
    -fmessage-length\=0 
    -fdiagnostics-show-note-include-stack
    -fmacro-backtrace-limit\=0 
    -std\=gnu++1z 
    -fobjc-arc 
    -gmodules 
    -Wno-trigraphs 
    -fpascal-strings 
    -O0 
    -fno-common 
    -Wno-missing-field-initializers 
    -Wno-missing-prototypes 
    -Wunreachable-code 
    -Wno-implicit-atomic-properties 
    -Wno-objc-interface-ivars 
    -Wno-arc-repeated-use-of-weak 
    -Wimplicit-retain-self 
    -Wno-non-virtual-dtor 
    -Wno-overloaded-virtual 
    -Wno-exit-time-destructors 
    -Wduplicate-method-match 
    -Wno-missing-braces 
    -Wparentheses 
    -Wswitch 
    -Wunused-function 
    -Wno-unused-label 
    -Wno-unused-parameter 
    -Wunused-variable 
    -Wunused-value 
    -Wempty-body 
    -Wuninitialized 
    -Wno-unknown-pragmas 
    -Wno-shadow 
    -Wno-four-char-constants 
    -Wno-conversion 
    -Wconstant-conversion 
    -Wint-conversion 
    -Wbool-conversion 
    -Wenum-conversion 
    -Wno-float-conversion 
    -Wnon-literal-null-conversion 
    -Wobjc-literal-conversion 
    -Wshorten-64-to-32 
    -Wno-newline-eof 
    -Wno-selector 
    -Wno-strict-selector-match 
    -Wundeclared-selector 
    -Wdeprecated-implementations 
    -Wno-c++11-extensions 
    -DOBJC_OLD_DISPATCH_PROTOTYPES\=0 
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk
    -fasm-blocks 
    -fstrict-aliasing 
    -Wprotocol 
    -Wdeprecated-declarations 
    -Winvalid-offsetof 
    -g 
    -fvisibility-inlines-hidden 
    -Wno-sign-conversion 
    -Winfinite-recursion 
    -Wmove 
    -Wcomma 
    -Wblock-capture-autoreleasing 
    -Wstrict-prototypes 
    -Wrange-loop-analysis 
    -Wno-semicolon-before-method-body 
    -fobjc-abi-version\=2 
    -fobjc-legacy-dispatch 
    -index-store-path /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Index/DataStore 
    -iquote /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/XXXXXX\ UCI-generated-files.hmap 
    -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/XXXXXX\ UCI-own-target-headers.hmap -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/XXXXXX\ UCI-all-target-headers.hmap -iquote /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/XXXXXX\ UCI-project-headers.hmap -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Products/Debug-iphonesimulator/include -I../../target -I../../libs -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk/usr/include/libxml2 -I../../3rdparty/ANTLR4-runtime/src -I../../libs/css_lib/src -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/DerivedSources-normal/x86_64 -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/DerivedSources/x86_64 -I/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/DerivedSources -F/Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Products/Debug-iphonesimulator -F/Users/XXXXXX/XXXXXX/software/Apple/XXXXXX\ UCI -F/Users/XXXXXX/XXXXXX/software/Apple/XXXXXX\ UCI/Carthage/Build/iOS -std\=c++0x -include /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/PrecompiledHeaders/SharedPrecompiledHeaders/647469697939819622/XXXXXX_UCI_Prefix.pch 
    -MMD 
    -MT dependencies 
    -MF /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/Objects-normal/x86_64/Test.d --serialize-diagnostics /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/Objects-normal/x86_64/Test.dia -c /Users/XXXXXX/XXXXXX/software/Apple/XXXXXX\ UCI/Util/Test.mm -o /Users/XXXXXX/Library/Developer/Xcode/DerivedData/XXXXXX_UCI-egshcztqxjcvajccurikbgmmndvq/Build/Intermediates.noindex/XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/Objects-normal/x86_64/Test.o -index-unit-output-path /XXXXXX\ UCI.build/Debug-iphonesimulator/XXXXXX\ Controller.build/Objects-normal/x86_64/Test.o

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
code:
-std\=c++0x

fankey
Aug 31, 2001

rjmccall posted:

code:
-std\=c++0x

Well I feel dumb. I think I added that flag way back when Xcode didn't have it as a direct configuration. Thanks!

former glory
Jul 11, 2011

I've cranked out a few throwaway projects and a releasable one in Swift in the past few months. In the process, I've gone from being annoyed by how differently SwiftUI works from anything I've done in the past (mainly winforms), to wondering how I can ever write another GUI that isn't done with viewbuilders. It's so clean and quick to chain all these read-only views and have them adapt to the model dynamically. It has me wondering: are there other user interface frameworks out there that behave the same way? Not necessarily for mobile, but as a multiplatform library spanning win/macos/linux? How about for the web?

I looked around to see if Swift is multiplatform, but it seems only the core language is there and UI is still very experimental.

former glory
Jul 11, 2011

Huh, what a coincidence, I just saw a comment on HN about a Rust implementation of a SwitfUI-like in its early days here:

https://github.com/audulus/rui

take boat
Jul 8, 2006
boat: TAKEN
I've never used it, but if you want to stay with Swift, you can check out https://github.com/TokamakUI/Tokamak

outside of Swift, Flutter has a similar declarative UI model and some degree of support for desktop apps, as well as enough corporate backing to tackle things like accessibility

you can also try React + React Native (not the same thing, though you can share much of your app between the two). I don't think there's real support for Linux with React Native but Microsoft is supporting Windows and macOS

if you do end up using any of these, I'm curious how you find it

Vesi
Jan 12, 2005

pikachu looking at?
"everyone" is using declarative style for UIs now, flutter, react, jetpack compose, qt qml

former glory
Jul 11, 2011

Thank you both-- that helped me go down a few avenues. I didn't realize so many declarative frameworks had popped up.

Froist
Jun 6, 2004

Vesi posted:

"everyone" is using declarative style for UIs now, flutter, react, jetpack compose, qt qml

I don’t want to make a baseless claim without doing my research so I won’t say it was the first, but QML was surely one of the early ones. I worked on the framework itself way back in my career - dates get fuzzy at this point but wiki says it launched in 2009 which feels about right.

Nokia doomed their own platform for many unrelated reasons, but it’s odd to see so much of the industry latch onto the declarative idea half-to-a decade later.

Evis
Feb 28, 2007
Flying Spaghetti Monster

Froist posted:

it’s odd to see so much of the industry latch onto the declarative idea half-to-a decade later.

Is declarative easier to work with for complex UIs or easier to learn? I’ve only ever really tinkered with UI to hack together something until fairly recently, but the declarative style seems far easier to work with.

uncle blog
Nov 18, 2012

I'm working on an app that uses CoreLocation to calculate the distance between the phone and various locations.

code:
// LocationManager class

@Published var distanceToPlace: CLLocationDistance = 1000
   
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
	lastSeenLocation = locations.first
}
   
private var lastSeenLocation: CLLocation? {
	didSet {
        	if let distance = lastSeenLocation?.distance(from: CLLocation(latitude: selectedPlace.latitude, longitude: selectedPlace.longitude)) {
            		self.distanceToPlace = distance
		}	
 	}
}
The latitude and longitude are Doubles taken directly from the lon and lat found in the URL of Google Maps representing the specified location. But for some reason - in practice - each place is positioned about 150 meters away from the actual spot. In other words, if I go to the actual spot, the app tells me I'm still about 150 meters away.

Any idea why this is? Do the coordinates need to be formatted or converted for some reason?

Stringent
Dec 22, 2004


image text goes here
have you set the desiredAccuracy on the location manager?

https://developer.apple.com/documentation/corelocation/cllocationmanager/1423836-desiredaccuracy

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?

Vesi posted:

"everyone" is using declarative style for UIs now, flutter, react, jetpack compose, qt qml

You know what’s really declarative?

Deserializing a pre-configured object graph!

uncle blog
Nov 18, 2012

Thanks for the tips. I managed to find other coordinates which seemed much more accurate in actual use.


About to get a new Mac from work. Going to be a Pro with M1-something. How important are the gpu cores when running live previews in SwiftUI? My current one is rear end slow. And what other specs should I aim for on a machine made to develop both iOS and web, and often running some Docker containers/local dev env, and maybe the occasional game?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

uncle blog posted:

About to get a new Mac from work. Going to be a Pro with M1-something. How important are the gpu cores when running live previews in SwiftUI? My current one is rear end slow. And what other specs should I aim for on a machine made to develop both iOS and web, and often running some Docker containers/local dev env, and maybe the occasional game?

I haven't done any research or anything, but my answers are: gpu cores won't make any noticeable difference; more memory is maybe better otherwise no noticeable difference.

Data Graham
Dec 28, 2009

📈📊🍪😋



This is a super long shot but — any chance that any wizard goon Mac developers have the ability to do anything with this?

https://github.com/cocoahuke/shrink_trackpad

It's a kext utility to mask off a selected part of the trackpad so you don't constantly trigger gestures because your palm is resting on the edge of the unnecessarily enormous trackpad. It's the only thing about my M1 Pro MBP that drives me absolutely bugfuck.

However it only works on Intel and won't build under Monterey. The developer says:

quote:

This project does not support M1 macs because M1 equipped something called "Kernel Integrity Protection" prevents kernel code from been modifying, you can not disable that, it's a lower level stuff than SIP. Injecting code into the multitouch driver is critical for this project to function properly.

One possible solution is to rebuild the entire multitouch driver, and load this custom driver instead of the OEM one. but that's a hell of work to do cuz I don't have the multi touch driver source code.

The ideal outcome would be if Apple would somehow add the ability to do this masking-off in the OS itself, but I don't know of any way to bribe or prevail upon any actual Apple devs to do this. So the next best thing would be if anyone had some idea to possibly make this tool work on modern hardware/software.

Fallback would be to tape some aluminum foil or felt or something over the left 1" of the trackpad but gently caress that if there's any way to avoid it.

Pulcinella
Feb 15, 2019
Probation
Can't post for 4 days!
Edit: ^ Can’t you just turn off trackpad gestures you don’t want in preferences?

pokeyman posted:

I haven't done any research or anything, but my answers are: gpu cores won't make any noticeable difference; more memory is maybe better otherwise no noticeable difference.

The M1 Pro/max/ultra cpu and faster ram help far, far more than the GPU. It’s my understanding (based o podcasts featuring Apple’s developers) that previews are basically modified simulators (modified to share and reuse resources so each tiny preview doesn’t require an entire simulator instance) so the flu and ram help more with that.

SwiftUI previews can still have a lot of jank and performance problems though, it’s just much better than on the x86 cpus. Also ARM’s much lower power requirements means that you laptop doesn’t sound and heat up like a jet engine, even when performance is bad.

The best preview experience I’ve had is on the Swift Playgrounds iPad app, probably because it’s not really previewing at that point, just running your code “natively.”

Pulcinella fucked around with this message at 19:31 on May 12, 2022

Data Graham
Dec 28, 2009

📈📊🍪😋



Pulcinella posted:

Edit: ^ Can’t you just turn off trackpad gestures you don’t want in preferences?

No, it's more like it's more pervasive and hard to repeat. If my left thumb is floating anywhere near the left edge/corner of the trackpad, it interferes with my right finger just doing normal clicking or two-finger gestures. Very often I'll try to do a two-finger scroll and instead it'll do a three-finger Exposé, or a double-click won't register properly making the haptic feedback all weird or something.

I don't know where they think I'm supposed to put my left hand but there's nowhere I can rest it on the keyboard without my thumb draping over the trackpad. It was perfectly fine when the trackpad was half this size.

lord funk
Feb 16, 2004

Data Graham posted:

It was perfectly fine when the trackpad was half this size.
I don't have a solution for you but I just want to say I have similar problems, this trackpad is too big, you're not the only one.

commie kong
Mar 7, 2019

the point free fellas have released a video showing off some new helpers they've built.

it's relatively short (33 mins :v:) for anyone interested in swiftui, testing, api mocks, etc.

Point-Free posted:

Tour of Parser-Printers: API Clients for Free
We conclude our tour of swift-parsing with a look at how URL routers defined as parser-printers can be automatically transformed into fully-fledged API clients, which we will drop into an iOS application and immediately use.

https://www.pointfree.co/episodes/ep189-tour-of-parser-printers-api-clients-for-free

Graniteman
Nov 16, 2002

I'm working on subscriptions for my first app, using StoreKit2. Everything is working as expected in TestFlight, except family sharing. Does Family Sharing work in TestFlight? Products purchased by family members are not showing up as entitled. I'm not sure if I'm doing something wrong in my code or if Family Sharing relationships don't copy over into the TestFlight environment.

FWIW I'm using StoreKit.Transaction.currentEntitlement(for: productIdentifier) and it returns nil for a product that I know was purchased by another Apple Family member. I'm using this same call for subscriptions and non-consumables.

It sure would be nice if you could mock family sharing using sandbox users...

Edit: I got a response from apple that Family Sharing does not work in TestFlight (or Sandbox, but I knew that already). Seems like this should be documented somewhere, but I can't find it anywhere.

Graniteman fucked around with this message at 21:51 on May 19, 2022

Pulcinella
Feb 15, 2019
Probation
Can't post for 4 days!
I finally have a chance to use async/await for the project I’m on and…I don’t like it? I know it’s supposed to be simpler and more straightforward than the old method, but I’m so, so used to nested callbacks that it’s been hard to wrap my brain around async await. Like async seems to have this viral quality where when one thing is async, all of a sudden everything around it has to be async and it spreads from there. I just want to wait for one asynchronous data to be retrieved and push a view controller configured with that data but I’m trapped in async world! I just want to get back on the main thread! Give me a pyramid of doom any day.

This is mostly just griping. I should probably go re-watch those WWDC videos.

Pulcinella
Feb 15, 2019
Probation
Can't post for 4 days!
Edit: duplicate some how

KidDynamite
Feb 11, 2005

Pulcinella posted:

I finally have a chance to use async/await for the project I’m on and…I don’t like it? I know it’s supposed to be simpler and more straightforward than the old method, but I’m so, so used to nested callbacks that it’s been hard to wrap my brain around async await. Like async seems to have this viral quality where when one thing is async, all of a sudden everything around it has to be async and it spreads from there. I just want to wait for one asynchronous data to be retrieved and push a view controller configured with that data but I’m trapped in async world! I just want to get back on the main thread! Give me a pyramid of doom any day.

This is mostly just griping. I should probably go re-watch those WWDC videos.

are you creating a Task to make your async calls in? otherwise async will definitely virally spread.

KidDynamite
Feb 11, 2005

commie kong posted:

the point free fellas have released a video showing off some new helpers they've built.

it's relatively short (33 mins :v:) for anyone interested in swiftui, testing, api mocks, etc.

seems cool but where is the work to create your models and routes? how do you get that for free with their library? or is this just a suggestion for how to structure your networking code?

i guess this is how they hook you into paying for episodes.

edit: oh this was the last video in a 5 part tour of the technique and library. I will have to get back to this.

I'm actually interested in the point free guys work. someone mentioned composable architecture in an interview i had. it's swiftui only though right?

KidDynamite fucked around with this message at 17:55 on May 26, 2022

101
Oct 15, 2012


Vault Dweller

KidDynamite posted:

it's swiftui only though right?

It is not. There's a UIKit section in the GitHub readme, was just looking at it yesterday. Works like Combine from the looks of it.

I think most of all of their videos on it are SwiftUI focused though.

I'm interested in it, but I don't know about using something third party for the whole architecture of the app. Anyone here used it and got any thoughts?

Adbot
ADBOT LOVES YOU

SaTaMaS
Apr 18, 2003

Pulcinella posted:

I finally have a chance to use async/await for the project I’m on and…I don’t like it? I know it’s supposed to be simpler and more straightforward than the old method, but I’m so, so used to nested callbacks that it’s been hard to wrap my brain around async await. Like async seems to have this viral quality where when one thing is async, all of a sudden everything around it has to be async and it spreads from there. I just want to wait for one asynchronous data to be retrieved and push a view controller configured with that data but I’m trapped in async world! I just want to get back on the main thread! Give me a pyramid of doom any day.

This is mostly just griping. I should probably go re-watch those WWDC videos.

b-but most UI functions are marked as @MainActor so you can call them and have them run on the main thread without having to put DispatchQueue.main.async all over the place. If they aren't, just use await MainActor.run{}

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