Skip to content

Commit

Permalink
Add lane to fetch/update dev certificates (#16)
Browse files Browse the repository at this point in the history
* Add lane to fetch/update dev certificates

* Configure Debug build to use development provisioning profile

* Add `xcconfig` to iOS project and DRY `DEVELOPMENT_TEAM` in it

* DRY `CODE_SIGN_STYLE` definition in `xcconfig` (`Manual`)

* DRY `CODE_SIGN_IDENTITY` in `xcconfig`

* Move `PROVISIONING_PROFILE_SPECIFIER` to `xcconfig`

* Move `_set_up_code_singing` out of `platform` block

* Remove odd `_` prefix from `set_up_code_signing`

See @spencertransier's question at
#16 (comment)

* Add `set_up_code_singing` lane that runs both App Store and Dev
  • Loading branch information
mokagio authored Jul 5, 2024
1 parent cdab550 commit 64ffd29
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 47 deletions.
71 changes: 44 additions & 27 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ USER_ENV_FILE_PATH = File.join(Dir.home, '.a8c-apps', ENV_FILE_NAME)
import 'lib/helpers.rb'

before_all do
setup_ci if runner.current_platform == :ios

Dotenv.load(USER_ENV_FILE_PATH)
end

Expand Down Expand Up @@ -64,7 +66,7 @@ platform :ios do

desc 'Builds the app for iOS and Mac Catalyst App Store distribution'
lane :build_for_app_store do |options|
set_up_code_signing unless options[:skip_code_signing_setup]
set_up_code_signing_app_store unless options[:skip_code_signing_setup]

shared_options = {
scheme: 'Blocknotes',
Expand Down Expand Up @@ -97,34 +99,17 @@ platform :ios do
)
end

desc 'Sets up code signing'
lane :set_up_code_signing do |options|
require_env_vars!(*ASC_API_KEY_ENV_VARS, *MATCH_ENV_VARS)

setup_ci
lane :set_up_code_signing do |readonly: true|
set_up_code_signing_app_store(readonly: readonly)
set_up_code_signing_deveploment(readonly: readonly)
end

shared_options = {
type: 'appstore',
app_identifier: BUNDLE_IDENTIFIER,
team_id: 'PZYM8XX95Q',
storage_mode: 's3',
s3_region: 'us-east-2',
s3_bucket: 'a8c-fastlane-match',
readonly: options.fetch(:readonly, true),
api_key: app_store_connect_api_key
}
lane :set_up_code_signing_app_store do |readonly: true|
set_up_code_signing(type: 'appstore', readonly: readonly)
end

sync_code_signing(
platform: 'ios',
**shared_options
)
sync_code_signing(
platform: 'catalyst',
# Without this, we'll get:
# error: exportArchive: Provisioning profile "match AppStore com.ellavandurpe.blocknotes catalyst" doesn't include signing certificate "3rd Party Mac Developer Installer: Automattic, Inc. (PZYM8XX95Q)".
additional_cert_types: 'mac_installer_distribution',
**shared_options
)
lane :set_up_code_signing_deveploment do |readonly: true|
set_up_code_signing(type: 'development', readonly: readonly)
end
end

Expand All @@ -139,3 +124,35 @@ def bump_build_number
build_number: latest_build_number + 1
)
end

def set_up_code_signing(type:, readonly: true)
require_env_vars!(*MATCH_ENV_VARS)

unless readonly
require_env_vars!(*ASC_API_KEY_ENV_VARS)
api_key = app_store_connect_api_key
end

shared_options = {
type: type,
app_identifier: BUNDLE_IDENTIFIER,
team_id: 'PZYM8XX95Q',
storage_mode: 's3',
s3_region: 'us-east-2',
s3_bucket: 'a8c-fastlane-match',
readonly: readonly,
api_key: api_key
}

sync_code_signing(
platform: 'ios',
**shared_options
)
sync_code_signing(
platform: 'catalyst',
# Without this, we'll get:
# error: exportArchive: Provisioning profile "match AppStore com.ellavandurpe.blocknotes catalyst" doesn't include signing certificate "3rd Party Mac Developer Installer: Automattic, Inc. (PZYM8XX95Q)".
additional_cert_types: 'mac_installer_distribution',
**shared_options
)
end
28 changes: 8 additions & 20 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
/* Begin PBXFileReference section */
04E5AB7A2A37305E0052580F /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };
3F6C399A2C34C40900776C37 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
3F6C399B2C34C46600776C37 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
3F6C399C2C34C46E00776C37 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
4C8F509035A341B5689A8624 /* Pods-Blocknotes.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Blocknotes.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Blocknotes/Pods-Blocknotes.debug.xcconfig"; sourceTree = "<group>"; };
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
504EC3041FED79650016851F /* Blocknotes.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Blocknotes.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -85,6 +88,9 @@
504EC3131FED79650016851F /* Info.plist */,
2FAD9762203C412B000D30F8 /* config.xml */,
50B271D01FEDC1A000F3C39B /* public */,
3F6C399A2C34C40900776C37 /* Base.xcconfig */,
3F6C399B2C34C46600776C37 /* Debug.xcconfig */,
3F6C399C2C34C46E00776C37 /* Release.xcconfig */,
);
path = App;
sourceTree = "<group>";
Expand Down Expand Up @@ -245,6 +251,7 @@
/* Begin XCBuildConfiguration section */
504EC3141FED79650016851F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3F6C399B2C34C46600776C37 /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -275,7 +282,6 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -305,6 +311,7 @@
};
504EC3151FED79650016851F /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3F6C399C2C34C46E00776C37 /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -335,7 +342,6 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
Expand Down Expand Up @@ -363,13 +369,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = PZYM8XX95Q;
"DEVELOPMENT_TEAM[sdk=macosx*]" = PZYM8XX95Q;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -380,9 +380,6 @@
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.ellavandurpe.blocknotes;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.ellavandurpe.blocknotes";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "match AppStore com.ellavandurpe.blocknotes catalyst";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand All @@ -398,13 +395,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = PZYM8XX95Q;
"DEVELOPMENT_TEAM[sdk=macosx*]" = PZYM8XX95Q;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -414,9 +405,6 @@
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.ellavandurpe.blocknotes;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.ellavandurpe.blocknotes";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "match AppStore com.ellavandurpe.blocknotes catalyst";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down
2 changes: 2 additions & 0 deletions ios/App/App/Base.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEVELOPMENT_TEAM = PZYM8XX95Q
CODE_SIGN_STYLE = Manual
6 changes: 6 additions & 0 deletions ios/App/App/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "Base.xcconfig"

CODE_SIGN_IDENTITY = Apple Development

PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*] = match Development com.ellavandurpe.blocknotes
PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] = match Development com.ellavandurpe.blocknotes catalyst
6 changes: 6 additions & 0 deletions ios/App/App/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "Base.xcconfig"

CODE_SIGN_IDENTITY = Apple Distribution

PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*] = match AppStore com.ellavandurpe.blocknotes
PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] = match AppStore com.ellavandurpe.blocknotes catalyst

0 comments on commit 64ffd29

Please sign in to comment.