fermoya / cocoapods-catalyst-support

Ruby extensions to help you configure your pods project so that pods not compiled for Catalyst can still be used for iOS devices
MIT License
111 stars 18 forks source link

When building for Mac I'm still getting Debug-maccatalyst/XXXX/XXXX.modulemap' not found #13

Closed pnome closed 3 years ago

pnome commented 3 years ago

First of all, thank you for what seems to be a very promising and helpful script! If I can get this working, I'll be very happy :)

It's probable that the issue I'm having is user error, but I think I followed all of the instructions to the letter.

I'm using the latest version of the script.

Here's a quick 2 min video showing the error https://www.loom.com/share/3a3a5041c6fb4945bfe01de35a7e46b2

Note that, although this is showing errors for 'ConfettiView', if I remove that pod and all references, I just get the same error but relating to the next incompatible pod.

When I run pod update, the log shows the following:

#### Unsupported Libraries ####
["DeallocationChecker", "DeallocationChecker", "ConfettiView-NSHipster", "ConfettiView-NSHipster", "FirebaseCrashlytics", "Firebase", "FirebaseAnalytics", "Firebase", "FirebaseAnalytics", "FirebaseCore", "FirebaseCrashlytics", "FirebaseCore", "FirebaseInstallations", "GoogleAppMeasurement", "GoogleUtilities", "nanopb", "FirebaseCore", "FirebaseInstallations", "PromisesObjC", "GoogleDataTransport", "nanopb", "FirebaseCore", "FirebaseInstallations", "GoogleAppMeasurement", "GoogleUtilities", "nanopb", "GoogleUtilities", "FirebaseCoreDiagnostics", "FirebaseCore", "FirebaseInstallations", "PromisesObjC", "GoogleDataTransport", "nanopb", "FirebaseCore", "PromisesObjC", "GoogleUtilities", "GoogleUtilities", "nanopb", "nanopb", "PromisesObjC", "GoogleUtilities", "FirebaseCoreDiagnostics", "GoogleDataTransport", "GoogleUtilities", "nanopb", "FirebaseCore", "PromisesObjC", "GoogleUtilities", "GoogleUtilities", "nanopb", "nanopb", "PromisesObjC", "GoogleUtilities", "FirebaseCoreDiagnostics", "GoogleDataTransport", "GoogleUtilities", "nanopb", "nanopb", "PromisesObjC", "GoogleDataTransport", "GoogleUtilities", "nanopb", "nanopb", "PromisesObjC", "nanopb", "PromisesObjC"]

#### Unsupported dependencies ####
["ConfettiView-NSHipster", "DeallocationChecker", "Firebase", "FirebaseAnalytics", "FirebaseCore", "FirebaseCoreDiagnostics", "FirebaseCrashlytics", "FirebaseInstallations", "GoogleAppMeasurement", "GoogleDataTransport", "GoogleUtilities", "PromisesObjC", "nanopb", "c++", "sqlite3", "CoreTelephony"]

#### Frameworks not to be included in the Archive ####
["ConfettiView-NSHipster.framework", "DeallocationChecker.framework", "Firebase.framework", "FirebaseAnalytics.framework", "FirebaseCore.framework", "FirebaseCoreDiagnostics.framework", "FirebaseCrashlytics.framework", "FirebaseInstallations.framework", "GoogleAppMeasurement.framework", "GoogleDataTransport.framework", "GoogleUtilities.framework", "PromisesObjC.framework", "nanopb.framework", "FirebaseAnalytics.framework", "GoogleAppMeasurement.framework", "CoreTelephony.framework"]

#### Resources not to be included in the Archive ####
[]

However, when I try to run on Mac I get the following error <unknown>:0: error: module map file '/Users/amsneve/Library/Developer/Xcode/DerivedData/PolyNome-giehslaoapcxtwcaqjaiyulmarvy/Build/Products/Debug-maccatalyst/ConfettiView-NSHipster/ConfettiView.modulemap' not found

If I go to Pods -> Targets and select ConfettiView-NSHipster, I can see that it has been set to iOS in platforms.

If I search my project for ConfettiView I can see that I've wrapped all imports and any code referencing it with #if !targetEnvironment(macCatalyst) #endif

The only other places it shows up are in the Pods-AllTargets-PolyNome.debug.xcconfig

E.g. LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AirTurnUI" "${PODS_CONFIGURATION_BUILD_DIR}/Amplitude" "${PODS_CONFIGURATION_BUILD_DIR}/BNHtmlPdfKit" "${PODS_CONFIGURATION_BUILD_DIR}/CMPopTipView" "${PODS_CONFIGURATION_BUILD_DIR}/ConfettiView-NSHipster"

OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/ConfettiView-NSHipster/ConfettiView.modulemap"

Then also in Pods.xcodeproj //:configuration = Debug ARCHS = $(ARCHS_STANDARD)

//:completeSettings = none

There are some other places which I showed in the video.

Please let me know if I've missed some crucial step, or if you have any ideas about how I can fix this.

Thanks again, Joe

fermoya commented 3 years ago

Hi @pnome, can you share your Podfile please? I've just run:

def catalyst_unsupported_pods
  [
    "Firebase/Analytics",
    'ConfettiView-NSHipster',
    'Firebase/Crashlytics',
    'DeallocationChecker'
  ]
end

in a Sample Project and all worked well. You might have a more complex configuration in your Podfile and/or your project.

Could you also please complete this table for me? Tool Version Notes
Ruby <e.g. 2.6.0> ruby --version
Cocoapods <e.g. 1.10.0> pod --version
Xcode <e.g. 12.4.4> xcodebuild -version
pnome commented 3 years ago

Thanks for the quick response. I have two targets, PolyNome and PolyNomePro which utilise the same pods. There are also a few lines in my podfile that I've added to attempt to fix certain things in the past - they have comments to explain what.

Tool Version
Ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
Cocoapods 1.10.1
Xcode 12.4, Build version 12D4e

Here's my podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

#Removing some stuff for Catalyst MacOS builds. NOTE: Go to end of pod list and specify those pods that shouldn't be added for Catalyst
load 'remove_ios_only_frameworks.rb'

# Workaround duplicate Assets.car issue https://github.com/CocoaPods/CocoaPods/issues/8122
# This impacts the new Xcode build system
install! 'cocoapods', :disable_input_output_paths => true

# Note: There are no targets called "AllTargets" in any of this workspace's Xcode projects
abstract_target 'AllTargets' do

#the following targets will inherit everything from AllTargets
target 'PolyNomePro' do
end

target 'PolyNome' do
end

pod "DeallocationChecker"
pod 'DeviceGuru'
pod 'Amplitude', '~> 7.1.0'
pod 'NotificationBannerSwift', '~> 3.0.0'
pod 'ConfettiView-NSHipster'
pod 'ShowTime'
pod 'MarqueeLabel'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod "ViewAnimator"
pod 'SwipeCellKit'
pod 'SwiftSpinner', '~> 2.0.0'
pod 'Finch', '~> 1.0.3'
pod 'JMHoledView', '~> 0.2.1'
pod 'PDColorPicker'
pod 'WhatsNewKit'
pod 'FittableFontLabel'
pod "FFGlobalAlertController"
pod 'SwiftKeychainWrapper'
pod 'EDColor', '~> 1.0.1'
pod 'FLAnimatedImage', '~> 1.0.12'
pod 'CorePlot', '~> 2.3'
pod 'MBProgressHUD', '~> 1.2.0'
pod 'CMPopTipView', '~> 2.2.0'
pod 'FontAwesomeKit', git: 'https://github.com/PrideChung/FontAwesomeKit.git'
pod 'Masonry', '~> 1.1.0'
pod 'SnapKit', '~> 5.0.0' 
pod 'RZViewActions', '~> 0.2.0'
pod 'KxMenu', '~> 1'
pod 'FTPopOverMenu', '~> 1.3.2' 
pod 'FTPopOverMenu_Swift', '~> 0.3.3'
pod 'WEPopover', '~> 2.5.3'
pod "XCDYouTubeKit", "~> 2.8"
pod 'DDExpandableButton', '~> 1.1.1'
pod 'Reachability', '~> 3.2'
pod 'MZTimerLabel', '~> 0.5.4'
pod 'Audiobus', '3.0.12'
pod 'DLPDFRenderer', '~> 1.1.2'
pod 'BNHtmlPdfKit', '~> 0.4.2'
pod 'DevContactSDK'
pod 'LGAlertView', '~> 2.4.0'
pod 'OBSlider', '~> 1.1.1'
pod 'MBCircularProgressBar', '~> 0.3.5'
pod 'FSCalendar'
pod 'MIKMIDI', '~> 1.7.0'
pod 'AirTurnUI', '~>4'

