Skip to content

Commit eba5c63

Browse files
hbugdollhansemannn
andauthored
fix(ios): added dSYM for Swift framework-based modules (#14369)
* fix(ios): added dSYM for Swift framework-based modules * fix: improve code style * fix(ios): further code improvements --------- Co-authored-by: Hans Knöchel <[email protected]>
1 parent 8ae9374 commit eba5c63

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

iphone/cli/commands/_buildModule.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -753,21 +753,20 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
753753
}
754754

755755
createUniversalBinary(next) {
756-
this.logger.info('Creating universal library');
756+
this.logger.info('Creating universal framework/library');
757757

758758
const moduleId = this.isFramework ? this.moduleIdAsIdentifier : this.moduleId;
759759
const findLib = function (dest) {
760-
let libPath = this.isFramework ? '.xcarchive/Products/Library/Frameworks/' + moduleId + '.framework' : '.xcarchive/Products/usr/local/lib/lib' + this.moduleId + '.a';
761-
760+
let libPath = this.isFramework ? `.xcarchive/Products/Library/Frameworks/${moduleId}.framework` : `.xcarchive/Products/usr/local/lib/lib${moduleId}.a`;
762761
const lib = path.join(this.projectDir, 'build', dest + libPath);
763762
this.logger.info(`Looking for ${lib}`);
764763

765764
if (!fs.existsSync(lib)) {
766765
// unfortunately the initial module project template incorrectly
767766
// used the camel-cased module id
768-
libPath = '.xcarchive/Products/usr/local/lib/lib' + this.moduleIdAsIdentifier + '.a';
767+
libPath = `.xcarchive/Products/usr/local/lib/lib${this.moduleIdAsIdentifier}.a`;
769768
const newLib = path.join(this.projectDir, 'build', dest + libPath);
770-
this.logger.debug('Searching library: ' + newLib);
769+
this.logger.debug(`Searching library: ${newLib}`);
771770
if (!fs.existsSync(newLib)) {
772771
return new Error(`Unable to find the built Release-${dest} library`);
773772
} else {
@@ -777,6 +776,18 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
777776
}
778777
return lib;
779778
}.bind(this);
779+
// Find the debug symbols (dSYM) for the generated framework
780+
const findDSYM = function (dest) {
781+
const dSymPath = `.xcarchive/dSYMs/${moduleId}.framework.dSYM`;
782+
const dSym = path.join(this.projectDir, 'build', dest + dSymPath);
783+
this.logger.debug(`Looking for dSYM ${dSym}`);
784+
785+
if (!fs.existsSync(dSym)) {
786+
this.logger.warn(`Unable to find the Release-${dest} dSYM. Crash reports for ${moduleId} may be unsymbolicated.`);
787+
return null;
788+
}
789+
return dSym;
790+
}.bind(this);
780791

781792
// Create xcframework
782793
const args = [];
@@ -791,36 +802,41 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
791802
if (lib instanceof Error) {
792803
return next(lib);
793804
}
794-
795805
args.push('-create-xcframework');
796-
args.push(buildType);
797-
args.push(lib);
798-
806+
args.push(buildType, lib);
799807
if (!this.isFramework) {
800-
args.push('-headers');
801-
args.push(headerPath);
808+
args.push('-headers', headerPath);
809+
} else {
810+
// Include dSYM files in xcframework for symbolicated crash reports
811+
const dSym = findDSYM('iphoneos');
812+
dSym && args.push('-debug-symbols', dSym);
802813
}
803814

804815
lib = findLib('iphonesimulator');
805816
if (lib instanceof Error) {
806817
return next(lib);
807818
}
808-
args.push(buildType);
809-
args.push(lib);
819+
args.push(buildType, lib);
810820
if (!this.isFramework) {
811-
args.push('-headers');
812-
args.push(headerPath);
821+
args.push('-headers', headerPath);
822+
} else {
823+
// Include dSYM files in xcframework for symbolicated crash reports
824+
const dSym = findDSYM('iphonesimulator');
825+
dSym && args.push('-debug-symbols', dSym);
813826
}
827+
814828
if (this.isMacOSEnabled) {
815829
lib = findLib('macosx');
816830
if (lib instanceof Error) {
817831
this.logger.warn('The module is missing macOS support. Ignoring mac target for this module...');
818832
} else {
819-
args.push(buildType);
820-
args.push(lib);
833+
args.push(buildType, lib);
821834
if (!this.isFramework) {
822-
args.push('-headers');
823-
args.push(headerPath);
835+
args.push('-headers', headerPath);
836+
} else {
837+
// Include dSYM files in xcframework for symbolicated crash reports
838+
const dSym = findDSYM('macosx');
839+
dSym && args.push('-debug-symbols', dSym);
824840
}
825841
}
826842
}
@@ -857,7 +873,7 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
857873
}
858874

859875
async verifyBuildArch() {
860-
this.logger.info('Verifying universal library');
876+
this.logger.info('Verifying universal framework/library');
861877

862878
const moduleId = this.isFramework ? this.moduleIdAsIdentifier : this.moduleId;
863879
const frameworkPath = path.join(this.projectDir, 'build', moduleId + '.xcframework');
@@ -874,7 +890,7 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
874890
libraryPath = path.join(libraryPath, frameworkName);
875891
}
876892
if (!(await fs.pathExists(libraryPath))) {
877-
throw new Error(`Unable to find the built library ${libraryPath}`);
893+
throw new Error(`Unable to find the built framework/library ${libraryPath}`);
878894
}
879895
};
880896

@@ -954,7 +970,7 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks/**"`);
954970
binarylibName = this.isFramework ? this.moduleIdAsIdentifier + '.xcframework' : moduleId + '.xcframework',
955971
binarylibFile = path.join(this.projectDir, 'build', binarylibName);
956972

957-
this.logger.info(`binarylibFile is ${binarylibFile}`);
973+
this.logger.info(`Binary framework/library file: ${binarylibFile}`);
958974

959975
this.moduleZipPath = moduleZipFullPath;
960976

0 commit comments

Comments
 (0)