Home Blog Page 6

Utilizing Devices to profile a SwiftUI app – Donny Wals


A key talent for each app developer is with the ability to profile your app’s efficiency. Your app would possibly look nice on the floor, but when it doesn’t carry out properly, it’s going to really feel off—typically subtly, typically very noticeably. Lovely animations, slick interactions, and huge knowledge units all fall flat if the app feels sluggish or unresponsive.

Nice apps reply immediately. They present that you just’ve tapped one thing straight away, and so they make interactions really feel easy and satisfying.

To verify your app behaves like that, you’ll must control its efficiency. On this publish, we’ll take a look at how you should use Devices to profile your SwiftUI app. We’ll cowl find out how to detect sluggish code, monitor view redraws, and perceive when and why your UI updates. For those who’re focused on a deeper dive into SwiftUI redraws or profiling sluggish code, try these posts:

We’ll begin by constructing your app for profiling, then take a look at find out how to use Devices successfully—each for SwiftUI specifics and basic efficiency monitoring.

Constructing an app for profiling

Step one is to construct your app utilizing Product > Profile, or by urgent Cmd + I (sidenote: I extremely suggest studying shortcuts for command you employ ceaselessly).

Use Product->Profile or cmd+i

This builds your app in Launch mode, utilizing the identical optimizations and configurations as your manufacturing construct.

That is essential as a result of your improvement construct (Debug mode) isn’t optimized. You would possibly see efficiency points in Debug that don’t exist in Launch. I not too long ago had this occur whereas working with giant knowledge units—code ran fairly horrible in Debug was optimized in Launch to the purpose of now not being an issue in any respect.

When this occurs, it often means there’s some inefficiency underneath the hood, however I wouldn’t spend an excessive amount of time on points that disappear in Launch mode when you’ve got larger points to work on.

As soon as your app is constructed and Devices launches, you’ll see a bunch of templates. For SwiftUI apps, the SwiftUI template is often the best selection—even in case you’re not profiling SwiftUI-specific points. It consists of the whole lot you want for a typical SwiftUI app.

Choosing a template

After selecting your template, Devices opens its essential window. Hit the pink document button to begin profiling. Your app will launch, and Devices will begin amassing knowledge in real-time based mostly on the devices you chose. The SwiftUI template collects the whole lot in real-time.

Instruments overview

Studying the collected knowledge

Devices organizes its knowledge into a number of lanes. You’ll see lanes like View Physique, View Properties, and Core Animation Commits. Let’s undergo them from high to backside.

Viewing recorded data

Observe that I’m testing on a bodily gadget. Testing on the simulator can work okay for some use instances however outcomes can differ wildly between simulators and gadgets because of the sources accessible to every. It’s all the time beneficial to make use of a tool when testing for efficiency.

The View Physique lane

This lane reveals how usually a SwiftUI view’s physique is evaluated. Each time SwiftUI detects a change in your app’s knowledge, it re-evaluates the physique of any views that depend upon that knowledge. It then determines whether or not any youngster views must be redrawn.

So, this lane primarily reveals you which of them views are being redrawn and the way usually. For those who click on the timing abstract, you’ll see how lengthy these evaluations take—whole, min, max, and common durations. This helps you establish whether or not a view’s physique is fast or costly to guage.

Exploring the view body lane

By default, Devices reveals knowledge for the whole profiling session. Which means a view that was evaluated a number of occasions could have been triggered by totally different interactions over time.

Often, you’ll wish to profile a selected interplay. You are able to do this by dragging throughout a timeframe within the lane. This allows you to zoom in on a selected window of exercise—like what occurs whenever you faucet a button.

When you’ve zoomed in, you can begin to kind a psychological mannequin.

For instance, if tapping a button will increase a counter, you’d count on the counter view’s physique to be evaluated. If different views just like the button’s dad or mum additionally redraw, that is perhaps sudden. Ask your self: did I count on this physique to be re-evaluated? If not, it’s time to look into your code.

In my publish on SwiftUI view redraws, I clarify extra about what may cause SwiftUI to re-evaluate views. It’s price a learn if you wish to dig deeper.

View Properties and Core Animation Commits

The View Properties and Core Animation Commits lanes are ones I don’t use fairly often.

In View Properties, you may see which items of state SwiftUI tracked in your views and what their values have been. In principle, you may work out how your knowledge mannequin modified between physique evaluations—however in observe, it’s not all the time straightforward to learn.

Core Animation Commits reveals how a lot work Core Animation or the GPU needed to do when redrawing views. Often, it’s not too heavy, but when your view physique takes a very long time to guage, the commit tends to be heavier too.

