<?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>DEV Community: Takuma Yamada</title>
    <description>The latest articles on DEV Community by Takuma Yamada (@tyamada).</description>
    <link>https://dev.to/tyamada</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4224061%2Fb162f217-9b93-42da-b233-e9cc212776f0.jpg</url>
      <title>DEV Community: Takuma Yamada</title>
      <link>https://dev.to/tyamada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tyamada"/>
    <language>en</language>
    <item>
      <title>From “It Opens” to “It Works”: Testing My PDF Reader with Predictable Data</title>
      <dc:creator>Takuma Yamada</dc:creator>
      <pubDate>Tue, 17 Nov 2026 21:51:13 +0000</pubDate>
      <link>https://dev.to/tyamada/from-it-opens-to-it-works-testing-my-pdf-reader-with-predictable-data-32m0</link>
      <guid>https://dev.to/tyamada/from-it-opens-to-it-works-testing-my-pdf-reader-with-predictable-data-32m0</guid>
      <description>&lt;p&gt;Fix the two-page layout. Open a PDF. Check the result. Make another change. Check again.&lt;/p&gt;

&lt;p&gt;That cycle became familiar while I was building &lt;strong&gt;MihirakiPDFViewer&lt;/strong&gt;, an iPad PDF reader for books I had scanned. In &lt;a href="https://dev.to/tyamada/why-two-page-pdf-layouts-were-harder-than-i-expected-47fg"&gt;Part 2&lt;/a&gt;, I described the work behind page spacing, right-to-left reading, and search highlight alignment.&lt;/p&gt;

&lt;p&gt;But checking a fix with whichever book I happened to be reading had a limitation: the input kept changing. It was difficult to tell whether the next code change preserved the behavior I had just checked.&lt;/p&gt;

&lt;p&gt;I needed test PDFs with known settings and predictable results.&lt;/p&gt;

&lt;p&gt;This article follows how I prepared those files, asked AI to help add tests, and learned to distinguish a passing test from a broader claim that the app worked correctly.&lt;/p&gt;

&lt;p&gt;The automated test results described here were recorded in August and September 2026 using an iPad (A16) Simulator running iOS 26.5. They are separate from my everyday testing on a physical iPad.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a file you can share
&lt;/h2&gt;

&lt;p&gt;My own scanned books were useful for finding problems during normal reading. They were not suitable for publishing alongside the source code so that someone else could reproduce the same checks.&lt;/p&gt;

&lt;p&gt;I created sample documents in Google Docs, exported them as PDFs, and used a script to set different reading directions and page layouts.&lt;/p&gt;

&lt;p&gt;The goal was to make mistakes easy to spot.&lt;/p&gt;

&lt;p&gt;Clearly numbered pages help reveal reversed pairs. Files with the same content but different reading-direction settings make it easier to compare the app’s behavior.&lt;/p&gt;

&lt;p&gt;Preparing test data became part of developing the app.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fil2qo527zujd08s1r2zu.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fil2qo527zujd08s1r2zu.png" alt="Right-to-left test setup with a separate cover: a four-page PDF should show page 1, then page 3 on the left and 2 on the right, then page 4." width="800" height="1570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1. Connect the input conditions to an expected sequence of views. This four-page example uses right-to-left reading, a separate cover, and the app’s STANDARD cover setting. Numbers are PDF positions starting at 1; arrows show the view sequence, not swipe direction. Schematic illustration.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the file, the detected settings, and the screen
&lt;/h2&gt;

&lt;p&gt;The reader uses information inside the PDF to determine its reading direction and page layout.&lt;/p&gt;

&lt;p&gt;The relevant settings are called &lt;code&gt;Direction&lt;/code&gt; and &lt;code&gt;PageLayout&lt;/code&gt;. A filename such as “right-to-left.pdf” does not prove that the file contains the intended values.&lt;/p&gt;

&lt;p&gt;I needed to separate three checks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the PDF contain the settings I intended?&lt;/li&gt;
&lt;li&gt;Does the app recognize those settings correctly?&lt;/li&gt;
&lt;li&gt;Does the resulting page arrangement look correct on screen?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These checks answer different questions. Recognizing right-to-left metadata does not, by itself, prove that the reader opens on the correct page or puts each page on the correct side.&lt;/p&gt;

&lt;p&gt;The test files covered two reading directions and six layout settings, giving 12 combinations. Additional files covered page pairing with and without a separate cover.&lt;/p&gt;

&lt;p&gt;The cover examples assumed the app’s cover setting was &lt;code&gt;STANDARD&lt;/code&gt;. The app configuration mattered as well as the file.&lt;/p&gt;

&lt;p&gt;There was another boundary to keep clear: recognizing a continuous-layout setting in a PDF did not mean that the app reproduced that continuous viewing mode. A test of metadata recognition needed to be described as exactly that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give search a known answer
&lt;/h2&gt;

&lt;p&gt;Finding a few results was not enough to verify search.&lt;/p&gt;

&lt;p&gt;With a book I was reading, I usually did not know how many times a word appeared. A plausible-looking result count could hide missing or duplicate matches.&lt;/p&gt;

&lt;p&gt;I prepared Japanese and English search PDFs containing words with known occurrence counts. Both files had 30 pages. For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Search term&lt;/th&gt;
&lt;th&gt;Expected matches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LOADTEST600&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;600&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Performance Check&lt;/code&gt; in the English file&lt;/td&gt;
&lt;td&gt;300&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When preparing the original development article, I also checked the occurrence counts in text extracted from the PDFs.&lt;/p&gt;

&lt;p&gt;That gave the app’s search results something concrete to match. Instead of asking whether search found “a lot” of results, I could ask whether it found the expected number.&lt;/p&gt;

&lt;p&gt;These checks use PDFs containing searchable text. An image-only scan is a different input and should not be treated as equivalent.&lt;/p&gt;

&lt;h2&gt;
  
  
  A large file needs checks after opening
&lt;/h2&gt;

&lt;p&gt;I also wanted to test conditions that were less likely to occur during everyday reading.&lt;/p&gt;

&lt;p&gt;An earlier job had taught me the importance of load testing. For this project, I asked AI to create a PDF larger than 100 MB with more than 1,000 pages.&lt;/p&gt;

&lt;p&gt;The resulting file had 1,100 pages and was about 153 MB when checked.&lt;/p&gt;

&lt;p&gt;Opening it was only the beginning. I also wanted to know whether I could keep turning pages without a crash or an obvious stall.&lt;/p&gt;

&lt;p&gt;The search files and the large PDF placed different demands on the reader. One tested how the reader handled many search results; the other tested opening and navigating a large document.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz28z9yam46q5gfmmquhs.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz28z9yam46q5gfmmquhs.png" alt="Three test data types and their checks: layout metadata, a 30-page searchable PDF with 600 expected LOADTEST600 hits, and a 1,100-page PDF of about 153 MB." width="800" height="1400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2. Different test files answer different questions: recognizing layout settings, finding an expected number of search matches, and navigating a large document. This diagram describes the test design, not a screenshot of test results.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the request specific enough to verify
&lt;/h2&gt;

&lt;p&gt;After preparing the PDFs, I asked AI to add tests or check the app’s behavior with them.&lt;/p&gt;

&lt;p&gt;The development records include requests naming the files and describing the expected output. For a right-to-left PDF with a separate cover, I specified the first page and the left/right arrangement of the following spread.&lt;/p&gt;

&lt;p&gt;Two kinds of tests played different roles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unit tests&lt;/strong&gt; checked results such as detected settings and search counts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI tests&lt;/strong&gt; operated the app and checked its resulting state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The large-PDF UI test checked the file’s size and page count, opened it, and performed 30 consecutive swipes.&lt;/p&gt;

&lt;p&gt;Search testing included checking expected match counts and repeatedly entering search terms while turning pages.&lt;/p&gt;

&lt;p&gt;One useful detail emerged when reviewing those tests: the test’s own checks needed improvement too.&lt;/p&gt;

&lt;p&gt;The repeated-search UI test was strengthened to verify that the page indicator actually changed. Sending a page-turn action was not enough; the test needed evidence that navigation had occurred.&lt;/p&gt;

&lt;p&gt;For a similar request now, I would write down three things first:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which file should the test use? What should it do? What observable result counts as a pass?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That structure helps when asking AI to write a test. It also makes the result easier to interpret later.&lt;/p&gt;

&lt;h2&gt;
  
  
  A passing test has a limited scope
&lt;/h2&gt;

&lt;p&gt;Some checks passed. Others did not reach a confirmed passing result.&lt;/p&gt;

&lt;p&gt;After the 30-swipe test succeeded, I also investigated whether the slider could navigate accurately to a particular page in the 1,100-page PDF.&lt;/p&gt;

&lt;p&gt;That work involved further changes to the test, including handling the difference between spread indices and PDF page counts, and parsing a number displayed with a thousands separator. Later runs did not reach a final passing report.&lt;/p&gt;

&lt;p&gt;The recorded exit code alone did not establish that the app itself was at fault.&lt;/p&gt;

&lt;p&gt;Using the same file did not make these the same test. Successful page turns did not prove accurate slider navigation.&lt;/p&gt;

&lt;p&gt;The search results had limits too. Checking match counts and page changes did not establish pixel-perfect highlight alignment. No pixel-by-pixel image comparison was performed, and the large-PDF checks did not include numerical memory measurements.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcka0wipkwi5cc4h93vjo.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcka0wipkwi5cc4h93vjo.png" alt="Historical Simulator results: PDF settings were recognized, search counts and page changes were checked, and 30 consecutive swipes passed. UI layout requires a separate check. Pixel comparison was not performed, slider accuracy had no confirmed pass, and memory usage was not measured." width="800" height="1180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3. A summary of the recorded Simulator results and their limits. UI layout requires a separate check, highlight positions were not compared pixel by pixel, slider accuracy had no final confirmed pass, and memory usage was not measured.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A passing test was reassuring. I also wanted to be able to explain what that reassurance was based on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Leave a check you can repeat
&lt;/h2&gt;

&lt;p&gt;Testing began with opening my own books and seeing how the app felt. Preparing shareable PDFs gave me a more repeatable way to check specific behavior.&lt;/p&gt;

&lt;p&gt;The useful combination was:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A small input with known conditions.&lt;/li&gt;
&lt;li&gt;An action and an expected result.&lt;/li&gt;
&lt;li&gt;A record of the outcome, including anything still unverified.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A few clearly numbered pages can make a layout problem easier to discuss. A search term with a known count can turn a vague impression into a checkable result.&lt;/p&gt;

&lt;p&gt;AI helped create the data and the test code. I still needed to decide which conditions mattered, what counted as success, and how far the results supported my conclusions.&lt;/p&gt;

&lt;p&gt;What small test files or fixtures have helped you catch regressions in your own projects?&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Source and code:&lt;/strong&gt; Adapted and reorganized from &lt;a href="https://qiita.com/tyamada22/items/021de2e09cdda239f24c" rel="noopener noreferrer"&gt;my Japanese development article on Qiita&lt;/a&gt;. The &lt;a href="https://github.com/tyamada/MihirakiPDFViewer" rel="noopener noreferrer"&gt;source code and test data are available on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The repository includes later changes. The results discussed here describe the historical development records and Simulator checks identified above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI disclosure:&lt;/strong&gt; I used AI assistance to organize and draft this English article and to help create the explanatory diagrams. The development experiences and test results described here are based on my records.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ios</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>Why Two-Page PDF Layouts Were Harder Than I Expected</title>
      <dc:creator>Takuma Yamada</dc:creator>
      <pubDate>Fri, 13 Nov 2026 01:10:53 +0000</pubDate>
      <link>https://dev.to/tyamada/why-two-page-pdf-layouts-were-harder-than-i-expected-47fg</link>
      <guid>https://dev.to/tyamada/why-two-page-pdf-layouts-were-harder-than-i-expected-47fg</guid>
      <description>&lt;p&gt;Two PDF pages overlapped on the screen. After another fix, they moved too far apart. Later, the pages looked better, but search highlights no longer lined up with the text.&lt;/p&gt;

&lt;p&gt;I was building &lt;strong&gt;MihirakiPDFViewer&lt;/strong&gt;, an iPad PDF reader for books I had scanned. I wanted to read them as two-page spreads, with an option to show the cover on its own. AI helped me write and revise the code, but deciding whether a fix actually worked took repeated use and more precise descriptions of the expected behavior.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/tyamada/building-an-ipad-pdf-reader-with-ai-what-i-learned-beyond-generating-code-2hmc"&gt;Part 1&lt;/a&gt;, I described the broader development process. This time, I want to focus on one deceptively small feature: putting two pages next to each other.&lt;/p&gt;

&lt;p&gt;This is a development retrospective for beginners, rather than a complete PDF rendering tutorial. The diagrams below explain the layout problems; they are not screenshots from the original debugging sessions.&lt;/p&gt;

