<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Carlos Vidal</title>
    <description>The latest articles on Forem by Carlos Vidal (@nakiostudio).</description>
    <link>https://forem.com/nakiostudio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3851%2F1814571.jpeg</url>
      <title>Forem: Carlos Vidal</title>
      <link>https://forem.com/nakiostudio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nakiostudio"/>
    <language>en</language>
    <item>
      <title>How to code your app using the CodeSandbox iPad IDE</title>
      <dc:creator>Carlos Vidal</dc:creator>
      <pubDate>Fri, 25 Nov 2022 18:11:29 +0000</pubDate>
      <link>https://forem.com/codesandboxio/how-to-code-your-app-using-the-codesandbox-ipad-ide-20o</link>
      <guid>https://forem.com/codesandboxio/how-to-code-your-app-using-the-codesandbox-ipad-ide-20o</guid>
      <description>&lt;p&gt;In the last few years, mobile devices like the iPad have become really powerful. With a long-lasting battery, a great screen, top-notch performance and 5G connectivity, the iPad provides an excellent alternative to laptops for those wanting to get work done while on the go.&lt;/p&gt;

&lt;p&gt;Naturally, one question came up—is it possible to have a coding experience on a mobile device that resembles that of a laptop?&lt;/p&gt;

&lt;p&gt;The most widely used IDEs, such as VS Code, have no official iOS support. So over the years, a series of iPad IDEs have tried to fill this ever-growing need. However, most of them came with a lot of quirks and required making too many compromises, failing to become a viable choice for daily use.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="https://apps.apple.com/us/app/codesandbox/id1423330822" rel="noopener noreferrer"&gt;CodeSandbox for iOS&lt;/a&gt; — a full-featured, native IDE for iPad and iPhone that was built to provide an optimal coding experience.&lt;/p&gt;

&lt;p&gt;In this blog post, we will present an overview of the app and show it in action as we fix a bug on an example app and open a pull request. You can also see the whole flow &lt;a href="https://www.youtube.com/watch?v=3nSzXmVDHqU" rel="noopener noreferrer"&gt;in this video&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A full-featured iPad IDE powered by the cloud&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;CodeSandbox for iOS is a native IDE for iPad and iPhone that provides all the tools you need to develop, test and collaborate on your web projects or small prototypes.&lt;/p&gt;

&lt;p&gt;As we will see in the next section, it is built around the concept of simplicity, incorporating all the tools you know and love from mainstream IDEs, such as IntelliSense, syntax highlighting, terminals, and git integration.&lt;/p&gt;

&lt;p&gt;But CodeSandbox for iOS goes above and beyond to make your life as a developer easier by running your projects on the cloud. This means that you never have to worry about storage space or the specs of your iPhone or iPad—everything runs on powerful microVMs that spin up almost instantly and are always ready.&lt;/p&gt;

&lt;p&gt;Plus, CodeSandbox for iOS is the only collaborative iPad IDE, allowing you to share any project with a URL and collaborate (live or asynchronously) with friends or colleagues, with no setup required.&lt;/p&gt;

&lt;p&gt;Let’s look at the developer experience of coding using the app. Don’t forget to install the free app and follow along!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setting up a project&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;One of the highlights of CodeSandbox for iOS is how easy it is to get started. In a nutshell, there are two main options: importing a GitHub repository or creating a sandbox.&lt;/p&gt;

&lt;p&gt;Importing from GitHub is great for working on branches and reviewing pull requests. Thanks to the &lt;a href="https://codesandbox.io/post/introducing-the-codesandbox-github-app" rel="noopener noreferrer"&gt;seamless GitHub integration&lt;/a&gt;, you can use this for your daily work and completely replace your laptop.&lt;/p&gt;

&lt;p&gt;One key advantage of doing this on CodeSandbox for iOS is that you won’t have to configure anything—every branch and PR runs on the cloud, so all the dependencies of your repo are installed for you, which means you can focus 100% on coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgofenvctfr0io14b6eaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgofenvctfr0io14b6eaf.png" alt="Import a repository" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sandboxes are great to play around with code. They ship with everything you need to quickly prototype an idea and share it to get feedback.&lt;/p&gt;

&lt;p&gt;CodeSandbox provides templates for all sorts of web technologies and packages (such as React, Next.js, Vue.js, Next.js, Remix, Angular, Astro, Gatsby, Svelte, and many more). So you can just choose a technology to create a sandbox and build on top of it to learn, experiment, and create a cool demo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcgh2nj5ngrvu8pdd9jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcgh2nj5ngrvu8pdd9jp.png" alt="Create Cloud Sandbox" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whether you’re working with Repositories or Sandboxes, it just takes a few taps to get started.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: Once you install app, you will get universal links support, so you can open any repo or sandbox in the app when you’re browsing them using Mobile Safari.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For this tutorial, let’s focus on the experience of working on a GitHub repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Working with branches and git&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example, we imported &lt;a href="https://codesandbox.io/p/github/nakiostudio/astro.build/draft/skeletal-zeh" rel="noopener noreferrer"&gt;this GitHub repo&lt;/a&gt;, which is a fork of &lt;a href="https://github.com/withastro/astro.build" rel="noopener noreferrer"&gt;Astro Starter Kit: Minimal&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Right after importing, we get to the editor. On the left, you’ll see the file tree, search and git controls. There’s also a dock at the bottom, which is where you’ll find some useful DevTools like access to previews, tasks, tests and the terminal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F9db824f0aa069a02aec1af75e46f7ccc%2Fc3def%2Fipad-ide-sidebar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F9db824f0aa069a02aec1af75e46f7ccc%2Fc3def%2Fipad-ide-sidebar.png" alt="CodeSandbox for iOS left sidebar" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All this navigation becomes very intuitive thanks to the command palette. Open it with &lt;code&gt;⌘ + K&lt;/code&gt;. This shows us some suggested actions such as file search, opening previews or changing branches.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: If you don’t have a physical keyboard, you can bring up the command palette by double tapping with two fingers anywhere on the screen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To make it easier to work on our code, let’s open a preview. It’s as simple as typing “preview”, tapping to accept “Open Preview”, and then tapping on the available preview—in this case, &lt;code&gt;dev: 3000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The preview will appear on the right side of your screen and you can drag it to resize as needed. In our example, by taking a quick look at our preview, we can see that my website is missing the hero component. Let’s fix that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F8452decd634ddc1f29bf41307419843d%2Fc3def%2Fipad-ide-missing-hero.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F8452decd634ddc1f29bf41307419843d%2Fc3def%2Fipad-ide-missing-hero.png" alt="Missing hero on the website" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first step is to create a new branch. Again using the command palette, simply type “branch” and choose “Branch from main”. CodeSandbox will immediately run this branch on an entirely new cloud instance that is created in seconds.&lt;/p&gt;

&lt;p&gt;Then, we just need to open the preview for the current branch, and we’re ready to start bug fixing.&lt;/p&gt;

&lt;p&gt;So, let’s search for &lt;code&gt;src/pages/index.astro&lt;/code&gt; on the command palette and open that file.&lt;/p&gt;

&lt;p&gt;We just have to scroll a bit to get to the section we’re looking for—the layout for our hero, which appears to be missing the &lt;code&gt;Hero&lt;/code&gt; component.&lt;/p&gt;

&lt;p&gt;As you start typing, the built-in IntelliSense automatically displays autocomplete suggestions with matching components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2Fa726cb6454534d7757e488c6f8b1af3d%2Fc3def%2Fipad-ide-intellisense.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2Fa726cb6454534d7757e488c6f8b1af3d%2Fc3def%2Fipad-ide-intellisense.png" alt="CodeSandbox for iOS IntelliSense" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take the suggestion. The preview updates immediately and we see that the hero component is now showing up as expected.&lt;/p&gt;

&lt;p&gt;However, there seems to be a problem with the copy of the &lt;code&gt;Hero&lt;/code&gt; component, which I can find by navigating to &lt;code&gt;src/components/Hero.astro&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F62184173a32e311a0baf316fedcf5e41%2F10439%2Fipad-ide-hero-copy-problem.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F62184173a32e311a0baf316fedcf5e41%2F10439%2Fipad-ide-hero-copy-problem.png" alt="Problem with the hero copy" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This seems like a question for someone from the Marketing team. But, instead of going back and forth with screenshots and Slack messages, what if I can bring that colleague to make this change directly on my code?&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Collaborating with others from any device&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;One of the truly unique aspects of CodeSandbox for iOS is that it is fully collaborative, with an experience that’s similar to what you might find on tools like Figma.&lt;/p&gt;

&lt;p&gt;Everything you need is a link to your branch, which you can get by tapping on the ellipsis on the top right, choosing “Share” and copying the URL. In my case, I’ve shared it with Filipe, a colleague from the Marketing team.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F84be4639912fe245a5b2868586276e06%2Fc3def%2Fipad-ide-share.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2F84be4639912fe245a5b2868586276e06%2Fc3def%2Fipad-ide-share.png" alt="CodeSandbox for iOS share modal" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because CodeSandbox provides seamless collaboration between any device, Filipe can open my PR on the editor of his choice: the CodeSandbox web editor, CodeSandbox for iOS or even VS Code, using the &lt;a href="https://marketplace.visualstudio.com/items?itemName=CodeSandbox-io.codesandbox-projects" rel="noopener noreferrer"&gt;CodeSandbox VS Code extension&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I will see Filipe’s avatar pop up when he joins and, by tapping on it, I will follow him around the code and see the fix being made in real-time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flc5tl5e5uxeo2atn3ge3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flc5tl5e5uxeo2atn3ge3.png" alt="CodeSandbox collaboration" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because the collaboration happens in real-time, I can see the updated preview and everything looks good!&lt;/p&gt;

