Appboy / appboy-ios-sdk

Public repo for the Braze iOS SDK
https://www.braze.com
Other
165 stars 142 forks source link

The run script for SPM support requires a clean build for each successive build/run #283

Closed smawpaw closed 3 years ago

smawpaw commented 3 years ago

Report

Describe your environment.

Info Value
Platform Name iOS / Catalyst
Platform Version 13+ for iOS, 14+ for Catalyst
SDK Version 3.34.0
Integration Method SPM
Xcode Version Xcode 12.2
Repro rate all the time (100%)

What did you do?

Tried to build/run the app a second time after an initial run

What did you expect to happen?

The app to build & run without error and without needing to clean build each time

What happened instead?

We get the error library not found for -lAppboyKitLibrary.

What I believe is happening:

Steps to reproduce

Code Snippet

The post-action run script

# iOS
bash "$BUILT_PRODUCTS_DIR/Appboy_iOS_SDK_AppboyKit.bundle/Appboy.bundle/appboy-spm-cleanup.sh"
# macOS (if applicable)
bash "$BUILT_PRODUCTS_DIR/Appboy_iOS_SDK_AppboyKit.bundle/Contents/Resources/Appboy.bundle/appboy-spm-cleanup.sh"

Clean up bash script

#! /bin/sh

# AppboyKitLibrary
find "$BUILT_PRODUCTS_DIR/" -name libAppboyKitLibrary.a -exec rm {} \;

# AppboyPushStory
rm -rf "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/AppboyPushStory.framework"
find "$BUILT_PRODUCTS_DIR/$PLUGINS_FOLDER_PATH/" -name "AppboyPushStory.framework" -exec rm -r {} \;

Project that demonstrates the issue

BrazeTest 2.zip

Thanks! 🙏

hokstuff commented 3 years ago

Hi @smawpaw,

Thanks for filing this! We've been able to repro on our end and are working on a fix.

smawpaw commented 3 years ago

@hokstuff Thanks!

Some new info that may help: we have some reservations about the scheme-based run script. We have a multi-scheme project, so that alone was several copy-pastas, and overall it just felt a little unusual. We would much prefer a Build Phase script (or no script at all 😇).

But, just poking around I was able to get the same scheme script to work as a Build Phase script by ticking the For install builds only box. Unfortunately, this was more of a "let's see what happens" moment than a "ah, this oughta do it!".

But, not only does it appear to work, it also fixed this reported issue. I do not need to clean build for each successive run with the script in Build Phases as described.

Screen Shot 2021-03-11 at 12 04 03 PM
lowip commented 3 years ago

Hi @smawpaw,

Glad that you were able to find a workaround. We have released 4.0.0 that should fix the issue. We encourage you still to upgrade as the previous version of appboy-spm-cleanup.sh would delete cache files which Xcode relies on for incremental build.

We've heard reports that this cleanup step might no longer be needed in the last Xcode 12.5 beta and we'll make sure to update our integration documentation when the next Golden Master is released.