Cocoapods: APPLICATION_EXTENSION_API_ONLY is not set with Xcode 12 & CocoaPods 1.9.3

Created on 24 Sep 2020  Â·  19Comments  Â·  Source: CocoaPods/CocoaPods

Report

What did you do?

I have the following post install hook to make PureLayout work with extensions on iOS:

post_install do |installer|
  # NOTE: If you are using a CocoaPods version prior to 0.38, replace `pods_project` with `project` on the below line
  installer.pods_project.targets.each do |target|
    if target.name.end_with? "PureLayout"
      target.build_configurations.each do |build_configuration|
        if build_configuration.build_settings['APPLICATION_EXTENSION_API_ONLY'] == 'YES'
          build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'PURELAYOUT_APP_EXTENSIONS=1']
        end
      end
    end
  end
end

But after updating to CocoaPods 1.9.3 & Xcode 12, the APPLICATION_EXTENSION_API_ONLY flag is never set leaving the build configuration broken for PureLayout when built against extensions.

What did you expect to happen?

ℹ Please replace these two lines with what you expected to happen.
e.g. Install all pod dependencies correctly.

What happened instead?

ℹ Please replace these two lines with of what happened instead.
e.g. Pod A is missing the subspec B for target C.

CocoaPods Environment

ℹ Please replace these two lines with the output of pod env.
e.g. via pod env | pbcopy

Project that demonstrates the issue

ℹ Please link to a project we can download that reproduces the issue.
You can delete this section if your issue is unrelated to build problems,
i.e. it's only an issue with CocoaPods the tool.

Most helpful comment

@dnkoutso I suppose this can be fixed with the proper use of @available as outlined by @igor-makarov.

All 19 comments

Please upload a sample app demonstrating the issue.

Its very hard for us to diagnose with the given error report.

@dnkoutso it's not difficult to reproduce. Before CocoaPods 1.8 APPLICATION_EXTENSION_API_ONLY was set for widget extensions, it's not anymore. I had to downgrade to 1.7.5 to be able to build my project. I believe it's not difficult to set up a sample Xcode project with widget extension target and then just dump build_configuration.build_settings in post_install hook. The issue was raised on PureLayout repo too https://github.com/PureLayout/PureLayout/issues/245

@pronebird hmm We did have this https://github.com/CocoaPods/CocoaPods/issues/9233 that says 1.9.0 release and then this https://github.com/CocoaPods/CocoaPods/pull/9693 which is for 1.10.0.

Have you tried 1.10.0.rc.1 by any chance?

@dnkoutso yeah I saw that issue before & thought that it was fixed, but alas I couldn't build my Xcode project after updating from 1.5 -> 1.9.3. Then I downgraded to 1.8 - same issue, then 1.7.5 which worked. I haven't tried the 1.10 yet, but I can try it tomorrow morning.

Thanks a lot for trying it out. I will try to find sometime myself to check out for prior versions.

Please update here when you try 1.10 version.

@dnkoutso so I have just installed the 1.10.0.rc.1:

$ bundle info cocoapods
  * cocoapods (1.10.0.rc.1)
    Summary: The Cocoa library package manager.
    Homepage: https://github.com/CocoaPods/CocoaPods
    Path: /Users/pronebird/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.0.rc.1

$ pod --version
1.10.0.rc.1

$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 8 dependencies from the Podfile and 8 total pods installed.

Widget target has APPLICATION_EXTENSION_API_ONLY = YES as expected:

Screen Shot 2020-09-26 at 20 25 53

Pods project for the Today widget has APPLICATION_EXTENSION_API_ONLY = NO 😞

Screen Shot 2020-09-26 at 20 29 03

Switched back to 1.7.5:
Screen Shot 2020-09-26 at 20 33 09

It will really help to get a small sample project here that reproduces.

@dnkoutso Alright, here you go. I have copied a sample old-fashion widget project by Apple & added CocoaPods 1.10.0.rc.1 and PureLayout pod with no other changes to the source code of the sample app.

Git repo: https://github.com/pronebird/cocoapods-issue-10087

That's what I see on my end:

Screen Shot 2020-09-27 at 13 36 59

Thank you so much! I will hopefully find time this week to take a look.

I see what the problem is - the APPLICATION_EXTENSION_API_ONLY flag moved to the .xcconfig file, and is not in the .pbxproj as perviously.

@dnkoutso it seems like this issue is due to relying on an implementation detail of CocoaPods.

@pronebird - I've checked the uses of the PURELAYOUT_APP_EXTENSIONS flag in the referenced library and there's only one - for RTL checks. It looks like something that might be done much more portably by using an availability check:

if (@available(iOSApplicationExtension 10.0, *)) {
} else {
}

@igor-makarov not sure at what point the APPLICATION_EXTENSION_API_ONLY is added to the .xcconfig. I can't see it. https://github.com/pronebird/cocoapods-issue-10087/search?q=APPLICATION_EXTENSION_API_ONLY&type=

So sorry, is this still an issue?

I do not quite understand this:

@dnkoutso it seems like this issue is due to relying on an implementation detail of CocoaPods.

The PureLayout developers are recommending a post_install hook that's no longer working because some implementation detail in project configuration has moved from .pbxproj to .xcconfig.

I have advised them how to resolve this in a more portable way on their end.

I think we can close this, what do you think?

Ah, @pronebird wdyt? I think we can close this yes.

@dnkoutso I suppose this can be fixed with the proper use of @available as outlined by @igor-makarov.

Sounds good!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments

intelliot picture intelliot  Â·  3Comments

gerchicov-bp picture gerchicov-bp  Â·  3Comments

pronebird picture pronebird  Â·  3Comments

k06a picture k06a  Â·  3Comments