I don’t take a look at this lane in isolation, however it helps to get a way of how costly redrawing grew to become after a physique analysis.

Studying the Time Profiler

The Time Profiler is perhaps probably the most helpful lane within the SwiftUI Devices template. It reveals you which of them code was working on which thread, and the way lengthy it was working.

You’re primarily seeing snapshots of the CPU at quick intervals. This provides you perception into how lengthy particular features have been energetic.

When profiling SwiftUI apps, you’ll often be focused on code associated to your knowledge mannequin or views. If a operate updates your knowledge and seems sluggish, or if it’s referred to as from a view physique, which may clarify a efficiency problem.

Configuring the time profiler

Getting comfy with the time profiler takes a little bit of observe. I like to recommend enjoying round with the decision tree settings. I often:

  • Separate by thread
  • Invert the decision tree
  • Disguise system libraries

Typically, I tweak these settings relying on what I’m looking for. It’s price exploring.

In abstract

Profiling your code and understanding find out how to use Devices is important if you wish to construct responsive, high-quality apps. As your app grows, it will get more durable to mentally monitor what ought to occur throughout an interplay.

The difficult half about utilizing Devices is that even with a ton of knowledge, you have to perceive what your app is meant to be doing. With out that, it’s laborious to inform which components of the information matter. One thing is perhaps sluggish—however that is perhaps okay if it’s processing a whole lot of knowledge.

Nonetheless, entering into the behavior of profiling your app usually helps you construct a way of what’s regular and what’s not. The sooner and extra usually you do that, the higher your understanding turns into.

The Auto Manufacturers Electrifying Quickest in USA — Gross sales Charts (EXCLUSIVE)



Join CleanTechnica’s Weekly Substack for Zach and Scott’s in-depth analyses and excessive stage summaries, join our day by day e-newsletter, and/or comply with us on Google Information!


Final Up to date on: sixteenth April 2025, 03:11 am

As they are saying, every little thing’s relative. Nicely, not every little thing — if it was, the phrase “relative” wouldn’t exist. However generally we wish to or want to know issues in absolute phrases, and different instances we wish to or want to know issues in relative phrases. I’ve to say that I’m a complete sucker for crunching information to see who cleantech leaders are in relative phrases.

Earlier at the moment, I reported on the auto manufacturers promoting essentially the most electrical autos in america to this point this yr. And that follows a take a look at the high promoting EV fashions within the nation and charts on the long-term progress of the EV market within the USA. Now, let’s check out one thing you gained’t discover anyplace else — the share of gross sales from the market’s auto manufacturers and auto teams that at the moment are EV gross sales. (And, sure, we’re simply taking a look at pure EV gross sales right here, not together with plugin hybrids.)

Within the first chart, taking a look at auto manufacturers, I’m together with pure electrical firms. Nevertheless, within the chart for auto teams and alliances, I’m excluding them since that makes the chart more durable to look at.

Together with the pure EV manufacturers is admittedly simply to provide them a nod. Let’s hope all of them survive. The spotlight legacy model, although, is Fiat. If you happen to go to its web site, Fiat is barely promoting electrical autos now. Nevertheless, there are nonetheless some legacy gas-powered Fiats hanging round on heaps, so Fiat’s apparently not at 100% EV gross sales but — but it surely ought to get there quickly! In fact, Fiat has the bottom quantity of gross sales amongst all auto manufacturers within the nation, so it’s a footnote, however kudos to Fiat nonetheless. (Fiat moved solely 522 autos within the 1st quarter, and whereas that was a 239% improve in gross sales yr over yr, it was barely greater than 1 / 4 of Alfa Romeo’s gross sales!)

What’s actually thrilling is how excessive the EV share of Porsche and Cadillac gross sales has turn out to be. Porsche, with top-quality racing genes, is in first amongst notable auto manufacturers, with 23% of its gross sales being electrical within the 1st quarter, however Cadillac isn’t far behind at 19% share. Humorous sufficient, I used to be simply commenting to myself at the moment that I’m now always seeing Cadillac LYRIQs in all places I’m going and so they appear to account for many of the Cadillacs I see on the highway. I’ve additionally seen a couple of Cadillac Escalade IQs — Cadillac’s top-of-the-line providing now. EVs have clearly turn out to be essentially the most premium and desired autos available on the market.

Different premium manufacturers account for the following three positions on the chart — Acura (15.6% EV share regardless of being very new to the EV world), BMW (15.5% EV share), and Audi (13.8% EV share). Then we get Volkswagen, which has tried to be daring in its EV transition plans and now has nearly 11% of its US gross sales coming from EVs. (I do know, I’d a lot reasonably see it at 44% by now, however it’s the main mid-market auto model and deserves some props for that.) MINI is the final model to be in double digits, and that was simply barely at 10.0% of its gross sales coming from EVs.

Not way more is notable on there if we don’t wish to spotlight the laggards, however the greatest shocker of the entire chart for me was seeing Dodge at 9% EV gross sales. Dodge! Nicely, I assume Dodge consumers are very into efficiency, and everybody ought to know by now that there’s no competing with the moment torque of electrical motors. I assume sufficient Dodge drivers obtained smoked by Teslas and different EVs that they determined to purchase the primary electrical Dodge available on the market. Hopefully that may encourage Dodge to supply and promote extra EVs ASAP.

auto teams and alliances, EV share of gross sales will get watered down a bit. The manufacturers that shine get diluted by the manufacturers that don’t. Some individuals favor this rating, although, as a result of it exhibits extra totally how a lot a company is behind the transition to EVs.

On this rating, we see BMW Group — lengthy a pioneer in EVs attempting to be a pacesetter of the revolution — reaching 15% EV gross sales. Volkswagen Group is available in honorably within the silver medal place.

Clearly, the Germans are far forward of the pack, as third place Hyundai–Kia had simply 5.5% of gross sales coming from EVs. By nearly all accounts, that’s not a share to be pleased with. Comparatively talking, although, it did beat each different mass-market legacy auto group/alliance.

Do any others deserve point out? Nicely, a minimum of GM, Mercedes-Benz Group, Ford Motor Firm, and Honda Motor Firm are above 4%, but it surely’s arduous to cheer them on at such low EV shares. Simply don’t look additional down the record.

Let me know down within the feedback — do the automakers that rank within the high three to 5 locations in these rankings deserve reward for being leaders in a weak market, or ought to all of them be shamed for not attaining increased percentages by now? I’m torn between the 2 factors of view.

Whether or not you’ve gotten solar energy or not, please full our newest solar energy survey.




Have a tip for CleanTechnica? Wish to promote? Wish to recommend a visitor for our CleanTech Discuss podcast? Contact us right here.


Join our day by day e-newsletter for 15 new cleantech tales a day. Or join our weekly one if day by day is just too frequent.


Commercial



 


CleanTechnica makes use of affiliate hyperlinks. See our coverage right here.

CleanTechnica’s Remark Coverage




NowSecure Drives OWASP Cellular Requirements to Strengthen AppSec


NowSecure just lately celebrated three years of contributing to the OWASP Cellular App Safety Undertaking which produces globally acknowledged requirements for safe cell app improvement and cell app safety testing. The corporate’s trade management as an OWASP MAS Advocate has superior cell safety and offered cell software threat administration options that align with OWASP requirements to scale back threat, strengthen privateness and guarantee compliance.

Led by Carlos Holguera, the OWASP MAS Undertaking co-chair and a NowSecure principal analysis engineer, the NowSecure contributions to OWASP cell safety initiatives will be partially quantified by GitHub metrics:

  • 320+ pull requests
  • 230+ opinions
  • 42,000+ additions
  • 29,500+ deletions

These numbers mirror greater than exercise — they show management. NowSecure has considerably superior OWASP MAS sources by contributing useful content material, reviewing group submissions and sustaining the general readability and high quality of the mission.


NowSecure has considerably superior OWASP MAS sources by contributing useful content material, reviewing group submissions and sustaining the general readability and high quality of the mission.

Why OWASP Cellular Software Safety Issues to Safety Leaders

The OWASP Cellular App Safety mission gives an authoritative, community-driven framework for securing cell purposes. It contains three core parts which have develop into important sources for cell safety leaders, practitioners and builders:

  • MASVS: The Cellular Software Safety Verification Normal (MASVS) defines the safety controls required to safe a cell app throughout completely different menace fashions.
  • MASTG: The Cellular Software Safety Testing Information (MASTG) gives detailed check instances and methodologies to evaluate app compliance in opposition to MASVS.
  • MASWE: The Cellular App Safety Weak point Enumeration (MASWE) gives a structured taxonomy of identified cell safety weaknesses for higher vulnerability monitoring and remediation.
NowSecure Drives OWASP Cellular Requirements to Strengthen AppSec