#//THE use_frameworks things end up not finding certain .h files. I can try replacing them all, but it'll take some time, and I think the ChartView ended up not working - so backup before trying
#use_frameworks! #//THIS BREAKS EVERYTHING - can't find .h files
#use_frameworks! :linkage => :static #trying this for being able to use modlues
#use_modular_headers!#THIS DID NOT MAKE A DIFFERENCE

end

#Now we define the pods we don't want to appear for Catalyst MacOS builds
def catalyst_unsupported_pods
  [
    "Firebase/Crashlytics",
"Firebase/Analytics",
"ConfettiView-NSHipster",
"DeallocationChecker"
  ]
end

post_install do |installer|

#create acknowledgements
  require 'fileutils'
  FileUtils.cp_r('Pods/Target Support Files/Pods-AllTargets-PolyNome/Pods-AllTargets-PolyNome-acknowledgements.plist', 'PolyNome/Acknowledgements.plist', :remove_destination => true)

#See debug info for Catalyst script
def debug
  true
end

#NOW Run the Ruby script that's supposed to strip the pods we don't want from Catalyst builds
installer.configure_support_catalyst

end
fermoya commented 3 years ago

@pnome I've noticed that:

I'd suggest you create a Sample project and start adding dependencies one by one and determining which ones compile with macCatalyst. This is my Podfie, it works fine:

# 1. Load the script
load "remove_ios_only_frameworks.rb"
use_frameworks!

abstract_target 'AllTargets' do

  target 'Sample'

  pod "DeallocationChecker"
  pod 'DeviceGuru'
  pod 'Amplitude', '~> 7.1.0'
  pod 'NotificationBannerSwift', '~> 3.0.0'
  pod 'ConfettiView-NSHipster'
  pod 'ShowTime'
  pod 'MarqueeLabel'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'
  pod "ViewAnimator"
  pod 'SwipeCellKit'
  pod 'SwiftSpinner', '~> 2.0.0'
  pod 'Finch', '~> 1.0.3'
  pod 'JMHoledView', '~> 0.2.1'
  pod 'PDColorPicker'
  pod 'WhatsNewKit'
  pod 'FittableFontLabel'
  pod "FFGlobalAlertController"
  pod 'SwiftKeychainWrapper'
  pod 'EDColor', '~> 1.0.1'
  pod 'FLAnimatedImage', '~> 1.0.12'
  pod 'CorePlot', '~> 2.3'
  pod 'MBProgressHUD', '~> 1.2.0'
  pod 'CMPopTipView', '~> 2.2.0'
  pod 'FontAwesomeKit', git: 'https://github.com/PrideChung/FontAwesomeKit.git'
  pod 'Masonry', '~> 1.1.0'
  pod 'SnapKit', '~> 5.0.0'
  pod 'RZViewActions', '~> 0.2.0'
  pod 'KxMenu', '~> 1'
  pod 'FTPopOverMenu', '~> 1.3.2'
  pod 'FTPopOverMenu_Swift', '~> 0.3.3'
  pod 'WEPopover', '~> 2.5.3'
  pod "XCDYouTubeKit", "~> 2.8"
  pod 'DDExpandableButton', '~> 1.1.1'
  pod 'Reachability', '~> 3.2'
  pod 'MZTimerLabel', '~> 0.5.4'
  pod 'Audiobus', '3.0.12'
  pod 'DLPDFRenderer', '~> 1.1.2'
  pod 'BNHtmlPdfKit', '~> 0.4.2'
  pod 'DevContactSDK'
  pod 'LGAlertView', '~> 2.4.0'
  pod 'OBSlider', '~> 1.1.1'
  pod 'MBCircularProgressBar', '~> 0.3.5'
  pod 'FSCalendar'
  pod 'MIKMIDI', '~> 1.7.0'
  #  pod 'AirTurnUI', '~> 4'

end

# 2. Define which libraries should be excluded for macCatalyst
def catalyst_unsupported_pods
  [
  "Firebase/Analytics",
  'ConfettiView-NSHipster',
  'Firebase/Crashlytics',
  'DeallocationChecker',
  'FTPopOverMenu',
  'FTPopOverMenu_Swift',
  'DLPDFRenderer',
  'BNHtmlPdfKit',
  'Audiobus',
  'DevContactSDK'
  ]
end

# 3. Run the script
post_install do |installer|
  installer.configure_support_catalyst
end
pnome commented 3 years ago

