0

I created a react-native module. For iOS builds on Intel architecture I need the custom CFlags -maes -mpclmul

Right now it works if the "consuming" project configures those for my module by clicking Pods -> "My Module" -> Build Settings -> Other C Flags

But I don't want to force the users of my module to do that. I want to configure this in my module so that after pod install the config is automatically copied with my module.

I tried opening the "xcodeproj" file of my Module and setting the config there, but after trying it out in a project and installing my module with pod install the CFlags are not there and the build step fails because of that.

Is there any way to "automate" the setting of custom CFlags?

Laurenz Honauer
  • 254
  • 1
  • 12

1 Answers1

0

Open module's .podspec file.

Inside the .podspec file, you can use the pod_target_xcconfig configuration to set the custom CFlags based on the architecture.

Pod::Spec.new do |spec|
  # ... other spec configurations ...

  spec.pod_target_xcconfig = {
    'OTHER_CFLAGS[sdk=iphonesimulator*][arch=x86_64]' => '-maes -mpclmul'
  }
end

In this configuration, 'OTHER_CFLAGS[sdk=iphonesimulator*][arch=x86_64]' specifies that the custom CFlags should only be applied when the build is for the iOS Simulator (iphonesimulator) and the architecture is Intel (x86_64).

Save the changes to your .podspec file. Using this approach, the custom CFlags will be automatically applied when users install your module using CocoaPods and meet the specified architecture condition. This method avoids the use of the post_install hook and simplifies the configuration.

Laurenz Honauer
  • 254
  • 1
  • 12