&lt;h2&gt;
  
  
  A layout fix needs a visible target
&lt;/h2&gt;

&lt;p&gt;My early attempts produced overlapping pages, shifted pages, and unwanted space between them. Changing the layout could improve one symptom while leaving another behind.&lt;/p&gt;

&lt;p&gt;A report that the code was fixed was useful as a starting point. I still needed to open the PDF and check the result.&lt;/p&gt;

&lt;p&gt;The request became clearer when I separated three requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preserve each page's aspect ratio.&lt;/li&gt;
&lt;li&gt;Keep both pages within the available reading area.&lt;/li&gt;
&lt;li&gt;Make their inner edges meet at the center of the spread.&lt;/li&gt;
&lt;/ul&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy2lvgsymx9m4qz3lnuu8.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy2lvgsymx9m4qz3lnuu8.png" alt="Two spreads with the same page size: the upper one has an unwanted gap, while the lower one joins both inner edges at the center." width="800" height="1110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1. The same viewport and page size can produce different spreads. The vertical line marks the center; the lower example places both inner edges on it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The distinction between a page's container and its visible content mattered. A container can occupy half the screen while a page scaled to fit inside it is narrower. Centering the visible page inside that container can leave an unwanted gap near the spine.&lt;/p&gt;

&lt;p&gt;Looking at page dimensions, scale, and position helped make the problem concrete. Asking to remove the gap was more useful when I could also say which edges should meet and which proportions should stay the same.&lt;/p&gt;

&lt;p&gt;My main lesson was to describe the expected picture before requesting another layout change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Right-to-left reading involves more than reversing things
&lt;/h2&gt;

&lt;p&gt;Japanese books also made page order a separate problem. During development, a right-to-left configuration opened on the last page instead of the beginning.&lt;/p&gt;

&lt;p&gt;I needed to distinguish three decisions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Which pages belong in the same spread?&lt;/li&gt;
&lt;li&gt;Which page appears on the left or right?&lt;/li&gt;
&lt;li&gt;Which spread appears first, and how does navigation move through the document?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These decisions are related, but reversing all of them together does not automatically produce the intended reading experience.&lt;/p&gt;

&lt;p&gt;Here is a small example. The numbers are PDF file positions starting at 1, not printed page labels. Each bracket shows the screen from left to right:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Left-to-right, no separate cover: &lt;strong&gt;[1 | 2] → [3 | 4] → [5]&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Right-to-left, no separate cover: &lt;strong&gt;[2 | 1] → [4 | 3] → [5]&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Right-to-left, cover alone: &lt;strong&gt;[1] → [3 | 2] → [5 | 4]&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fne2l3lv17qsfyz8dbfkv.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fne2l3lv17qsfyz8dbfkv.png" alt="Right-to-left reading sequence with a separate cover: page 1 alone, then page 3 on the left and 2 on the right, then page 5 on the left and 4 on the right." width="800" height="1420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2. A five-page example with a separate cover and right-to-left reading. Downward arrows show the sequence of spreads, not the direction of a swipe gesture.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Eventually, page grouping was extracted into a helper, &lt;code&gt;PDFPageGrouping&lt;/code&gt;, that works with arrays of page indices independently of PDFKit objects. That made the pairing rules easier to inspect and test separately from the view.&lt;/p&gt;

&lt;p&gt;For a beginner, the useful idea is simple: write down a tiny example with numbered pages before working on the full reader. A five-page document makes the cover rule and left/right placement easier to discuss. Without a separate cover, page 5 is left unpaired. With the cover shown alone, as in Figure 2, the remaining four pages form two complete spreads.&lt;/p&gt;

&lt;p&gt;Those examples still need to be checked in the actual interface. Correct groups alone do not prove that the initial selection or navigation behaves correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Moving the page also affects search highlights
&lt;/h2&gt;

&lt;p&gt;Another problem appeared when search found the right text but the highlight was drawn in the wrong place.&lt;/p&gt;

&lt;p&gt;The page image was positioned according to its alignment in the spread, while the highlight calculation still assumed a centered page. Both calculations could look reasonable in isolation and still disagree on the screen.&lt;/p&gt;