Firstly, I want to thank you for helping me out with this. My understanding of how pods and frameworks and build settings work is pretty limited, so your guidance is much appreciated.

You mentioned that I wasn't using use_frameworks! or use_modular_headers in my podfile.

There are 2 reasons I don't use use_frameworks!

  1. My project doesn't build if I use that setting. I have to go through all of my code and replace #import "xxx.h" with #import <xxx/xxx.h>. Eventually I end up at a place where some file or other still can't be found, then I have to undo. At least, that's what happened last time I tried.
  2. Reading this, it seems like I no longer need to use it, and it might be better to not.

I already had 'cocoapods', :disable_input_output_paths => true in my podfile (below the pods), and it looks like I had use_modular_headers but it was commented out.

I just re-added use_modular_headers and I can confirm that my app still runs on iOS with this setting enabled.

Should your script still work if I'm not using use_frameworks!?

Thanks for listing the pods that are incompatible. Some of those are quite heavily utilised in my app, so it's going to take some substantial re-writing in order to get things working.

However, before I get to that, I just want to check I'm going down the right path.

It was my understanding that the errors I'm getting when trying to build for Mac are related to Xcode not being able to compile certain pods for the Mac architecture.

Hence, I get an error like: module map file '.../Xcode/DerivedData/PolyNome-giehslaoapcxtwcaqjaiyulmarvy/Build/Products/Debug-maccatalyst/ConfettiView-NSHipster/ConfettiView.modulemap' not found I assumed that adding a pod to catalyst_unsupported_pods and removing any code references to it would be the equivalent of removing the pod from the podfile.

If I remove Confetti-View from the podfile and try to build for Mac, then the error above no longer appears. Instead, I get the same error but about the next incompatible pod.

But if I just add the pod to the catalyst_unsupported_pods list, it still tries to build it and I get the error above.

Is this the expected behaviour?

My original plan was to follow these steps until I got a build working:

  1. Build for Mac.
  2. Note which pod the build error relates to (e.g. Confett-View)
  3. Add that pod to catalyst_unsupported_pods
  4. pod update

Then repeat the process until I get no more errors.

Am I missing something in how it works behind the scenes? Is it necessary to have all incompatible pods in the catalyst_unsupported_pods list in order for Xcode to not build any specific one?

I hope the above makes sense.

Thanks again, Joe

fermoya commented 3 years ago

@pnome the steps you mention seem correct but I'd do it differently. I'd create a Dummy project, run pod init and start adding pods to the dummy project.

I think it's easier to go from nothing to the final result. Once you have them all, then use the same configuration in your project and deal with the precompiler.

The above is what I've done to test this. I first used use_frameworks! and the checked with use_modular_headers! along with 'cocoapods', :disable_input_output_paths => true. It worked in both scenarios. If you actually take a look at the Podfile I shared, it uses this second option.

All in all, if you define:

def catalyst_unsupported_pods
  [
  "Firebase/Analytics",
  'ConfettiView-NSHipster',
  'Firebase/Crashlytics',
  'DeallocationChecker',
  'FTPopOverMenu',
  'FTPopOverMenu_Swift',
  'DLPDFRenderer',
  'BNHtmlPdfKit',
  'Audiobus',
  'DevContactSDK'
  ]
end

The it should be fine. As I mentioned, try first in a Sample project as it'll be faster to compile and dependencies will be easier to link (Xcode fails sometimes and you need to clean and compile in certain order)

pnome commented 3 years ago

Thanks for the update. I've been working on this pretty solidly for the last couple of days.

I did as you said and started a dummy project. Like you said, it worked fine. So, I had something to compare to.

I discovered a difference in the Build Settings between my project and the dummy project.

In my project, Build Active Architectures Only was set to NO In the dummy project, it was set to YES for Debug, and NO for release and ad-hoc.

Once I set Build Active Architectures Only to YES for debug, my project no longer complained about modules that I'd told the ruby file to remove. Instead, the errors now reflect my references in code to modules that weren't imported. I think it should build once I go through and remove references to pods I can't use.

My concern now is that there might still be issues when building for ad-hoc, or release - since those have the Build Active Architectures Only to NO.

Anyway, I'll deal with that bridge when I come to it.

Thanks again for all your help with this. I may have more questions later.

Best, Joe

fermoya commented 3 years ago

It's going to be a PIA, especially if you have so many dependencies and considering you have a bunch that don't compile.

I'll close this for now then, glad it's starting to work 👍🏻