&lt;p&gt;Instead of taking 10 minutes and a dozen Slack messages, we fixed this in 30 seconds 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Using DevTools: terminals, tests, tasks and more&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As we mentioned earlier, the bottom dock of the editor shows a series of DevTools that you may find very useful. Click on the &lt;code&gt;+&lt;/code&gt; sign to expand it and you will see the three default options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Previews&lt;/li&gt;
&lt;li&gt;Tasks&lt;/li&gt;
&lt;li&gt;Terminals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Previews show you every preview you have started, allowing you to easily switch between multiple previews of your app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/docs/learn/repositories/task" rel="noopener noreferrer"&gt;Tasks&lt;/a&gt; are one of the most powerful CodeSandbox features, essentially allowing you to run any command with a tap. In our example, CodeSandbox automatically detects some tasks of the Astro repo such as &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;dev&lt;/code&gt;, &lt;code&gt;format&lt;/code&gt;, &lt;code&gt;format:eslint&lt;/code&gt; and &lt;code&gt;format:prettier&lt;/code&gt;. You can easily add new tasks for tests, database servers and more—take a look at our &lt;a href="https://codesandbox.io/docs/learn/repositories/task" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2Ffd80494f897e425a4f9c8b5b6956a77a%2F10439%2Fipad-ide-tasks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcodesandbox.io%2Fstatic%2Ffd80494f897e425a4f9c8b5b6956a77a%2F10439%2Fipad-ide-tasks.png" alt="CodeSandbox for iOS tasks" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you can create terminals and run commands for anything else you might need.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: You can use a terminal to &lt;a href="https://codesandbox.io/docs/tutorial/getting-started-with-docker" rel="noopener noreferrer"&gt;install Docker&lt;/a&gt; and run servers, databases and much more, right from the CodeSandbox iOS app!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Opening a pull request&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we’re happy with the fix to our website’s hero component, let’s go ahead and commit these changes. &lt;/p&gt;

&lt;p&gt;Simply reveal the panel from the left side of your screen to bring up the sidebar and go to the git tab. This is where you can write the commit message, create a commit, and then tap to open a PR.&lt;/p&gt;

&lt;p&gt;This brings you directly to GitHub with everything pre-filled. You only need one final tap to open the PR, and it’s done!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnywgnnjze76hi7pwtzv7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnywgnnjze76hi7pwtzv7.png" alt="Commit and open PR" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Supercharging your workflow&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As we saw in this post, CodeSandbox for iOS goes beyond providing the core functionality you expect from an IDE, by running your code in the cloud and accelerating how you code, review and ship.&lt;/p&gt;

&lt;p&gt;Here are some tips on how you can get the most out of this experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up the &lt;a href="https://codesandbox.io/post/introducing-the-codesandbox-github-app" rel="noopener noreferrer"&gt;CodeSandbox GitHub App&lt;/a&gt; on your GitHub repo to get automatic deployment previews for every PR that you can open on the app with a tap.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://codesandbox.io/docs/learn/teams/team-overview" rel="noopener noreferrer"&gt;Create a team&lt;/a&gt; to organize your work and improve collaborations with everyone on your team.&lt;/li&gt;
&lt;li&gt;Share a standalone &lt;a href="https://codesandbox.io/docs/learn/repositories/preview" rel="noopener noreferrer"&gt;preview&lt;/a&gt; of your branch at any time to get feedback on your code and iterate faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are constantly working on making this experience even better. So, if you have any feature requests or experience any issues, please provide some feedback—simply tap “Submit feedback” at the bottom of the app’s dashboard.&lt;/p&gt;

</description>
      <category>codesandbox</category>
      <category>ipad</category>
      <category>ios</category>
      <category>development</category>
    </item>
    <item>
      <title>Xcode, the ultimate debugging and cracking tool</title>
      <dc:creator>Carlos Vidal</dc:creator>
      <pubDate>Wed, 06 Jun 2018 13:08:16 +0000</pubDate>
      <link>https://forem.com/nakiostudio/xcode-the-ultimate-debugging-and-cracking-tool-1964</link>
      <guid>https://forem.com/nakiostudio/xcode-the-ultimate-debugging-and-cracking-tool-1964</guid>
      <description>&lt;p&gt;Debugging has always been part of my experience with computers, even before learning how to code. However, the satisfaction of unfolding a binary and modifying a program behaviour has never been hassle free.&lt;/p&gt;

&lt;p&gt;Normally, debugging consists on switching back and forth from hex editor to debugger, application, terminal, calculator… not to mention the program exiting and that very long recipe you had to follow until reaching the point where your debugging session finished abruptly. &lt;em&gt;Not good…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But few months ago, with the excuse of &lt;a href="http://github.com/nakiostudio/TwitterX" rel="noopener noreferrer"&gt;cracking Twitter for macOS&lt;/a&gt;, I decided to minimise this problem and optimise this flow. That is when Xcode came to the rescue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;First of all, we need to create a Xcode project with a Cocoa Framework as target.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F550y57wtuby89996b3bs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F550y57wtuby89996b3bs.png" alt="setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Debugging
&lt;/h3&gt;

&lt;p&gt;We will use the embedded lldb console for dynamic debugging.&lt;/p&gt;

&lt;p&gt;Imagine that Twitter for macOS is the app we want to debug. Normally, we would need to run lldb and launch the process from the debugger, instead, Xcode can do this for you every time we click on the Run button.&lt;/p&gt;

&lt;p&gt;To do so, select the Twitter application as executable in the &lt;strong&gt;Run&lt;/strong&gt; configuration of our framework’s scheme.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7tuv6yjg5adn9fculwiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7tuv6yjg5adn9fculwiq.png" alt="debugging_1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This way, our framework will be compiled and the Twitter app launched with lldb attached to the process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2sd2sgbkpstq6f0l6ujb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2sd2sgbkpstq6f0l6ujb.png" alt="debugging_2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Injecting code
&lt;/h3&gt;

&lt;p&gt;What we have done so far could be a sufficient achievement, we can easily create a debugging session targeting an application and also take advantage of the commands autocomplete Xcode provides. But what about injecting code?&lt;/p&gt;

&lt;p&gt;Code injection usually involves compiling a dynamic library and patching the binary so it links to our library. Still, debugging the code we inject is a tedious task and the process slow and repetitive although we can always automate parts of it.&lt;/p&gt;

&lt;p&gt;Now, thanks to Xcode flexibility configuring schemes and a bit of magic we can patch the runtime of the application we are inspecting easily and without modifying its binary (double win).&lt;/p&gt;

&lt;p&gt;As an example, let’s inject some code that logs every call to &lt;code&gt;viewDidLoad&lt;/code&gt;.&lt;br&gt;
The Cocoa Framework project template creates a header file called &lt;code&gt;nameOfTheProject.h&lt;/code&gt;. We are going to create its respective &lt;code&gt;.m&lt;/code&gt; file and place in it the swizzling logic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhvpgxj5uor6eboso70ls.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhvpgxj5uor6eboso70ls.png" alt="injection_1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As it is, Xcode will compile our framework and launch the Twitter application with the debugger attached to its process. Linking these two is as easy as running the process with an environment variable that forces the load of a library located at the path given. This environment variable is &lt;code&gt;DYLD_INSERT_LIBRARIES&lt;/code&gt; and the path of our library &lt;code&gt;${TARGET_BUILD_DIR}/${TARGET_NAME}.framework/Versions/A/${TARGET_NAME}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8bfnlyiapoyyf6fl1htj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8bfnlyiapoyyf6fl1htj.png" alt="injection_2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After setting the environment variable in the &lt;strong&gt;Arguments&lt;/strong&gt; tab of the &lt;strong&gt;Run&lt;/strong&gt; configuration of our scheme click the Run button. Our code should have been correctly injected into the Twitter process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F112anpji9b3rzr84jjzf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F112anpji9b3rzr84jjzf.png" alt="injection_3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not good enough? all the other debugging goodies Xcode provides are also available, from the view hierarchy to the memory graph debuggers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7t8mh752oqtvehntdtat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7t8mh752oqtvehntdtat.png" alt="injection_4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summing up
&lt;/h3&gt;

&lt;p&gt;Whether your are into reverse engineering or not, I encourage you to give this a try and also play with &lt;a href="https://github.com/nakiostudio/TwitterX" rel="noopener noreferrer"&gt;TwitterX&lt;/a&gt; for more about the capabilities of this setup.&lt;/p&gt;

</description>
      <category>xcode</category>
      <category>ios</category>
      <category>macos</category>
      <category>iosdev</category>
    </item>
  </channel>
</rss>
