Skip to content

Potential fix for iOS release build mode #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lemz90
Copy link

@lemz90 lemz90 commented Mar 26, 2025

Problem

Our app, as well as the example app, fails to build on iOS in release mode due to MockReaderUI being unavailable. This is particularly relevant for Flutter developers who want to use the plugin without manually managing iOS dependencies -- although I was never able to get it to build by adding pod MockReaderUI to the app's Podfile.

➜  example git:(main) ✗ pwd              
/Users/--------/Workspace/------/mobile-payments-sdk-flutter/example

➜  example git:(main) ✗ flutter build ios
Building com.squareup.squareMobilePaymentsSdkExample for device (ios-release)...
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Developer identity "Apple Development: ------------ (---------)" selected for iOS code signing
Running Xcode build...                                                  
Xcode build done.                                           43.2s
Failed to build iOS app
Swift Compiler Error (Xcode): No such module 'MockReaderUI'
/Users/-------/Workspace/-------/mobile-payments-sdk-flutter/ios/Classes/Modules/ReaderModule.swift:2:7

Solution

Added conditional compilation for MockReaderUI related code using #if DEBUG to ensure the plugin builds successfully in both debug and release modes. This is a common pattern in iOS development for handling debug-only features.

The solution doesn't require any additional pod or SPM dependencies in the app's Podfile.

Testing

  • Verified successful builds in both debug and release modes
  • Tested without any additional pod or SPM dependencies

Note

While this solution resolves the immediate build issue, I'm open to feedback if there's a more idiomatic approach that the Square team would prefer. Possibly something more on the flutter plugin or cocoapods side of things.

I also haven't tested that MockReader works in flutter debug mode but I assume it would. I thought I'd go ahead and put this up since it got us building release mode. Also wanted to add, this isn't critical for us since we can use my fork in the pubspec.yaml.

@ViniciusSossela ViniciusSossela mentioned this pull request Apr 7, 2025
@tobischw
Copy link

tobischw commented Apr 7, 2025

Thanks for catching this. We had a similar problem on the react-native plugin, and the solution was to simply remove the , configurations: ['Debug'] in our podspec. We have confirmed it is OK for mock reader to ship in production apps (it is very small and has barely any impact, and will not work unless you are in sandbox mode anyway).

I'll defer to my colleagues for the rest of this PR (@brandonjenniges, @tamerbader), and we'll need to publish the new version anyway.

cesar-sosa-hol
cesar-sosa-hol previously approved these changes Apr 8, 2025
Copy link
Collaborator

@cesar-sosa-hol cesar-sosa-hol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fka3
Copy link

fka3 commented Apr 16, 2025

Checking in about what we expect to happen with this; as Tobi noted, you shouldn't need DEBUG to use the MockReader, so I'm inclined to reject the PR... but that means that something else made lemz90 think it was debug-only. That's false, or should be. So what made it seem true??

@lemz90
Copy link
Author

lemz90 commented Apr 18, 2025

Checking in about what we expect to happen with this; as Tobi noted, you shouldn't need DEBUG to use the MockReader, so I'm inclined to reject the PR... but that means that something else made lemz90 think it was debug-only. That's false, or should be. So what made it seem true??

Sorry just circling back to this. I assumed it was Debug only since the podspec had it specified as so. I probably should have made an issue first to identify the correct fix, sorry for the extra complication.

I've updated my branch to remove the , configurations: ['Debug'] specification on the MockReaderUI dependency in the podspec per @tobischw. I've reverted the previous change. This should allow MockReaderUI to be available in all build configurations, which makes more sense given that it's intended to work in sandbox mode regardless of the build configuration.

I've also confirmed that the example app builds in release mode and debug mode.

tobischw
tobischw previously approved these changes Apr 18, 2025
Copy link

@tobischw tobischw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thank you for updating! This aligns with what we do for React Native as well: https://github.com/square/mobile-payments-sdk-react-native/blob/main/mobile-payments-sdk-react-native.podspec#L18

cc @tamerbader @brandonjenniges for releasing, since I know y'all are working on an MPSDK update anyway.

Copy link

@tobischw tobischw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably bump s.version in Podspec as well (patch is fine?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants