# Chapter 8: Final project produces two different views in iOS and macOS?

**URL:** <https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435>\
**Category:** Metal by Tutorials\
**Created:** [April 19, 2023, 5:03am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435 "2023-04-19T05:03:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 5:03am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/1 "2023-04-19T05:03:59Z")

</div>

There seems to be a problem but I can’t track it down

In the debugger I discovered that the macOS version has a much reduced uv Buffer compared to the iOS version if that means anything to you.

---

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 5:09am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/2 "2023-04-19T05:09:31Z")

</div>

I’ve cracked it!!

Replace:

```
vertexDescriptor.layouts[UVBuffer.index] = MDLVertexBufferLayout(stride: MemoryLayout<float2>.stride)

```

with:

```
vertexDescriptor.layouts[UVBuffer.index] = MDLVertexBufferLayout(stride: offset)

```

in _VertexDescriptor.swift_

Now I think that works but it is wrong too. It’s just that _MemoryLayout.stride_ is not big enough and _offset_ is.  
I have no idea why it works for iOS and not for macOS.

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [April 19, 2023, 5:49am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/3 "2023-04-19T05:49:18Z")

</div>

Mine seems to be exactly the same on M1 Mac mini, iPad mini 6 and an M1 iPad Pro.

Also I don’t really understand why that change works for you.

These are the two buffers involved:

 ![Screenshot 2023-04-19 at 3.45.20 pm](https://files.chunter.kodeco.com/original/3X/a/9/a936edd98715a210d6d0496db0ec2519921831d1.png)

`VertexBuffer` (buffer(0)) holds

```auto
[Position, Normal, Position, Normal, Position, Normal,...]

```

So the stride of `VertexBuffer` is the length of Position + length of Normal, which is `float3.stride + float3.stride` (32).

`UVBuffer` (buffer(1)) holds

```auto
[UV, UV, UV, UV, UV, ...]

```

So the stride of `UVBuffer` is `float2.stride` (8)

In **Common.h** , are these your `BufferIndices`?

```auto
typedef enum {
  VertexBuffer = 0,
  UVBuffer = 1,
  UniformsBuffer = 11,
  ParamsBuffer = 12
} BufferIndices;

```

---

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 6:30am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/4 "2023-04-19T06:30:49Z")

</div>

Screenshots after loading untouched from your repository:

first iOS

 ![Screenshot 2023-04-19 at 16.18.01](https://files.chunter.kodeco.com/original/3X/d/a/da8d146efa2ccf02f9b16b9704e345009c4b2a47.jpeg)

then macOS

 ![Screenshot 2023-04-19 at 16.17.13](https://files.chunter.kodeco.com/original/3X/c/b/cb3b3106bb0235d837e67d51e46841c108c6a898.png)

After making only the change I described, we have iOS unchanged and macOS:

 ![Screenshot 2023-04-19 at 16.19.00](https://files.chunter.kodeco.com/original/3X/3/9/3961be11575c82c9f1e49a639a113abdf280f503.png)

Indeed they are still different in that they point to different textures but now the macOS is coherent. The same effect occurs in the start project of the following chapter.

In the debugger for the iOS version I get:

 ![Screenshot 2023-04-19 at 16.27.48](https://files.chunter.kodeco.com/original/3X/b/2/b2a0479656fec474632b47b3daa15cf50090a979.png)  
suggesting some 34 uv values

while in the macOS (old version) I have only 9 values:

 ![Screenshot 2023-04-19 at 16.28.46](https://files.chunter.kodeco.com/original/3X/d/4/d48ac195e5d071e3c7a1c85ae70d294500878379.png)

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [April 19, 2023, 7:48am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/5 "2023-04-19T07:48:43Z")

</div>

Interesting. Would you be able to zip up the project and post here please? (You’ll have to delete everything in the Models folder first - I can use mine)

Just so I can see what happens here? I can’t see why it would be different though. I have the same UV coordinates as your iOS one.

It’s the final untouched project from the chapter?

I can’t remember what your devices are.

macOS model and GPU?  
iOS device and OS?

Just in case yours has some kind of corruption - here’s my final project:

[Textures.zip](https://forums.kodeco.com/uploads/short-url/aKUxb6eTo0w0HPjshwoVXYwMmG7.zip) (2.6 MB)

I had to remove everything in the Models folder because it was too big, so you’ll have to copy them over before running.

---

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 10:15am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/6 "2023-04-19T10:15:09Z")

</div>

Hi Caroline  
I closed all files in xCode and shut down xCode.  
I rebooted my machine.  
I loaded a completely untouched download of chapter 8 final (attached as zip)  
I ran in iOS iPhone 14 pro simulator (got the result shown above)  
I ran on my macBook (and got the result shown above)  
I changed the stride as described and got the good result shown above.

My equipment is as follows:

 ![Screenshot 2023-04-19 at 20.11.02](https://files.chunter.kodeco.com/original/3X/5/e/5e359130f6b3111f7c682003752a09f44723c930.png)  
 ![Screenshot 2023-04-19 at 20.11.31](https://files.chunter.kodeco.com/original/3X/8/1/813fc757bf4c9676b1215372d12b540341a2a15f.png)

My zip is 6.9MB and I’m told max upload is 4MB. Can I send it any other way?

All the best

Don

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [April 19, 2023, 10:32am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/7 "2023-04-19T10:32:29Z")

</div>

Did you try it on your iDevice? Sometimes Simulator doesn’t exactly reproduce what happens on the GPU. My Simulator works fine, but it is on an M1 Mac mini.

PM sent with my email address.

---

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 11:05am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/8 "2023-04-19T11:05:19Z")

</div>

haha

it works correctly on my iPhone 12

---

<div class="post-metadata">

**Author:** ![tchelyzt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tchelyzt/32/111572_2.png) [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Post date:** [April 19, 2023, 11:13am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/9 "2023-04-19T11:13:16Z")

</div>

the mac version needs a stride \>= 32  
???

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [April 19, 2023, 11:15am UTC](https://forums.kodeco.com/t/chapter-8-final-project-produces-two-different-views-in-ios-and-macos/186435/10 "2023-04-19T11:15:23Z")

</div>

That might be a possibility on the older GPUs. Although I don’t remember having this problem on my older MacBook Pro in the first edition of the book.