Collectively, these frameworks assist safety leaders:

  • Set up constant, measurable cell software safety requirements throughout inner and third-party improvement groups
  • Align cell software safety testing with regulatory compliance necessities equivalent to GDPR, HIPAA, PCI DSS, and CCPA
  • Scale back threat publicity from cell threats by way of structured verification, safety assessments and remediation planning
  • Allow DevSecOps and AppSec groups to shift left and implement safe coding practices earlier within the improvement lifecycle.

“The MAS Requirements assist reply the crucial query, ‘Have we carried out sufficient based mostly on the enterprise threat of the cell app?” says NowSecure CEO Alan Snyder. “The requirements keep present by way of group enter, allow vendor efficiency comparisons and supply proof of cheap care to auditors and regulators.  Any critical cell app threat administration program ought to incorporate them.”

How NowSecure Helps & Contributes to OWASP MAS

As a longstanding OWASP MAS contributor and advocate, NowSecure performs a pivotal function in shaping the way forward for cell safety requirements. As talked about above, our crew has contributed greater than 320 GitHub pull requests, 230 opinions and tens of 1000’s of traces of additives and enhancements to the MASVS, MASTG and MASWE sources.

Our contributions have influenced practically each main evolution of the mission previously three years:

MASVS v2.0 & v2.1 Modernize Cellular AppSec Requirements

In 2023, OWASP launched MASVS v2.0 — a serious replace that launched a simplified, modular construction with clearly outlined MAS Testing Profiles to assist real-world cell threat fashions. NowSecure contributed technical insights, real-world testing situations and strategic steering that helped refine the usual and enhance its usability for cell builders and safety groups.

In early 2024, MASVS-PRIVACY v2.1 was addressed to handle privateness and information safety dangers — a contribution closely influenced by NowSecure’s work within the monetary, healthcare and high-tech sectors.

MASTG Refactor Enhances Sensible Testing and Usability

The Cellular Software Safety Testing Information underwent a serious refactor led partly by NowSecure. The updates included:

  • Atomic Testing: Smaller, self-contained exams with clear traceability.
  • Modular Framework: Separation of exams, methods, instruments, and app examples.
  • Improved Searchability and Upkeep: Enabling quicker onboarding and simpler adoption for safety analysts.

These updates ease the method of conducting audits, automating assessments and tracing findings again to MASVS controls — accelerating time-to-insight and time-to-remediation.

MASWE Maps the Cellular Menace Panorama

NowSecure contributed considerably to the MASWE, a brand new enumeration designed to bridge the hole between safety necessities and concrete cell weaknesses. MASWE improves the traceability between MASVS and MASTG, making it simpler for groups to trace vulnerabilities throughout the SDLC and triage dangers with precision.

Check Apps and Allow Builders

To empower cell improvement and safety groups with hands-on expertise, NowSecure supported the creation of standardized MAS Check Apps for iOS and Android. These embrace:

  • Skeleton purposes for speedy testing
  • Embedded code samples to simulate vulnerabilities
  • CI/CD integration by way of GitHub Actions

This funding helps cell groups study, check, and scale safe improvement practices in real-world environments.

Operationalize OWASP MAS with NowSecure Platform

As an enterprise chief, contributing to OWASP MAS is simply a part of the story. NowSecure built-in OWASP MAS requirements immediately into NowSecure Platform, an automatic cell app safety testing answer. This permits organizations to: 

  • Conduct steady testing aligned to MASVS Testing Profiles
  • Automate assessments for inner, third-party and public apps
  • Map findings to MASVS, MASTG and MASWE for audit-ready stories
  • Help privateness testing with MASVS-PRIVACY integration
  • Shift left with CI/CD and API-first integrations.

This strategy empowers CISOs and AppSec leaders to scale cell app safety efforts throughout the cell ecosystem and quickly launch safe apps with out slowing improvement.

Drive Strategic Cellular Safety Outcomes

By contributing to and aligning with OWASP MAS, NowSecure helps CISOs,  safety leaders and DevSecOps leaders obtain these enterprise targets: 

  • Scale back Danger: Stop information breaches and privateness violations
  • Guarantee Compliance: Meet requirements like OWASP MASVS, GDPR, HIPAA, and SOC 2
  • Allow DevSecOps: Embed safety into the SDLC and CI/CD pipeline
  • Enhance Safety Maturity: Set up a repeatable, scalable cell AppSec program
  • Reveal Management: Align your program with world safety finest practices

Accomplice with NowSecure to Lead in Cellular Software Safety

