LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.58k stars 206 forks source link

Instructions for testing the gameboy camera integration on real iOS devices #639

Closed logicalmoody closed 1 week ago

logicalmoody commented 1 week ago

I am taking a stab at implementing multiple camera support for feature request #637 but I have not been able to figure out how to test my changes on my iPhone. I am able to compile the .app for iOS but I am unable to load that into Xcode to run on device as I expected and have done for other iOS apps.

@LIJI32 could you please share your method for testing changes on physical devices? I am really stoked to get wide angle and telephoto support working for the gameboy camera for newer iPhones.

LIJI32 commented 1 week ago

My device is jailbroken, which makes things easier for me. For non-jailbroken devices, you can use Sideloadly to re-sign the app and install it on your device. Then, launch the app on your phone. In Xcode, have any iOS project open and your device selected as it's target, and select Debug > Attach from the menu bar to attach the debugger. Apple, unfortunately, likes making it very cumbersome to resign and debug iOS apps if you don't build them with Xcode. Let me know if you're having any further troubles.

logicalmoody commented 1 week ago

I nearly got the application loaded on my device but I am having issues with code signing – Unless I'm mistaken, it seems that since I don't have a paid developer account and thus no way to create a provisioning profile, I am unable to load the app on my phone via Xcode. Xcode can manage provisioning profiles for you but it looks like the project has to built through Xcode, which this one is not.

Any tips would be appreciated, but I understand why you're testing with a jailbroken iPhone – way easier.

In the meantime, I wrote the code I intend to test in Draft PR #642, following the patterns I saw in the project and the Apple documentation. If you get a chance maybe you could help me test this on a real device – I tested similar code in a demo project on my device that I didn't have any code signing issues with, so I'm reasonably confident that it should work with minor tweaking.

LIJI32 commented 1 week ago

A free account is actually enough to create provisioning profiles, the only caveat is that they expire after 7 days (after which you need to create a new profile, Sideloadly should do that for you). I'll have a look at your PR soon.

logicalmoody commented 1 week ago

I noticed that I can create 7 day provisioning profiles, but they don't appear to work for me unless the app is built and signed by Xcode – I'm sure this is user error and I am still tinkering with it to see what I'm doing wrong.

I appreciate you looking at my PR in the meantime!

logicalmoody commented 1 week ago

I managed to get this resolved and am happily testing my changes – thanks!

EDIT: Here's how I got this working, in case a future hapless developer comes across this same issue.

  1. Create a new Xcode iOS hello world app called SameBoy
  2. Select a bundle identifier and my personal team in the project settings
  3. Update all bundle identifier and team references in iOS/Info.plist and iOS/sideload.entitlements
  4. Build SameBoy for iOS
  5. Locate the automatically created provisioning profile in ~/Library/MobileDevice/Provisioning Profiles/
  6. Inspect the profile with security cms -D -I /path/to/profile
  7. Copy the keys from this provisioning profile into iOS/sideload.entitlements
  8. Codesign the built application from the terminal, injecting sideload.entitlements with the --entitlements flag. This will re-sign the app with the necessary entitlements from the provisioning profile that your phone is expecting to get from Xcode
  9. Open the Devices and Simulators tab and manually add the built application. If everything matches (name, bundle id, etc), it will install on top of the hello world app using that provisioning profile

Obviously this is far from ideal. However, this works if you are as stuck as I was, and doesn't require any third party tools or jailbreaking.