The Pods-App target has transitive dependencies that include static binaries when using GTM in a fast structure

I am trying to rework a part of the project with fast 3 to make it a quick structure , to use it as a container. The thing is, I need to use the GoogleTagManager legacy (v3) property as a dependency, and when doing pod spec lint :

I get the following error:

ERROR | [iOS] unknown: An unknown error was detected (the "Pods-App" target has transitive dependencies that include static binaries: (/ private / var / folders / 7t / 0cd0n1gn46xd7r1cywrgcy2w0000gn / T / CocoaPods / Lint / Pods / GoogleTagManager / Libraries / libTagMan .a)) during verification.

Or with GTM v5:

ERROR | [iOS] unknown: An unknown error was detected (the "Pods-App" target has transitive dependencies that include static binaries: (/ private / var / folders / 7t / 0cd0n1gn46xd7r1cywrgcy2w0000gn / T / CocoaPods / Lint / Pods / GoogleTagManager / Frameworks / GoogleTagMan .framework)) during validation.

I am using the latest version of cocoapods (1.1.0.rc.2), and as I understand it, the problem comes from the dependencies of the GTM module, which at least one is a static library.

I read several threads where people talk about workarounds for installing static libraries within the framework or for transferring static libraries to the structure when creating the container. The fact is that the static library is a dependency of the GTM module, so I can not control it. At least this is what I understood in here .

Here is my subfile:

 # Uncomment this line to define a global platform for your project platform :ios, '8.0' target 'MyProject' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks # use_frameworks! # Pods for MyProject pod 'GoogleTagManager', '~> 3.15.2' end 

and here is my (short for StackOverflow) MyProject.podspec:

 Pod::Spec.new do |s| s.name = "MyProject" s.version = "0.1.0" s.platform = :ios, '8.0' s.ios.deployment_target = '8.0' s.source_files = "MyProject", "MyProject/**/*.{h,m}", "MyProject/**/*.{swift}" s.dependency 'GoogleTagManager', '~> 5.0.0' end 

I already tried to download the GTM SDK and install it without cocoapods, but I think I skipped the step because I could not get it to work.

So, I would like to get some tips on my podspec and podfile files or explain how to install the SDK without cocoapods. Many thanks!

+6
source share
1 answer

Well, after several months I had to go back to this project. Since the GTM module has not changed and still has static libraries as dependencies, it is still impossible to create a framework with the GTM module as a dependency and distribute it through Cocoapods.

In the end, I decided to ignore Cocoapods and manually add third-party frameworks to mine. Thus, this answer is not fully consistent with my question, but this is the only way that I found to assign to my structure.

So, the first step is to create a new project. Choose Cocoa Touch Framework :

Choose Cocoa Touch Framework

Give it a name, mine will be myFramework. When your workplace is ready, add a new goal to it:

how to add a new goal

Go to the cross-platform tab and select the “Assembly” template. I will name my Unit (so much originality). But for now, we will not worry about that.

Aggregate goal

Once you do, your workplace is set up to create your amazing structure! Immerse yourself a little further!

You will now create or copy the source files. If you copy them, do not forget to check the Copy elements if necessary box and make sure that they are added to the frame target:

check options when copying your files

Until now, I do not think that a big surprise.

Since my question was about GTM, this is the structure we are going to add as a dependency for our structure. I could not find the source elsewhere on Cocoapods, so I created a new project (I used the application template and named it PodApp), then I added Cocoapods to it. Open a terminal and go to the PodApp project folder:

  • pod init
  • vi Podfile
  • In the #Pods for PodApp section, add the pod 'GoogleTagManager', '~> 6.0.0'
  • Save and close the Subfile and run pod install
  • After downloading and installing the dependencies, close the PodApp project window and run open PodApp.xcworkspace

In your Framework project, add a new new group that you will name Framework (right click in Xcode Navigator -> new group). You will copy all Cocoapods dependencies loaded into the PodApp project in the Frameworks myFramework group. Once again, be sure to add it to myFramework target and copy the elements if necessary , as shown above.

Dragging and dropping frameworks in your project

In the image below, click 1 , 2 , 3 , if everything goes well, you should see the frames / libraries that you just added to 4 .

xcode project

In order for Firebase to work well, you will also need to establish a connection with AdSupport.framework. Just click on the + icon ( 5 ), find it and add it.

I had some problems with GoogleToolBoxForMac, I needed to create a PodApp project and copy the GoogleToolBoxForMac.framework file under PodApp / Pods / Products / in the myFramework / Frameworks / group. Remember to add it to the correct target and copy the item .

Another tricky part about GTM: you need to add some resources to your infrastructure. Follow the step in the following image:

enter image description here

In the popup that opens, click Add another and find where you saved GTM.framework, expand it and add TagManagerResources.bundle (do not forget to copy the item!).

TagManagerResources.bundle

Since other resources may give you warnings (in this particular example), you can remove them with - .

If you want the end user of your framework to be able to use the frameworks you are investing directly above the Copy Bundle Resources, open the Headers panel, drag and drop all the project headers to the public view.

Now all of these frameworks can be accessed by your own infrastructure, but to make them available, you must import your headers into your myFramework.h file:

 #import <myFramework/AnObjectiveCClass.h> #import <GoogleTagManager/GoogleTagManager.h> #import <GoogleTagManager/TAGCustomFunction.h> #import <myFramework/GTMDefines.h> #import <myFramework/GTMNSData+zlib.h> #import <FirebaseCore/FirebaseCore.h> #import <FirebaseAnalytics/FirebaseAnalytics.h> #import <FirebaseInstanceID/FirebaseInstanceID.h> #import <myFramework/GAI.h> #import <myFramework/GAIDictionaryBuilder.h> #import <myFramework/GAIEcommerceFields.h> #import <myFramework/GAIEcommerceProduct.h> #import <myFramework/GAIEcommerceProductAction.h> #import <myFramework/GAIEcommercePromotion.h> #import <myFramework/GAIFields.h> #import <myFramework/GAILogger.h> #import <myFramework/GAITrackedViewController.h> #import <myFramework/GAITracker.h> #import <myFramework/pb_encode.h> #import <myFramework/pb.h> #import <myFramework/pb_decode.h> #import <myFramework/pb_common.h> 

Ok, we are almost done!

Project Information / Build Settings

Now select the "Information" section of your project ( 1 in the image above), check the version for which you are building (mine is 8.0 for backward compatibility with most devices). In the Configurations panel, remove Debug by selecting it and clicking - . Now select "Build Settings" ( 2 on the image), here we will make some changes.

  • Built-in Active Architecture Only : None
  • Allow non-modular inclusion in structural modules : No
  • Valid architectures : arm64 armv7 i386 x86_64 (since armv7s does not create for some frameworks in this example)
  • Preprocessor macros : PB_NO_PACKED_STRUCTS = 1 PB_FIELD_32BIT = 1
  • Enable Modules (C and Objective-C) : Yes

For your two purposes, for the specified build settings, set them to $ (inherited), which means that they inherit the parameters that you just set in the build settings of the project.

As part of the target environment, I also set Other linker flags as what was set in the PodApp project, but I'm not 100% sure that this is necessary.

(FYI, here they are: $ (inherited) -ObjC -l "GoogleAnalytics" -l "C ++" -l "sqlite3" -l "z" -advertising "AdSupport" -camera "CoreTelephony" -framework "FirebaseAnalytics" - framework "FirebaseCore" -framework "FirebaseInstanceID" -framework "GoogleSymbolUtilities" -framework "GoogleTagManager" -fragment "GoogleToolboxForMac" -framework "GoogleUtilities" -framework "JavaScriptCore" -fragment "SystemConfiguration" "" -Framework Store " framework "CoreData")

Set Define Modules to yes .

Now select the Aggregate target, which will create a live framework, a file containing several versions of our framework, one for each architecture that we indicated a few steps back (arm64 armv7 i386 x86_64). We will need to tell Xcode that we want it to be created. Follow the instructions below image ( 1 ):

image description

In the build steps, you want your Aggregate target to create myFramework.framework before being inline.

After adding myFramework.framework, click on the + icon, designated as 2 , and select New Start Script Phase , Paste the following Script into it:

 # Merge Script # 1 # Set bash script to exit immediately if any commands fail. set -e # 2 # Setup some constants for use later on. FRAMEWORK_NAME="myFramework" # 3 # If remnants from a previous build exist, delete them. if [ -d "${SRCROOT}/build" ]; then rm -rf "${SRCROOT}/build" fi # 4 # Build the framework for device and for simulator (using # all needed architectures). xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch arm64 -arch armv7 -arch armv7s only_active_arch=no defines_module=yes -sdk "iphoneos" xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch x86_64 -arch i386 only_active_arch=no defines_module=yes -sdk "iphonesimulator" # 5 # Remove .framework file if exists from previous run. if [ -d "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework" ]; then rm -rf "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework" fi # 6 # Copy the device version of framework to Framework directory. cp -r "${SRCROOT}/build/Release-iphoneos/${FRAMEWORK_NAME}.framework" "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework" # 7 # Replace the framework executable within the framework with # a new version created by merging the device and simulator # frameworks' executables with lipo. lipo -create -output "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SRCROOT}/build/Release-iphoneos/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SRCROOT}/build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" # 8 # Copy the Swift module mappings for the simulator into the # framework. The device mappings already exist from step 6. cp -r "${SRCROOT}/build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/" "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule" # 9 # Delete the most recent build. if [ -d "${SRCROOT}/build" ]; then rm -rf "${SRCROOT}/build" fi # 10 # Remove .zip file if exists from previous run. if [ -d "${PROJECT_DIR}/${FRAMEWORK_NAME}.zip" ]; then rm -rf "${PROJECT_DIR}/${FRAMEWORK_NAME}.zip" fi # 11 # Zip the Framework and License all together. zip -r "${PROJECT_DIR}/${FRAMEWORK_NAME}.zip" "${PROJECT_DIR}/LICENSE" "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework" 

In the Script step, change the name with your frame name. Take time to understand what he is doing and change his behavior if it does not meet your requirements. In the end, this is what it creates the framework and zip archive in the project folder. I did this to link it with every release of Github.

Now everything should work fine. Select "Unit" as the active circuit and run it.

Run aggregate scheme

If you want to add your framework to the test application, create a new application project, just drag and drop myFramework.framework (for example, from the myFramework folder) into the application project. Once again, be sure to add it to the correct target and copy the elements. In your application’s target theme, on the General tab , add your framework to the Embedded Binaries panel, but remove it once from the Related Structures and Libraries because it needs to be there twice (check it before doing this). Import the framework

 import myFramework 

and start using what you have created!

NB: if you are trying to use GTM, do not forget to add material related to GTM integration (your container and the GoogleInfo plugin):

GTM Related Material

I really hope this helps you! Feel free to comment if something is unclear or if you encounter a problem, I will do my best to help you.

Please find my sources below:

+1
source

All Articles