The OWASP MAS mission continues to set the worldwide customary for cell AppSec — and NowSecure is proud to paved the way. Our specialists, instruments and contributions assist enterprise safety leaders construct and preserve resilient risk-based cell safety applications backed by confirmed requirements.

Discover how NowSecure will help your crew align with OWASP MASVS requirements, automate cell app safety testing and higher handle cell app threat by requesting a NowSecure Platform demo or cell PTaaS at present.



ios – Sustaining a secure scroll place when inserting gadgets above in a ScrollView


Because the title says, I’m not certain tips on how to correctly construct an inverted ScrollView the place I can safely insert gadgets above my information (“prepend”) with out all the pieces leaping round.

My present code is actually this:

@State non-public var scrollPosition = ScrollPosition(idType: Message.ID.self)

non-public func onMessageDidScrollIntoView(_ id: Message.ID) {
  let indexOfVisibleMessage = /* ... */
  if indexOfVisibleMessage < 10 {
    fetchOlderMessages()
    // ^ this updates my ViewModel `messages`
  }
}

var physique: some View {
  ScrollView {
    LazyVStack {
      ForEach(messages) { message in
        MessageCell(message)
      }
    }.scrollTargetLayout()
  }
  .defaultScrollAnchor(.backside)
  .scrollPosition($scrollPosition)
  .onChange(of: scrollPosition) { oldValue, newValue in
    guard let visibleMessageId = scrollPosition.viewID(sort: Message.ID.self) else { return }
    onMessageDidScrollIntoView(visibleMessageId)
  }
}

..so if the consumer scrolls as much as the oldest 10 messages, I begin loading extra and insert them on the high.

The issue with that is that the ScrollView now jumps when new messages are inserted. It’s because the ScrollView maintains it is Y place, however the content material dimension adjustments since we’re including new gadgets “above”.

I attempted to mess around with just a few strategies I discovered on StackOverflow, particularly;

  • Inverting the ScrollView (.scaleEffect(y: -1) on the ScrollView after which once more on the MessageCell to counter it): This by some means jumped the x place of the ScrollView and utterly breaks .contextMenu.
  • Taking part in round with .onScrollGeometryChange to replace scrollPosition.scrollTo(y:) when it is contentSize adjustments: This simply did not work and stopped the consumer scroll gesture/interplay.
  • Setting scrollPosition to the Message.ID I need to preserve secure earlier than doing an replace: This did not do something.

However nothing really labored for the explanations described above.

How do you really construct these UIs in SwiftUI? I believe an inverted ScrollView is sort of a standard UI, and clearly information must be loaded lazily.

subnet – Is it right to place 255.255.255.0 for ‘netmask’ in /and so on/community/interfaces for a bridge with static IP with this LAN setup?


I’m making an attempt to study extra about laptop networks by establishing issues in my homelab, which features a pfSense router and a spare laptop computer which has Debian put in on it. I’ve arrange a KVM visitor on the Debian machine. My purpose is to configure issues in order that I can attain the KVM visitor from my LAN, simply as I can attain some other system on the LAN. To attain this, I’m following this information to arrange a bridge on the Debian machine: https://jamielinux.com/docs/libvirt-networking-handbook/bridged-network.html

I’m on the level the place I must put the next config into /and so on/community/interfaces:

# If not sure what 'netmask' or 'gateway' must be, ask your internet hosting supplier.

iface eth0 inet guide

auto br0
iface br0 inet static
    # Use the MAC handle recognized above.
    hwaddress ether f1:c2:7e:46:c8:9a
    handle 192.168.3.246
    netmask ?????????????????????????????????????????????
    gateway 192.168.3.1

    bridge_ports eth0
    # If you wish to activate Spanning Tree Protocol, ask your internet hosting
    # supplier first as it might battle with their community.
    bridge_stp off
    # If STP is off, set to 0. If STP is on, set to 2 (or higher).
    bridge_fd 0

# Irrelevant, since I haven't got IPv6 configured
#iface br0 inet6 static
#    handle 2001:db8::1
#    netmask 64
#    gateway fe80::1
#    autoconf 0

My LAN seems like this:

Primary address pool

DHCP static mapping

My concept was to provide the Debian server the static IP 192.168.3.246, as a result of I perceive it needs to be outdoors the handle pool vary, however contained in the LAN (so the values I might select from are 246-254)?.

My query is: what do I put because the netmask? Ought to or not it’s 255.255.255.0 (or alternatively, 24), as a result of that’s the subnet masks of the LAN?

I’ve been making an attempt to know this by studying the manpages for interfaces, however I do not perceive how netmask is used when I’ve a static IP.