&lt;p&gt;The fix was to use the same page-origin calculation for both the image and its highlights. Here, the origin means the on-screen position of the page's top-left corner. The shared helper, &lt;code&gt;alignedPageOriginX&lt;/code&gt;, supplies the horizontal part of that position.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr3opqd7o9dx309ohoria.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr3opqd7o9dx309ohoria.png" alt="A search highlight is shifted when it uses a different horizontal origin from the page image, and aligned when both share the same origin." width="800" height="1110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3. Blue marks the page's left edge. In the upper example, the highlight uses a different horizontal origin, shown in orange. In the lower example, both use the same origin, so the highlight covers the text.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This was a useful reminder that a page and its overlays form one visual feature. After changing page placement, I needed to check search results as well as the page itself.&lt;/p&gt;

&lt;p&gt;The broader lesson applies to image editors, document viewers, and other interfaces with annotations: when the underlying content moves or scales, check everything drawn on top of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would write before the next layout change
&lt;/h2&gt;

&lt;p&gt;My expectations also changed through daily reading. For example, I initially asked for the pages to shrink when controls appeared. After using that behavior, I reconsidered the request. Some revisions came from discovering what felt better, rather than from a failure to implement the original instruction.&lt;/p&gt;

&lt;p&gt;For the next change, I would start with a short description like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Open a five-page PDF containing searchable text in right-to-left spread mode, with the cover shown alone. The first view should show page 1. The next spread should show page 3 on the left and page 2 on the right. The pages should keep their proportions, fit within the reading area, and meet at the center. Search for a word on either page and confirm that its highlight stays aligned. Show and hide the controls, then check the page size and position again.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This gives me something observable to verify after an AI-assisted change. It also helps separate a bug from a requirement I have changed my mind about.&lt;/p&gt;

&lt;p&gt;Two-page viewing taught me to be more specific about what I expected to see, to separate page grouping from navigation, and to check overlays whenever page geometry changed.&lt;/p&gt;

&lt;p&gt;If you have built a reader or another interface with paired content, which assumption about ordering or positioning surprised you?&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Source and code:&lt;/strong&gt; Adapted and reorganized from my Japanese development notes on Qiita (&lt;a href="https://qiita.com/tyamada22/items/7dd6b653e10962d6fa9c" rel="noopener noreferrer"&gt;first article&lt;/a&gt;, &lt;a href="https://qiita.com/tyamada22/items/5298a050636d8dc8a10d" rel="noopener noreferrer"&gt;second article&lt;/a&gt;). The project is on &lt;a href="https://github.com/tyamada/MihirakiPDFViewer" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI disclosure:&lt;/strong&gt; I used AI assistance to organize and draft this English article and to help create the explanatory diagrams. The development experiences described here are my own.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>ai</category>
      <category>beginners</category>
      <category>swift</category>
    </item>
    <item>
      <title>Building an iPad PDF Reader with AI: What I Learned Beyond Generating Code</title>
      <dc:creator>Takuma Yamada</dc:creator>
      <pubDate>Tue, 03 Nov 2026 11:18:59 +0000</pubDate>
      <link>https://dev.to/tyamada/building-an-ipad-pdf-reader-with-ai-what-i-learned-beyond-generating-code-2hmc</link>
      <guid>https://dev.to/tyamada/building-an-ipad-pdf-reader-with-ai-what-i-learned-beyond-generating-code-2hmc</guid>
      <description>&lt;p&gt;I read books I have scanned myself. I wanted a more comfortable way to read those PDFs on my iPad.&lt;/p&gt;

&lt;p&gt;My main frustration was how PDF readers handled right-to-left reading and cover pages. I wanted the cover to appear on its own, followed by two-page spreads. When a PDF contained reading-direction and page-layout settings, I wanted the reader to use them automatically.&lt;/p&gt;

&lt;p&gt;Some free viewers I tried offered related options, but I could not find one that opened my PDFs the way I expected. So I started building a reader for my own needs.&lt;/p&gt;

&lt;p&gt;The app is called &lt;strong&gt;MihirakiPDFViewer&lt;/strong&gt; in English and &lt;strong&gt;見開きPDFビューア&lt;/strong&gt; in Japanese. &lt;em&gt;Mihiraki&lt;/em&gt; is a Japanese word for the two facing pages of an open book.&lt;/p&gt;

&lt;p&gt;This is a look at what happened after I began asking AI to write the code: repeated layout fixes, problems discovered through daily use, tests with predictable results, and checks on the version prepared for App Store submission.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe028rvi4dmvefsds14j6.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe028rvi4dmvefsds14j6.png" alt="MihirakiPDFViewer displaying two facing pages of an English sample comic on an iPad." width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1. An earlier build displaying an English sample PDF in two-page view.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Returning to iOS development after almost ten years
&lt;/h2&gt;

&lt;p&gt;I had developed and published an iOS app independently in 2016. However, almost ten years had passed. This time, I was working with SwiftUI for the interface and PDFKit for PDF handling.&lt;/p&gt;

&lt;p&gt;I began development in July 2026. My initial workflow involved two computers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On Windows, I used Cline with a local Gemma model running through LM Studio to generate and modify code.&lt;/li&gt;
&lt;li&gt;On a Mac, I built the app in Xcode and checked it in the Simulator and on a physical iPad.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From August 15, I used Gemma for code changes and ChatGPT for bug fixes. On August 25, I moved the development work entirely to ChatGPT, continuing with Codex inside Xcode.&lt;/p&gt;

&lt;p&gt;In my setup, dealing with syntax errors in generated code made it difficult to see when I would finish. That was my reason for changing tools, rather than the result of a controlled comparison between models.&lt;/p&gt;

&lt;p&gt;The tools changed, but the cycle remained much the same: describe the behavior I wanted, change the code, build the app, use it, and decide what to ask next.&lt;/p&gt;

&lt;h2&gt;
  
  
  “Fixed” was the beginning of another check
&lt;/h2&gt;

&lt;p&gt;Two-page layout required repeated corrections.&lt;/p&gt;

&lt;p&gt;In an early version, the pages overlapped. I reported the problem and received a response saying it had been fixed. When I ran the app again, the pages were still misaligned, but in a different way.&lt;/p&gt;

&lt;p&gt;Other attempts left an unwanted gap between the pages or produced awkward margins. “Display two pages side by side” turned out to leave several questions unanswered.&lt;/p&gt;

&lt;p&gt;Where should their inner edges meet? How should pages of different sizes fit into the available space? Which dimensions should determine the scale?&lt;/p&gt;

&lt;p&gt;I added debugging information showing dimensions and scale values. My requests became more specific: preserve the aspect ratio, fit the pages within the available area, and place their inner edges together at the center.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e4c0slqv9kdld8jvjp8.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e4c0slqv9kdld8jvjp8.png" alt="Top: two equal-sized pages separated by an unwanted gap. Bottom: the same pages meeting at the center." width="800" height="1130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2. The same-sized pages with an unwanted gap (top) and with their inner edges meeting at the center (bottom). This schematic illustrates the layout requirement; it is not a reconstruction of a historical screenshot.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Right-to-left reading added another distinction. The left and right positions within a spread, the sequence of spreads, and the initial reading position all needed checking. Swapping two pages did not settle the whole problem.&lt;/p&gt;

&lt;p&gt;I learned to describe a bug through its conditions and expected result. An AI completion message was useful, but I still needed to open the document and inspect the output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Daily use changed requirements I had written myself
&lt;/h2&gt;

&lt;p&gt;Once the basic features worked, I continued reading with the app on my iPad almost every day.&lt;/p&gt;

&lt;p&gt;One issue was rendering quality. PDFs looked less sharp than they did in other apps. I requested high-quality rendering and sharpening options. After that change, even the normal rendering mode looked better.&lt;/p&gt;

&lt;p&gt;The code changes showed that the rendering path used by normal mode had also changed. However, I had not preserved before-and-after images under identical conditions. I could identify the implementation change and describe my observation, but I could not establish the exact cause of the improvement.&lt;/p&gt;

&lt;p&gt;Another issue came directly from my own instructions.&lt;/p&gt;

&lt;p&gt;Initially, I had asked for the PDF to shrink when the reading controls appeared. The app did that, but while reading, I found the changing text size distracting. I reconsidered the interface layout.&lt;/p&gt;

&lt;p&gt;Testing was therefore about more than finding implementation mistakes. It also helped me discover when a requirement I had chosen did not feel good in practice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turning “it works” into something repeatable
&lt;/h2&gt;

&lt;p&gt;At first, I tested with PDFs of books I had scanned. I could not distribute those files with the source code, so I needed test documents that other people could use too.&lt;/p&gt;

&lt;p&gt;I prepared shareable PDFs with known properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading-direction and page-layout settings.&lt;/li&gt;
&lt;li&gt;Search terms with known occurrence counts.&lt;/li&gt;
&lt;li&gt;Large file sizes and high page counts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A document containing a search term 600 times gives a test a concrete expected result. A right-to-left document with a cover gives it an expected sequence of page arrangements.&lt;/p&gt;

&lt;p&gt;Instead of asking only whether a feature worked, I could specify a file, an operation, and an expected outcome.&lt;/p&gt;

&lt;p&gt;Reading-session restoration provided another useful example. Switching to other apps and returning preserved my page. Ending the app’s process and relaunching it returned me to the file picker.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fntpb39xf1p5qeacxdatj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fntpb39xf1p5qeacxdatj.png" alt="Before the fix, returning from other apps preserved page 15 of 30, while ending the process and relaunching returned to the file picker." width="800" height="1480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3. A schematic based on historical Simulator test records. The process was terminated for the test; an actual operating-system termination caused by low memory was not reproduced.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The state could remain available while the process was alive, but saving and restoring it across launches required additional work. That distinction led to changes for restoring the document and reading position.&lt;/p&gt;

&lt;p&gt;I also discovered that the rendering options reverted to their defaults after relaunching. Being able to turn a setting on was only one part of its behavior.&lt;/p&gt;

&lt;p&gt;These automated tests were performed in the Simulator at the time. Their scope mattered. Matching search counts did not prove that highlights appeared at the correct coordinates. Successfully importing a local file did not establish that the complete iCloud Drive interaction had been tested.&lt;/p&gt;

&lt;p&gt;Keeping those boundaries in the records helped me understand what still needed checking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Submission preparation expanded the work beyond code
&lt;/h2&gt;

&lt;p&gt;Preparing for App Store submission made me think about someone opening the app without having my documents or development context.&lt;/p&gt;

&lt;p&gt;I created shareable sample PDFs. In the development version, I also added a way to download and open them from inside the app.&lt;/p&gt;

&lt;p&gt;The sample needed to match the task. A PDF made entirely from images could demonstrate two-page viewing, but it could not demonstrate text search. A useful-looking example was not automatically useful test data.&lt;/p&gt;

&lt;p&gt;I also kept the submitted version separate from ongoing development. Changes to the working code did not update the binary already submitted for review.&lt;/p&gt;

&lt;p&gt;While waiting for review, I expanded my checks to a saved distribution file and the corresponding source. That inspection revealed additional work involving an in-app privacy-policy link and a privacy manifest.&lt;/p&gt;

&lt;p&gt;Apple did not identify those findings as the reason for the extended review. The lesson I took from the inspection was to check the contents of the packaged app prepared for submission, as well as the submission status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review status checked on November 3, 2026 (Japan Standard Time):&lt;/strong&gt; App Store Connect still showed version 1.0.4 (build 10) as “In Review.” The three supporter-icon in-app purchases submitted alongside it were also “In Review.”&lt;/p&gt;

&lt;p&gt;This status update is based on a direct check of App Store Connect. The development experiences described above cover the earlier work documented through October 27, 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would carry into my next project
&lt;/h2&gt;

&lt;p&gt;AI helped me create and modify code, add tests, and consider improvements. Throughout the process, I continued using the app, describing unexpected behavior, and checking the results of changes.&lt;/p&gt;

&lt;p&gt;For my next small app, I would establish three habits earlier:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Record problems with reproduction steps.&lt;/strong&gt; Include the document, actions, observed behavior, and expected result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prepare shareable test inputs.&lt;/strong&gt; Known inputs and outcomes make repeated checks more useful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record the version and environment.&lt;/strong&gt; Distinguish development builds from submitted artifacts, and Simulator results from physical-device checks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I did not have all of this in place at the start. My development process improved alongside the app, as each problem gave me a reason to make the next check more precise.&lt;/p&gt;

&lt;p&gt;What problems have you discovered only after using your own app in everyday life?&lt;/p&gt;




&lt;p&gt;This article was adapted and reorganized from my Japanese &lt;a href="https://qiita.com/tyamada22/stocks/d4e7a344a6c04dc1115f" rel="noopener noreferrer"&gt;Qiita development series&lt;/a&gt;. The &lt;a href="https://github.com/tyamada/MihirakiPDFViewer" rel="noopener noreferrer"&gt;source repository&lt;/a&gt; includes changes made after some of the development stages described here.&lt;/p&gt;

&lt;p&gt;I used generative AI to help structure, draft, and translate this article. It is based on my development experience and a review of historical code and work logs.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>ai</category>
      <category>testing</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
