-
Notifications
You must be signed in to change notification settings - Fork 883
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
Ability to skip autolinking for dependency for specific ios target #1179
Comments
In my opinion, which is very strong when it comes to options/configuration 😅, auto-linking should be as simple as it can be without the need for configuration. Any further customisation should be done entirely through normal CocoaPods [or Gradle] means. The reason I feel this way is that I think it ends up hurting the user if we try to abstract away things that are already well covered by the amount of docs/issues/stackoverflow/blogs that exist for the underlying tool–in this case CocoaPods. Instead we would have to write and maintain new rn-cli specific documentation, meaning maintainers need to do more work and end-users have less chance of finding the right solution; which is a lose-lose situation. In short, I think auto-linking should:
Thus, I don’t think we should add this feature, furthermore I believe we should remove the ability to exclude pods for specific platforms. It would also be good to outline the above design in the auto-linking doc. |
@anta-semenov So coming back to your original issue, I think your best recourse would be to follow the strategy outlined in point 3 above; which is to:
If this doesn't work, then please let us know! 🙏 |
Not sure if this will work well with my user case.
I would like to use autolinking to install common dependencies, but according to my understanding if I add But I got your point. Will patch this locally. I have one question in how merging of And in my proposal, I didn't mean that there should be |
Can you check what this does? abstract_target 'Main' do
<Common dependencies, around 20>
target "InAppAddAllowed" do
pod 'RNFBAdMob', :path => '../node_modules/@react-native-firebase/admob'
use_native_modules!
end
target "AppWithoutAdd" do
use_native_modules!
end
end If this does not already omit
To be clear, my first comment wasn’t necessarily addressed at you, more so to the other maintainers of this tool and for posterity. I think we are on the same page, we want to be able to control these things in as easy a way as possible. |
Will try today or on monday. But according to code in |
I ended up patching abstract_target 'Main' do
# common dependencies, around 20
use_native_modules!(packages_to_skip: ['RNFBAdMob'])
target "InAppAddAllowed" do
pod 'RNFBAdMob', :path => '../node_modules/@react-native-firebase/admob'
end
target "AppWithoutAdd" do
end
end here is the content of my diff --git a/node_modules/@react-native-community/cli-platform-ios/native_modules.rb b/node_modules/@react-native-community/cli-platform-ios/native_modules.rb
index 2254158..397ca0a 100644
--- a/node_modules/@react-native-community/cli-platform-ios/native_modules.rb
+++ b/node_modules/@react-native-community/cli-platform-ios/native_modules.rb
@@ -12,7 +12,7 @@
require 'pathname'
require 'cocoapods'
-def use_native_modules!(config = nil)
+def use_native_modules!(config = nil, packages_to_skip: [])
if (config.is_a? String)
Pod::UI.warn("Passing custom root to use_native_modules! is deprecated.",
[
@@ -44,6 +44,10 @@ def use_native_modules!(config = nil)
packages.each do |package_name, package|
next unless package_config = package["platforms"]["ios"]
+ if skipped_pod = packages_to_skip.find { |pod_name| package["platforms"]["ios"]["podspecPath"].include? "#{pod_name}.podspec" }
+ Pod::UI.notice "Skipping pod: #{skipped_pod}"
+ next
+ end
podspec_path = package_config["podspecPath"]
|
Hey @Charlie-Hua, that's a great idea. This should make it to the canonical implementation; as niche as the the feature may be, it's incredibly useful for simulator vs real-device-only pods & separation of concerns. We use to it to split out our Unity framework interop. Thanks! |
The skip list is exactly what we need. We have a dependency required only for Android but it has an iOS native module that we don't want. Generally I agree with @alloy, configuration should be easy, but I don't think an exclusion list is at odds with that. |
Note that this feature would also be extremely useful when creating an iOS app clip! For now I'm gonna try @Charlie-Hua's solution which is a very nice workaround this limitation 👍🏼 |
@pot2mayo Did that work for you? I am trying to reduce my app clip size as well. I tried the work-around but I did not see a reduction in size. (I also didn't see any messages in the console about pods being skipped, so I'm not sure that my attempt to copy the patch worked.) Curious if you had success in this. |
There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
@Ross-Landry |
@sa-ma To reduce the App clip, you can use this approach. This way you can use the same base code for both the app and the app clip and only install the Pods necessary for the app clip and in this way not increase the size of the app clip, thanks to @dawidzawada for sharing this approach 💪💪 |
Describe the Feature
We use the same codebase for different apps in appstore, so we have different targets in pod file. For some of the apps we need to remove specific dependencies (for instance, we can't use firebase admob library in target that is aiming for kids due to appstore policy).
Currently in
react-native.config.js
I can disable autolinking only for specific platfrom, but it would be good to be able to skip dependency for specific pod targets as wellPossible Implementations
I can imagine that it could be a specific property in
react-native.config.js
in dependency configuration where I can putt targets that should be excluded from autolinkingI think in
../node_modules/@react-native-community/cli-platform-ios/native_modules
it could be possible to get this property for dependency and skip installation if current target is listedThe text was updated successfully, but these errors were encountered: